Repository Public License
1#!/usr/bin/env bash2# ORIX Secure3# File: Scripts/check.sh4# Description: Repository hygiene checks: author header on every first-party source file, and a scan of tracked and staged5# files for credentials, signing material, private addresses and remote package dependencies. Exits non-zero on any finding.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -uo pipefail10cd "$(dirname "$0")/.."11status=01213echo "== headers"14while IFS= read -r file; do15 head -12 "$file" | grep -q "Author: Simon-Pierre Boucher" || { echo "missing header: $file"; status=1; }16done < <(git ls-files -co --exclude-standard -- '*.swift' '*.sh' '*.py' 'project.yml')1718echo "== secrets"19files=$(git ls-files -co --exclude-standard)20# File types that must never be tracked.21echo "$files" | grep -E '\.(p8|p12|cer|mobileprovision|provisionprofile|keychain|pem)$|(^|/)\.env|AuthKey_' && { echo "signing material or env file present"; status=1; }22# Content patterns: private keys, API key assignments, issuer ids, bearer tokens, sudo-style passwords.23patterns='-----BEGIN [A-Z ]*PRIVATE KEY-----|AuthKey_[A-Z0-9]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.*(issuer|ISSUER)|(issuer|ISSUER).*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(api[_-]?key|apikey|secret|token|password|passwd)["'"'"' ]*[:=] *["'"'"'][^"'"'"' ]{8,}|sk-[A-Za-z0-9_-]{20,}|ghp_[A-Za-z0-9]{30,}'24hits=$(echo "$files" | grep -vE '\.(png|jpg|jpeg|pdf|ico)$|^Scripts/check\.sh$' | tr '\n' '\0' | xargs -0 grep -nIE "$patterns" 2>/dev/null || true)25if [[ -n "$hits" ]]; then echo "$hits" | cut -c1-200; status=1; fi26# Private network addresses of the author's own machines must not leak through docs, scripts or configuration.27# (Swift sources and the string catalog derived from them are excluded: the URL and network engines and their tests legitimately contain example addresses.)28addresses='192\.168\.[0-9]+\.[0-9]+|100\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\.[0-9]+\.[0-9]+|10\.67\.[0-9]+\.[0-9]+'29hits=$(echo "$files" | grep -vE '\.(png|jpg|jpeg|pdf|ico|swift|xcstrings)$|^Scripts/check\.sh$|^Scripts/translations-fr\.json$' | tr '\n' '\0' | xargs -0 grep -nIE "$addresses" 2>/dev/null || true)30if [[ -n "$hits" ]]; then echo "$hits" | cut -c1-200; status=1; fi31# No third-party code, analytics or advertising SDK: every package dependency must be a local path.32remote=$(grep -rnE '\.package\(url:' Packages/*/Package.swift project.yml 2>/dev/null || true)33if [[ -n "$remote" ]]; then echo "remote package dependency: $remote"; status=1; fi3435[[ $status -eq 0 ]] && echo "clean" || echo "FINDINGS"36exit $status37