max / audiofiles
- Co-Authored-By
- Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 file changed,
+25 insertions,
-0 deletions
| @@ -15,6 +15,31 @@ | |||
| 15 | 15 | ROOT="$(git rev-parse --show-toplevel)" | |
| 16 | 16 | cd "$ROOT" | |
| 17 | 17 | ||
| 18 | + | # --- secret scan (gitleaks) ------------------------------------------------- | |
| 19 | + | # Independent guardrail: blocks a commit whose staged changes contain a secret, | |
| 20 | + | # regardless of whether a human judged the value "safe". Shared ruleset lives at | |
| 21 | + | # ~/Code/.gitleaks.toml. Degrades gracefully if gitleaks is not installed (the | |
| 22 | + | # astra pre-receive hook is the backstop that always runs). Task: infra 97ffeda0. | |
| 23 | + | if command -v gitleaks >/dev/null 2>&1; then | |
| 24 | + | GL_CFG="" | |
| 25 | + | if [ -f "$ROOT/.gitleaks.toml" ]; then | |
| 26 | + | GL_CFG="$ROOT/.gitleaks.toml" | |
| 27 | + | elif [ -f "$HOME/Code/.gitleaks.toml" ]; then | |
| 28 | + | GL_CFG="$HOME/Code/.gitleaks.toml" | |
| 29 | + | fi | |
| 30 | + | gl_args=(git --staged --no-banner --redact) | |
| 31 | + | [ -n "$GL_CFG" ] && gl_args+=(-c "$GL_CFG") | |
| 32 | + | if ! gitleaks "${gl_args[@]}"; then | |
| 33 | + | echo "pre-commit: gitleaks found a secret in the staged changes." | |
| 34 | + | echo " remove it (or allowlist a false positive), then restage." | |
| 35 | + | echo " bypass: git commit --no-verify." | |
| 36 | + | exit 1 | |
| 37 | + | fi | |
| 38 | + | echo "pre-commit: gitleaks clean." | |
| 39 | + | else | |
| 40 | + | echo "pre-commit: gitleaks not installed; skipping secret scan (astra gates on push)." | |
| 41 | + | fi | |
| 42 | + | ||
| 18 | 43 | # Paths the gate ignores (extended regex, matched against repo-relative paths). | |
| 19 | 44 | # Empty means check everything. | |
| 20 | 45 | SKIP_PATHS="${SKIP_PATHS:-}" |