Run gitleaks or TruffleHog across an estate for the first time and you get hundreds of findings spanning years of git history — real keys, test keys, false positives, and long-dead credentials, all shouting equally.
Tier: Foundation · Hands-on time: ~40 minutes
The deterministic scanners are the source of truth; AI's job is the toil around them: classifying findings, drafting per-repo remediation PRs, and writing the rotation runbook for each credential type. One rule is absolute: the AI never sees the secret values, and rotation itself is executed by a human.
Skip AI for a single confirmed live leak — that is an incident: rotate now, then come back for the sweep.
Strip values, keep shape. Preprocess the scanner JSON: drop/mask the matched secret strings, keep rule type, entropy, file path, commit age, and repo. This sanitized export is the only thing that ever enters a prompt.
Classify and rank the pile.
Attached: sanitized secret-scan findings (no secret values) plus repo
metadata. Classify each finding:
- LIVE-RISK: credential type still plausibly valid (cloud key, DB
password, API token) in an active repo
- HISTORICAL: only in old commits, file since removed
- TEST/FAKE: paths and rule types suggesting fixtures or examples
- NEEDS-HUMAN: cannot determine from metadata
Rank LIVE-RISK by blast radius (cloud admin creds > service tokens >
webhook secrets). Group all findings by repo and owning team. Do not
guess validity — that is checked outside this analysis.
Spot-check 10 classifications before trusting the buckets — misclassified TEST/FAKE is the dangerous direction.
Verify liveness out-of-band. For LIVE-RISK findings, check validity via the provider (key last-used timestamps, IAM access analyzer, DB auth logs) — never by asking the AI and never by "testing" the credential from your laptop. Update the ranking with facts.
Draft per-repo remediation PRs. For each affected active repo, have the AI draft: removal of the hardcoded value, replacement with the secrets-manager reference (env var, external-secret, Vault path — per your platform's pattern), and a .gitignore/pre-commit gitleaks hook addition so the repo cannot regress. Owners review and merge; nothing auto-merges.
Write rotation runbooks per credential class. One runbook per type (AWS access key, GitHub PAT, DB password...): where it is issued, every consumer that must be updated, rotation steps in order, verification step, rollback. AI drafts from your notes; the owner executes rotation by hand and ticks each step. Rotation before history-scrub — a rotated secret in history is an artifact, an unrotated one is a breach.
Decide on history rewriting deliberately. For genuinely sensitive history (client repos, public repos), plan git filter-repo/BFG with the owning team — it rewrites hashes and breaks clones, so it is a coordinated change with its own record. For internal-only historical findings, rotation + documented acceptance is often the saner call.
Turn the sweep into a gate. Add the scanner to CI/pre-commit org-wide so the pile never rebuilds; AI drafts the pipeline snippet and the developer-facing "you just committed a secret — do this" doc.
Never paste, upload, or "check" an actual secret value with any AI tool — the workflow runs entirely on masked findings, and rotation is always a human's hands on the real console.
Scanners find, providers verify, AI drafts, humans rotate — the pipeline works because each stage refuses to do the next one's job.