Secrets Audit¶
Audit a repository for exposed secrets — hardcoded tokens, committed .env files, credentials in git history — and check .gitignore and .env.example hygiene.
Trigger: /secrets-audit
How It Works¶
- Redaction rule first — every finding is reported as file, line, and variable name plus a fingerprint (first 4 characters + length). The full secret value never appears in output, so the audit can't become the leak.
- Ignore hygiene —
.gitignoremust cover.env,.streamlit/secrets.toml,*.pem,*.key,credentials*.json; missing entries are listed. - Tracked files —
git ls-filesis checked for secret-holding files, because.gitignoredoesn't help if the file was added before the rule existed. - Working-tree scan —
gitleaks/trufflehogwhen installed, otherwise grep patterns for assignments, known token prefixes (ghp_,sk-,AKIA, JWTs), and URLs with embedded credentials — with placeholders filtered out. - History scan — the whole log, not just HEAD: a secret deleted in a later commit is still in every clone. Huge repos get a bounded scan, stated honestly in the report.
.env.examplecheck — example files must hold placeholders only.- Severity-ranked report — LEAKED (pushed: rotate now), committed-but-unpushed (scrub via Git Rescue), hardcoded in the tree, and hygiene gaps — ending in a one-line verdict: CLEAN / HYGIENE GAPS / LEAKED.
- Stop after reporting — rotation, history rewrites, and
.gitignoreedits happen only when the user asks.
Redacted Reporting¶
Bad: the audit becomes the leak
The full token is now in the conversation, the terminal scrollback, and any transcript that captures them.Good: location and fingerprint, never the value
Verdict Honesty¶
Bad: green because the tip is clean
The scan only looked at HEAD; the token deleted in last week's "remove key" commit is still in history and in every clone.Good: history included, gaps named
Verdict: LEAKED (1) + HYGIENE GAPS (2)
- MOTHERDUCK_TOKEN in commits a1b2c3d..f4e5d6a, pushed → rotate now, then /git-rescue to scrub.
- trades.db tracked by git → add to .gitignore, git rm --cached trades.db
- .env.example line 3 holds a real-looking key (sk-p…, 51 chars) → replace with a placeholder
Notes¶
- Rotation beats deletion, always. A secret that touched a pushed commit, a log file, or a pasted terminal is compromised no matter how thoroughly it's scrubbed. Every LEAKED finding says "rotate" before anything about cleanup.
- The skill never opens
.envorsecrets.tomlto "verify" contents — presence checks and pattern scans are enough; reading a secrets file pulls the values into the conversation. - Read-only by design: no
git filter-repo, no.gitignoreedits, no rotation. History surgery is Git Rescue's job. - Natural habit points: before Deploy Streamlit pushes a repo, before flipping a repo public in New Project, and after a Git Rescue secret cleanup.