SPB Git

Repository Public

check.sh 1.4 KB 25 lines shellscript

1#!/bin/bash2# ORIX Docs3# File: Scripts/check.sh4# Description: Repository hygiene before a push: secret scan over tracked files and file-header check on first-party sources.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -uo pipefail9cd "$(dirname "$0")/.."10FAIL=011echo "== Secret scan (tracked files) =="12PATTERN='(-----BEGIN [A-Z ]*PRIVATE KEY-----|AKIA[0-9A-Z]{16}|sk-[A-Za-z0-9]{32,}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,}|(password|passwd|secret|api[_-]?key|token)[[:space:]]*[:=][[:space:]]*["'"'"'][^"'"'"' ]{8,}["'"'"'])'13HITS=$(git ls-files -z | grep -zvE '\.(png|docx|pdf|icns|car|otf|ttf)$' | xargs -0 grep -nIEi "$PATTERN" 2>/dev/null | grep -vE "Scripts/check.sh|keychain-profile|NOTARY_PROFILE" || true)14if [[ -n "$HITS" ]]; then echo "$HITS" | cut -c1-200; FAIL=1; else echo "no secret-like strings found"; fi15FORBIDDEN=$(git ls-files | grep -E '\.(p12|p8|cer|mobileprovision|provisionprofile|pem|keychain)$|(^|/)\.env' || true)16if [[ -n "$FORBIDDEN" ]]; then echo "credential-like files are tracked:"; echo "$FORBIDDEN"; FAIL=1; fi17echo "== File headers =="18MISSING=019while IFS= read -r f; do20  head -16 "$f" | grep -q "Author: Simon-Pierre Boucher" || { echo "missing header: $f"; MISSING=$((MISSING+1)); }21done < <(git ls-files | grep -E '\.(swift|sh|py)$' | grep -v "/Corpus/")22echo "$MISSING first-party source files without the header"23[[ $MISSING -eq 0 ]] || FAIL=124exit $FAIL25
Files main
Menu

Theme