When your secret scanner cries wolf: a reproducible false-positive triage workflow
For projects that already run a secret scanner, but whose team has started ignoring the red build. Every command and exit code below was run locally; demo credentials are random values generated at runtime and all output
For projects that already run a secret scanner, but whose team has started ignoring
the red build. Every command and exit code below was run locally; demo credentials
are random values generated at runtime and all output is redacted.
The real cost of false positives is not noise
The first week with a secret scanner is easy: a new repo, clean history, zero findings.
The second week is where it breaks. A fake AWS key in a test fixture, a random string in
a build artifact, a sample token in the docs. To keep shipping, teams usually pick one of
three shortcuts:
- ignore the whole
tests/fixtures/directory; - raise
--fail-ontohighand stop looking; - delete the scan step from CI.
All three end the same way: the next real leak also goes unnoticed. The goal of
false-positive triage is not a green report. It is making every exemption bounded,
justified, and reviewable.
The walkthrough below uses LeakPulse (MIT, zero dependencies, pip install leakpulse).
The same workflow applies to other scanners that support inline allows, path ignores,
and baselines.
Reproduce it: three kinds of findings in one repo
The demo repo has three files:
repo/
├── tests/fixtures/legacy_aws.env # synthetic fixture left over from a 2019 migration
├── src/generated/build_metadata.py # signature constant written at build time
└── docs/config-example.md # documentation placeholder
The values in the fixture and the generated file are created by a script at runtime:
python3 - <<'PY'
import secrets, string
from pathlib import Path
aws_id = "AKIA" + "".join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(16))
aws_secret = "".join(secrets.choice(string.ascii_letters + string.digits + "+/") for _ in range(40))
Path("tests/fixtures/legacy_aws.env").write_text(
f"AWS_ACCESS_KEY_ID={aws_id}\nAWS_SECRET_ACCESS_KEY={aws_secret}\n"
)
sig = "".join(secrets.choice(string.ascii_letters + string.digits + "+/=") for _ in range(48))
Path("src/generated/build_metadata.py").write_text(f'BUILD_SIGNATURE = "{sig}"\n')
PY
First scan:
$ leakpulse scan . --history 0 --fail-on high
HIGH aws-access-key-id tests/fixtures/legacy_aws.env:2 AKIA************PSQ0 AWS access key ID
MEDIUM high-entropy-string src/generated/build_metadata.py:2 Uhfl****************PfP5 High-entropy string (possible secret)
MEDIUM high-entropy-string tests/fixtures/legacy_aws.env:3 AWS_****************Y17m High-entropy string (possible secret)
3 potential secrets found (1 high, 2 medium, 0 low). Scanned 3 files in 0.01s.
$ echo $?
1
Note that ghp_your_token_here_… in docs/config-example.md is not flagged.
Placeholder filtering is the scanner's first noise filter; you do not have to exempt it
by hand.
Step 1: inventory first, gate later
Arguing about thresholds before looking at the composition of the findings is how
teams pick the wrong fix. Turn the gate off and take an inventory:
$ leakpulse scan . --history 0 --fail-on never --json | python3 -c "
import json, sys, collections
d = json.load(sys.stdin)
print('summary', d['summary'])
print('by_rule', dict(collections.Counter(f['rule'] for f in d['findings'])))
print('by_severity', dict(collections.Counter(f['severity'] for f in d['findings'])))
"
summary {'total': 3, 'high': 1, 'medium': 2, 'low': 0}
by_rule {'aws-access-key-id': 1, 'high-entropy-string': 2}
by_severity {'high': 1, 'medium': 2}
--fail-on never changes only the exit code, not the report: it always exits 0, but
every finding is still printed. That lets you answer three questions without modifying
the repo:
- Which rules produce the noise?
- Which files and directories contribute most of it?
- Which findings contain a value, and which only "look like" one?
Step 2: sort every finding into one of four buckets
| Bucket | How to tell | Correct action | Do not use |
|---|---|---|---|
| Real credential | Can authenticate or call an API; or rotation status unknown | Rotate now, then clean history | Any exemption |
| Synthetic fixture | Generated by tests, has no external rights, must stay in the repo | Inline leakpulse:allow per line, or an exact-path ignore |
Ignoring the whole test directory |
| Generated / third-party artifact | Produced by a build, content changes between builds | Exact-path ignore, or move it to a default-excluded directory | Baseline |
| Legacy, cannot fix today | Real, but rotation or migration is not immediately possible | Baseline + owner + expiry | Regenerating the baseline to silence it |
This table is the whole article. Baselines are a poor fit for generated artifacts:
their value changes on every build, so the fingerprint changes and the old baseline stops
matching. Putting them in a baseline guarantees periodic red builds, which leads straight
back to disabling the scanner.
Step 3: the blast radius of a directory-level ignore
The convenient fix is to ignore the fixture directory:
printf 'tests/fixtures/\n' > .leakpulseignore
The scan turns green. To test whether that green means anything, drop a new, perfectly
valid fake GitHub token into the same directory (simulating a real leak):
$ leakpulse scan . --history 0 --fail-on high
MEDIUM high-entropy-string src/generated/build_metadata.py:2 Uhfl****************PfP5 High-entropy string (possible secret)
1 potential secret found (0 high, 1 medium, 0 low). Scanned 5 files in 0.00s.
$ echo $?
0
The new file is counted in "Scanned 5 files" and still produces zero findings. Exit code
0.
That is the real cost of a directory-level exemption: it covers every file added in the
future. A fixture directory is not a read-only archive; it receives new test data every
week. Two historical false positives are silenced today, and a production token can walk
through tomorrow.
Use directory ignores only when the entire tree should never be scanned: vendored
dependencies, minified bundles, generated SDKs. Test fixtures do not qualify.
Step 4: inline allows have the right granularity
LeakPulse supports an inline annotation:
AWS_ACCESS_KEY_ID=AKIA… # leakpulse:allow: synthetic fixture, revoked, owner=qa
AWS_SECRET_ACCESS_KEY=… # leakpulse:allow: synthetic fixture, revoked, owner=qa
leakpulse:allow applies to the entire line: any line containing the marker is
skipped. Scan again:
$ leakpulse scan . --history 0 --fail-on high
HIGH github-token tests/fixtures/leaked_prod.env:1 ghp_****************Bjcj GitHub token (classic app/OAuth/refresh)
MEDIUM high-entropy-string src/generated/build_metadata.py:2 Uhfl****************PfP5 High-entropy string (possible secret)
2 potential secrets found (1 high, 1 medium, 0 low). Scanned 4 files in 0.00s.
$ echo $?
1
The newly added leaked_prod.env in the same directory is still caught, and the exit code
is 1. The two historical fixture findings are exempted precisely; the new leak is not
carried along by the exemption.
Three limits you need to know:
-
It only works in formats that support comments.
.env, YAML, shell, and Python are fine. Strict JSON is not; adding#breaks parsing. Use an exact-path ignore or a baseline instead. - It skips the whole line. Never put a real credential and the allow marker on the same line, or a second secret on that line disappears with it.
-
It has no expiry. That is why the marker must carry
owner=and a reason, with code review and periodic audits as the backstop.
Step 5: a baseline is a rotation backlog, not a mute button
Inline allows fit findings you have confirmed are synthetic. When you cannot confirm that
a fixture value is dead, or it already exists in git history, a baseline is the better
alternative: acknowledge it, then queue rotation by blast radius. Take a snapshot first:
$ leakpulse scan . --history 0 --fail-on medium --write-baseline .leakpulse-baseline.json
leakpulse: recorded 3 fingerprint(s) in .leakpulse-baseline.json
$ echo $?
0
(The three printed findings are omitted here for brevity; taking a snapshot never hides
the report.) The file contains fingerprints only — no secrets, not even redacted fragments:
{
"schema": "leakpulse-baseline/1",
"tool": "leakpulse 0.5.1",
"count": 3,
"fingerprints": [
"b2070e9f17a00ac221c5",
"b63412ab3b7e36de2094",
"bd8f880e0c1b50c8dae6"
]
}
Scanning with the baseline restores exit 0, while the report still states how many
findings were suppressed:
$ leakpulse scan . --history 0 --fail-on medium --baseline .leakpulse-baseline.json
No potential secrets found. Scanned 4 files in 0.00s. 3 known findings suppressed by baseline.
$ echo $?
0
Prove that it does not mute new findings:
$ leakpulse scan . --history 0 --fail-on medium --baseline .leakpulse-baseline.json
HIGH github-token tests/fixtures/leaked_prod.env:1 ghp_****************MMwK GitHub token
1 potential secret found (1 high, 0 medium, 0 low). Scanned 5 files in 0.01s. 3 known findings suppressed by baseline.
$ echo $?
1
Two pitfalls deserve their own lines in the team runbook:
Pitfall 1: fingerprints ignore line numbers, so moving code does not resurrect old
findings. Adding two comment lines at the top of the fixture still yields
3 known findings suppressed and exit 0. That is intentional: unrelated edits should
not cause repeated red builds.
Pitfall 2: fingerprints include the matched value, so a regenerated artifact comes
back. After changing BUILD_SIGNATURE:
$ leakpulse scan . --history 0 --fail-on medium --baseline .leakpulse-baseline.json
MEDIUM high-entropy-string src/generated/build_metadata.py:3 ekuF****************ZY/+ High-entropy string (possible secret)
1 potential secret found (0 high, 1 medium, 0 low). Scanned 4 files in 0.01s. 2 known findings suppressed by baseline.
$ echo $?
1
That is the evidence for "do not baseline generated artifacts". Move the generated
directory out of scope, or ignore the exact file:
# .leakpulseignore — exact file, no directory glob
src/generated/build_metadata.py
New files added under src/generated/ in the future are still scanned.
Raising --fail-on is not the answer
The default gate fails only on high, which does suppress the two medium findings
above. It also lets real medium-severity leaks through. Put a password assignment in a
file of its own:
$ leakpulse scan . --history 0 --fail-on high
MEDIUM generic-secret-assignment settings.py:1 gJe_****************Eheo Secret-like value assigned to a sensitive name
1 potential secret found (0 high, 1 medium, 0 low). Scanned 1 file in 0.00s.
$ echo $?
0
There is a finding in the report and a green build. Switch to --fail-on medium:
$ echo $?
1
generic-secret-assignment covers password, api_key, access_token, and similar
names. It is the main exit path for database passwords and internal service tokens.
Excluding it from the gate permanently means you only guard the most obvious category.
The safe order is: triage the noise first, then consider tightening the gate. Once
each finding has a bucket, keeping --fail-on medium is sustainable. Doing it the other
way around hides real medium-severity leaks along with the noise.
Team policy: make every exemption reviewable
-
Every exemption carries a reason and an owner:
# leakpulse:allow: synthetic fixture, owner=qa, review=2026-Q1. - Prefer inline allows; reserve path ignores for trees that should never be scanned, and pin them to exact files or known suffixes.
-
Never ignore a directory that receives new files, such as
tests/,fixtures/,examples/, orconfig/. -
The baseline count must trend down. Treat
countas the length of the rotation backlog and report the trend weekly. A count that only grows means the baseline became a mute button. - Never baseline generated artifacts. Use an exact-path ignore or a build-directory convention instead.
- Every new exemption gets one sentence in the PR description, so a reviewer has a chance to object.
- Audit everything quarterly: remove stale exemptions, regenerate the baseline, and check that no directory globs crept back in.
Acceptance checklist
Before wiring the scanner into CI, confirm the behavior with this sequence:
# 1. Inventory (always exits 0, report is still complete)
leakpulse scan . --history 0 --fail-on never --json > /tmp/leak-inventory.json
# 2. Strict gate (expected: 0 on a clean repo, 1 on a new leak)
leakpulse scan . --history 0 --fail-on medium
# 3. Baseline suppresses only known findings (expected: 0 with no additions, 1 with one)
leakpulse scan . --history 0 --fail-on medium --baseline .leakpulse-baseline.json
# 4. Confirm that exemptions do not cover new files
git status --short && leakpulse scan . --history 0 --fail-on medium
If step 4 is still green right after adding a new fixture, check whether
.leakpulseignore contains a directory glob.
Closing
False-positive triage is not about turning the report green. It is about giving every
finding an explainable destination: real leaks get rotated, synthetic data gets an
inline allow, generated artifacts get an exact-path ignore, and legacy findings get a
baseline. Each path has boundaries; mixing them recreates the "the scanner is noisy, turn
it off" loop.
LeakPulse remains MIT-licensed, zero-dependency, and local-only. pip install leakpulse
reproduces every command above. If you would rather not build the process yourself,
StackPulse Lab offers a fixed-scope "CI secret gate + scheduled-job health check" package;
the self-service quickcheck is free:
https://github.com/stackpulse-lab/stackpulse-lab/tree/main/offers/ci-secrets-cron-health.
Related reading:
- The first 10 minutes after a secret leak: rotation, forensics, and blast-radius assessment.
- Adopting a secret scanner in a legacy repo: the full baseline adoption sequence.
- Online Cron/systemd checker and heartbeat monitoring: https://hook.kogasa.xyz
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.