Skip to content

PR-10: gitleaks pack + portable pre-commit fallback (scanner) - #39

Merged
emmanuelgjr merged 1 commit into
mainfrom
improve/pr-10-gitleaks
Jul 18, 2026
Merged

PR-10: gitleaks pack + portable pre-commit fallback (scanner)#39
emmanuelgjr merged 1 commit into
mainfrom
improve/pr-10-gitleaks

Conversation

@emmanuelgjr

Copy link
Copy Markdown
Contributor

Completes Phase 2 → v0.3 release-ready. Depends on PR-04.

What's here

  • integrations/gitleaks/dsgai.toml — a gitleaks rule pack for the DSGAI credential set: quote-optional named assignments (OpenAI/Anthropic/Cohere/Google/HF/AWS/Azure/GCP/vector-store/LangSmith/Langfuse) and raw token prefixes (xoxb-, ghp_, github_pat_, AIza, AKIA, sk-ant-/sk-proj-, JWT). Allowlists tests/fixtures/**, lockfiles, minified JS, snapshots.
  • pre-commit-hook.md now recommends gitleaks as the primary path (entropy-aware, cross-platform) with pre-commit-framework and plain-hook snippets; the ripgrep script is documented as the zero-dependency fallback.
  • dsgai-secret-scan.sh fixed for portability:
    • mapfile -d '' → a bash-3.2-safe while IFS= read -r -d '' loop
    • grep -zE (BSD grep lacks -z) → a case extension filter
    • quote-optional value pattern (fixes the unquoted-.env false negative)
    • new token-prefix branch so xoxb-/ghp_/etc. are caught by any variable name

Verification (with gitleaks 8.30.1 + the script pattern)

  • Both paths flag .env (unquoted key) and js-service/index.js (xoxb- token).
  • Neither flags good_config.py (Vault retrieval).
  • A whole-repo gitleaks scan allowlists tests/fixtures/**0 fixture leaks.
  • shellcheck clean; no bash-4 builtins (bash-3.2 / BSD safe by review).

Note

A repo-wide gitleaks scan flags CONTRIBUTING.md's fake sk-proj-FAKE… example — that's correct (it's a real sk-proj- literal). I did not globally allowlist FAKE values because the fixture detection the acceptance requires depends on those values being detected.

- integrations/gitleaks/dsgai.toml: gitleaks pack for the DSGAI credential set
  (quote-optional named assignments + raw token prefixes: xoxb-, ghp_,
  github_pat_, AIza, AKIA, sk-ant-/sk-proj-, JWT) with an allowlist for
  tests/fixtures/**, lockfiles, minified JS, snapshots. Recommended as the
  primary pre-commit path in pre-commit-hook.md (entropy-aware, cross-platform).
- Fix the bespoke dsgai-secret-scan.sh fallback for portability:
    * mapfile -d '' -> bash-3.2-safe 'while IFS= read -r -d '' loop
    * grep -zE (BSD grep lacks -z) -> a case-statement extension filter
    * quote-optional value pattern (fixes the unquoted-.env false negative)
    * new token-prefix branch so xoxb-/ghp_/etc. are caught by any var name
  shellcheck clean; no bash-4 builtins (bash-3.2 / BSD safe).

Verified against the fixture with gitleaks 8.30.1 and the script pattern:
  - both flag .env (unquoted key) and js-service/index.js (xoxb- token)
  - neither flags good_config.py (Vault retrieval)
  - a whole-repo gitleaks scan allowlists tests/fixtures/** (0 fixture leaks)
Acceptance met (the CONTRIBUTING.md fake-example match in a repo-wide scan is
expected — it is a real sk-proj- literal; the fixture detection the acceptance
needs precludes globally allowlisting FAKE values).
@emmanuelgjr
emmanuelgjr merged commit 5a334cd into main Jul 18, 2026
9 checks passed
@emmanuelgjr
emmanuelgjr deleted the improve/pr-10-gitleaks branch July 18, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant