Files
d37233e0c3 security: repo-wide client-identifier leak guard (fail-closed) + pre-commit hook (#65)
The existing hashed-denylist scan lives in lint_skills.py and only covers
skills/**. The identifier leak that motivated this guard landed in README.md
and tests/ — files that linter never sees, and skill-lint.yml only triggers on
skills/** paths anyway. It also fails OPEN: a missing denylist prints a NOTE
and exits 0.

This closes both holes:

- scripts/scan_identifiers.py — standalone scanner reusing the same denylist
  file and 1-/2-word shingle-hash logic, but over EVERY tracked text file
  (git ls-files, minus binaries). Fails CLOSED: missing/empty denylist = exit 2.
- .github/workflows/leak-guard.yml — runs it (and its self-test) on every push
  and PR with NO path filter. contents: read.
- .githooks/pre-commit — same scan locally before push (opt-in via
  `git config core.hooksPath .githooks`).
- scripts/test_scan_identifiers.py — stdlib self-check: catch, clean,
  case-insensitive, and fail-closed behaviors.
- scripts/.identifier-denylist.sha256 — added the single-word hash to
  complement the existing two-word entry (both now covered).
- CONTRIBUTING.md — documents the guard, the hook, and how to ban a new
  identifier without committing the plaintext.

Verified: whole-repo scan 0 matches / exit 0; self-test passes; missing denylist
exits 2; a planted identifier is blocked by both the scanner and the hook;
lint_skills.py still 0 errors. (The guard even caught a client name I'd left in
this scanner's own docstring — removed.)

Scope note: identifier-only by design. Repo-wide secret scanning is deferred —
it would false-positive on the synthetic AKIA test keys in docs/verification/,
which need allowlist work first. Secrets stay covered by lint_skills.py (skills)
and secret_scan.py.

Co-authored-by: Sachin Sharma <elementalsoul@Sachins-MacBook-Pro.local>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 20:27:39 +05:30

11 lines
498 B
Bash
Executable File

#!/usr/bin/env bash
# Block commits that contain client/engagement identifiers (hashed denylist).
# Enable once per clone: git config core.hooksPath .githooks
# Mechanism: scripts/scan_identifiers.py (fails closed if the denylist is missing).
python3 scripts/scan_identifiers.py || {
echo ""
echo "pre-commit: client-identifier scan failed — commit blocked."
echo "Remove the flagged identifier(s), or add a NEW banned term via scripts/.identifier-denylist.local (gitignored)."
exit 1
}