What is a Gitleaks baseline and when do you use it?

IntermediateConceptGitleaks
Answer

Short answer

A baseline is a saved report of existing, known findings. When you scan with --baseline-path, Gitleaks reports only new findings that aren't in the baseline. It's how you introduce Gitleaks into an old repository with historical leaks without failing every build on day one.

Example

# 1. One-time: record current findings (after rotating anything real!)
gitleaks git . --report-format json --report-path gitleaks-baseline.json --exit-code 0

# 2. In CI: fail only on NEW leaks
gitleaks git . --baseline-path gitleaks-baseline.json --redact -v

Process

  1. Run a full history scan.
  2. Triage every finding — rotate real secrets, mark false positives.
  3. Save the baseline and commit it.
  4. CI enforces "no new secrets" from now on.
  5. Burn down the baseline over time.

Danger

A baseline is not an excuse — anything real in it must already be rotated, otherwise you've just hidden a live leak.

What to say in the interview

"A baseline records known findings so CI only fails on new ones. It's how we roll Gitleaks out on legacy repos, after first triaging and rotating everything real in the historical results."

All Security Tools questions Roadmap: Gitleaks — secret scanning

More on Gitleaks