What is Gitleaks?
Short answer
Gitleaks is an open-source tool that scans Git repositories, files and commits for secrets — API keys, tokens, passwords, private keys — using regex rules and entropy checks. It runs on developer laptops (pre-commit), in CI pipelines and against full Git history.
What it detects (examples)
AWS access keys, GitHub/GitLab tokens, Slack webhooks, Stripe keys, Google API keys, private keys (-----BEGIN RSA PRIVATE KEY-----), JWTs, generic high-entropy passwords — 150+ built-in rules.
Quick start
brew install gitleaks # or download the binary / use the Docker image
gitleaks git . # scan the repo's full commit history (v8.19+)
gitleaks dir . # scan files in the current folder (no history)
gitleaks git --staged . # wait — use 'protect' style: scan only staged changes
docker run --rm -v $(pwd):/repo zricethezav/gitleaks:latest git /repo
(Older v8 versions use gitleaks detect for history and gitleaks protect --staged for staged changes — both are still widely seen in pipelines.)
Output
Finding: aws_secret_access_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
Secret: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
RuleID: aws-secret-access-key
File: config/settings.py
Line: 12
Commit: 4f1c2a9...
Author: [email protected]
Exit code 1 when leaks are found — perfect for failing a pipeline.
What to say in the interview
"Gitleaks scans repos, files and history for secrets using regex and entropy rules. We run it as a pre-commit hook and as a required CI check, where a non-zero exit fails the build."