How do you handle false positives in Gitleaks?

IntermediateHands-onGitleaks
Answer

Short answer

Tell Gitleaks what to ignore as narrowly as possible: an inline gitleaks:allow comment for a single line, a .gitleaksignore file listing specific finding fingerprints, or an allowlist in .gitleaks.toml for paths, regexes or known test values. Never disable whole rules just to get a green build.

Options

1. Inline (one line)

TEST_TOKEN = "ghp_exampleexampleexampleexample00"  # gitleaks:allow

2. .gitleaksignore (specific findings by fingerprint)

4f1c2a9e:tests/fixtures/sample.env:generic-api-key:3

The fingerprint is printed in the report (commit:file:rule:line).

3. Allowlist in .gitleaks.toml

[extend]
useDefault = true

[allowlist]
description = "Test fixtures and docs"
paths = ['''tests/fixtures/''', '''docs/examples/''']
regexes = ['''EXAMPLE''', '''dummy-password''']

Good practice

  • Review allowlist changes in PRs like code.
  • Prefer obviously fake test values (AKIAIOSFODNN7EXAMPLE) so they don't look real.
  • Use a baseline for old historical findings you've already rotated, so only new leaks fail the build.

What to say in the interview

"I suppress as narrowly as possible: gitleaks:allow for one line, .gitleaksignore fingerprints for specific findings, and path or regex allowlists in .gitleaks.toml for fixtures. Allowlists are code-reviewed, and a baseline covers historical findings that were already rotated."

All Security Tools questions Roadmap: Gitleaks — secret scanning

More on Gitleaks