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
- Run a full history scan.
- Triage every finding — rotate real secrets, mark false positives.
- Save the baseline and commit it.
- CI enforces "no new secrets" from now on.
- 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."
More on Gitleaks
What is Gitleaks and how do you use it?BeginnerWhat is a secret leak and why is it dangerous?BeginnerWhat is Gitleaks?BeginnerHow do you scan a repository's full history with Gitleaks and create a report?BeginnerHow do you stop secrets before they're committed using a pre-commit hook?BeginnerHow do you run Gitleaks in a CI pipeline and fail the build on findings?Beginner