Prompt
Need to detect leaked credentials in repos
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
To detect leaked credentials in repositories, use a mix of secret scanning, policy enforcement, and CI checks.
Best options
1) GitHub secret scanning
If your repos are on GitHub:
- Enable Secret Scanning
- Enable Push Protection
- Works for common tokens/API keys/passwords
- Can also detect custom patterns for your org
2) TruffleHog
Good for finding high-entropy secrets and verified credentials.
Install:
pip install trufflehog
Scan a repo:
trufflehog filesystem /path/to/repo
Or scan git history:
trufflehog git file:///path/to/repo
3) Gitleaks
Very popular for CI/CD and local scans.
Install:
brew install gitleaks
# or
docker run --rm -v "$PWD:/repo" zricethezav/gitleaks:latest detect --source /repo
Run scan:
gitleaks detect --source .
Generate baseline:
gitleaks detect --source . --report-format json --report-path report.json
4) Git-secrets
Useful for preventing secrets from being committed.
Install and configure:
git secrets --install
git secrets --register-aws
git secrets --add 'password\s*=\s*.+'
git secrets --scan
Recommended workflow
- Scan existing repos
- Use Gitleaks or TruffleHog across all repos and history
- Add pre-commit hooks
- Block secrets before commit
- Add CI scanning
- Fail builds if secrets are found
- Enable platform protections
- GitHub/GitLab secret scanning and push protection
- Rotate any exposed credentials immediately
- Assume leaked secrets are compromised
Example CI step with Gitleaks
- name: Scan for secrets
run: |
gitleaks detect --source . --exit-code 1
Helpful tips
- Scan both working tree and git history
- Add custom regex rules for internal credential formats
- Review false positives and tune rules carefully
- Never rely only on pattern matching; combine with entropy checks and validation
If you want, I can give you:
- a ready-to-run script to scan all repos in a directory,
- a GitHub Actions workflow for secret scanning, or
- a custom Gitleaks config for your org’s token formats.