secret-sweep
v1.0.0
Published
๐ Scan your entire git history for accidentally committed secrets. Rotate, fix, and prevent credential exposure.
Maintainers
Readme
๐ secret-sweep
Scan your entire git history for accidentally committed secrets. Find, report, and rotate leaked credentials โ before attackers do.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ ๐ secret-sweep โ Secret Scanner โ
โ Protect your git history โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Repository: /home/user/my-project
Branch: main
Risk Level: โโ CRITICAL RISK โโ
Commits scanned: 1,247
Files scanned: 3,891
Scan duration: 4.2s
Secrets Found
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ด CRITICAL (rotate NOW) 3
๐ HIGH (rotate today) 7
๐ก MEDIUM (investigate) 2
โช LOW (review) 1
Currently in HEAD: โโ 3 โ ๏ธ
History only: 10The Problem
You pushed .env to GitHub three months ago. You deleted it in the next commit. But it's still in git history โ readable by anyone who clones your repo.
Every secret that was ever committed to git is still there. secret-sweep finds them all.
Features
๐ Deep History Scan
Walks your entire git commit history โ not just the current files. Finds secrets in deleted files, reverted commits, old branches, everything.
๐ฏ 60+ Secret Patterns
Detects credentials across every major platform:
| Platform | Secrets Detected | |---|---| | โ๏ธ AWS | Access Key ID, Secret Key, Session Token | | ๐ต GCP | API Keys, Service Account JSON, OAuth Secrets | | ๐ท Azure | Storage Keys, Client Secrets, Connection Strings | | ๐ GitHub | PATs (classic + fine-grained), OAuth Tokens | | ๐ณ Stripe | Secret Keys, Publishable Keys, Webhook Secrets | | ๐ค OpenAI | API Keys (all formats) | | ๐ง Anthropic | Claude API Keys | | ๐ฌ Slack | Bot Tokens, User Tokens, Webhooks | | ๐ฎ Discord | Bot Tokens, Webhook URLs | | ๐ฑ Twilio | Account SIDs, Auth Tokens | | ๐ง SendGrid | API Keys | | ๐ฅ Firebase | API Keys, Admin SDK Keys | | ๐๏ธ Databases | PostgreSQL, MySQL, MongoDB, Redis connection strings | | ๐ SSH/TLS | Private Keys (RSA, EC, DSA, OpenSSH), PGP Keys | | ๐ซ JWT | Secrets, Live Tokens | | ๐ฆ NPM | Access Tokens, .npmrc auth tokens | | + more | Vercel, Netlify, Heroku, Cloudflare, Shopify, Datadog... |
๐ฆ Severity Classification
Every finding is rated CRITICAL / HIGH / MEDIUM / LOW based on the potential blast radius.
CRITICAL AWS Access Keys, Stripe Live Keys, Private SSH Keys
HIGH GitHub PATs, Slack Tokens, DB Connection Strings
MEDIUM Webhooks, JWT Tokens, Generic API Keys
LOW Publishable Keys, Low-confidence Matches๐ Exact Rotation Instructions
Every finding includes:
- Direct link to the credentials page for that service
- Step-by-step instructions for rotating the specific credential
- Priority ordering โ CRITICAL secrets first
๐ Multi-Format Reports
- Console: Beautiful color-coded terminal output
- HTML: Shareable visual report for your team
- JSON: Machine-readable for automation and SIEM integration
๐ช Pre-commit Hook
Block secrets from being committed in the first place:
secret-sweep install-hook๐คซ Allowlist Support
Mark known false positives in .guardianignore to keep scans clean:
[
{
"patternId": "generic-secret",
"filePath": "tests/fixtures/",
"reason": "Test fixtures contain fake secrets"
}
]Quick Start
Install
npm install -g secret-sweepScan your repo
# Full git history scan (recommended)
secret-sweep scan
# Scan a specific repo
secret-sweep scan /path/to/your/repo
# Quick scan of current files only
secret-sweep checkExample output
โ LIVE IN HEAD ยท a3f91bc ยท 2024-11-14
File: config/database.yml
Commit: Add production database config
CRITICAL AWS Access Key ID
Line 12: aws_access_key_id: AKIA...MPLE (12 chars)
Value: AKIA...MPLE
Confidence: 99%
Rotate at: https://console.aws.amazon.com/iam/home#/security_credentials
Action: Go to IAM โ Security Credentials โ Deactivate key โ Create new key
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโCLI Reference
secret-sweep [command] [options]
Commands:
scan [path] Full git history scan (default: current directory)
check [path] Quick scan of current files only
install-hook Install pre-commit git hook
init-ignore Create .guardianignore allowlist file
patterns List all 60+ detectable secret patterns
Options (scan):
-b, --branch <branch> Branch to scan (default: current)
--since <commit> Scan commits after this hash
--max-commits <n> Limit number of commits scanned
--min-severity <level> LOW | MEDIUM | HIGH | CRITICAL (default: LOW)
--include <patterns> Only scan matching file paths
--exclude <patterns> Skip matching file paths
--format <formats> console,json,html (default: console)
--output-dir <dir> Report output directory
--ci Exit code 1 if secrets found (for CI pipelines)
-q, --quiet Summary only, no detailed findings
--allowlist <file> Custom allowlist fileCI Integration
# GitHub Actions
- name: Scan for secrets
run: npx secret-sweep scan --ci --min-severity HIGH# GitLab CI
secret-sweep scan --ci --format console,json --output-dir reports/Pre-commit Hook
secret-sweep install-hook
# Now secrets are blocked before every commitHow It Works
git log (full history)
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Git Walker โ โ iterates every commit, every changed file
โ (git diff-tree)โ
โโโโโโโโโโฌโโโโโโโโโ
โ file content at each commit
โผ
โโโโโโโโโโโโโโโโโโโ
โ Pattern Engine โ โ 60+ regex patterns with confidence scoring
โ (60+ patterns) โ
โโโโโโโโโโฌโโโโโโโโโ
โ raw matches
โผ
โโโโโโโโโโโโโโโโโโโ
โ Filter Layer โ โ false positive removal, allowlist, dedup
โ (confidence + โ
โ allowlist) โ
โโโโโโโโโโฌโโโโโโโโโ
โ verified findings
โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Risk Engine โโโโโโถโ Console โ โ HTML โ
โ (severity, โ โ Report โ โ Report โ
โ rotation, โโโโโโถโ โ โ โ
โ recs) โ โโโโโโโโโโโโ โโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโ
โ
โผ
JSON / SARIFComparison
| Tool | History Scan | 60+ Patterns | Rotation Guide | HTML Report | Pre-commit Hook | Free | |---|:---:|:---:|:---:|:---:|:---:|:---:| | secret-sweep | โ | โ | โ | โ | โ | โ | | GitHub Secret Scanning | โ | โ | โ | โ | โ | โ ๏ธ Teams+ | | truffleHog | โ | โ | โ | โ | โ | โ | | gitleaks | โ | โ | โ | โ | โ | โ | | detect-secrets | โ | โ | โ | โ | โ | โ |
secret-sweep's edge: Rotation instructions + HTML reports + zero configuration needed.
FAQ
Does it send my code anywhere? No. secret-sweep runs entirely locally. No network calls, no telemetry, no SaaS.
Will it slow down my team's workflow? The pre-commit hook only scans changed files โ typically under 0.5s per commit.
What about .env.example files?
secret-sweep detects placeholder-looking values and reduces their confidence score. You can also allowlist entire paths in .guardianignore.
How do I purge a secret from git history?
secret-sweep will tell you exactly which commits are affected. Use git-filter-repo to rewrite history:
pip install git-filter-repo
git-filter-repo --invert-paths --path .env
git push --force-with-leaseContributing
git clone https://github.com/SergiuPogor/secret-sweep.git
cd secret-sweep
npm install
npm run devPRs welcome โ especially new patterns! Add them to src/scanner/patterns.ts with a test.
License
MIT ยฉ 2026 Sergiu Pogor
Found a secret in your history? Star the repo after you rotate it. ๐
