๐ Secure Your Codebase: Discover Exposed Secrets Instantly with Secret-Hunter

Accidentally pushed an API key to GitHub? You're not alone โ and you're not safe.
Whether it's an OpenAI token, AWS credentials, or a database password, secrets can slip into your codebase faster than you realize. One leaked key can lead to:
๐จ Compromised systems
๐ธ Unexpected cloud bills
๐ Major security incidents
That's why I built secret-hunter
โ a zero-config, lightning-fast CLI tool to scan your code for exposed secrets before they go public.
๐ What Is secret-hunter
?
secret-hunter
is a developer-friendly command-line tool that finds:
API Keys: OpenAI, Google, GitHub, Stripe, Slack, Discord, Twitter
Cloud credentials: AWS access keys, Azure tokens, Google Cloud keys
Database URLs: MongoDB, PostgreSQL, MySQL, Redis connection strings
Private keys: SSH keys, RSA keys, JWT secrets
Authentication tokens: OAuth tokens, Bearer tokens, webhook secrets
The tool scans your entire codebase in seconds and tells you exactly where potential secrets are hiding.
๐ง Why I Built This
Most existing tools are either:
Too slow โ taking minutes to scan what should take seconds
Hard to configure โ requiring complex YAML files and setup
Built only for CI/CD โ designed for pipelines, not everyday development
Enterprise-focused โ built for large teams, not individual developers
I wanted something simple. Something you could run in 5 seconds before every commit. Something that just works without reading documentation.
โก Features That Actually Matter
Zero Configuration
npx secret-hunter
No config files. No setup. No reading docs. Just run it and get results immediately.
Lightning Fast Performance
โก Scans thousands of files in seconds โ not minutes like other tools
๐ Smart ignores โ automatically skips
node_modules
,.git
,dist
,.next
,build
, and other irrelevant directories๐ฏ Optimized patterns โ uses efficient matching without false positives
๐ Recursive scanning โ goes through your entire project structure
Comprehensive Secret Detection
The tool recognizes over 20 different types of secrets:
API Keys & Tokens:
OpenAI API keys (
sk-...
)Google API keys (
AIza...
)GitHub tokens (
ghp_...
,gho_...
)Stripe keys (
sk_live_...
,pk_live_...
)Slack tokens (
xoxb-...
,xoxp-...
)Discord bot tokens
Twitter API keys
Cloud Provider Credentials:
AWS access keys (
AKIA...
)Azure subscription keys
Google Cloud service account keys
DigitalOcean tokens
Database Connections:
MongoDB connection strings (
mongodb://...
)PostgreSQL URLs (
postgresql://...
)MySQL connection strings
Redis URLs (
redis://...
)
Private Keys:
SSH private keys (
-----BEGIN OPENSSH PRIVATE KEY-----
)RSA private keys (
-----BEGIN RSA PRIVATE KEY-----
)JWT secrets
Generic private keys
Developer-Friendly Output
๐ Starting secret scan...
Collecting files...
Found 3 files to scan
Scanning for secrets...
Progress: 3/3 files
๐ SECRET SCANNER REPORT
==================================================
๐ SCAN SUMMARY
------------------------------
๐ Total files scanned: 3
๐จ Total secrets found: 1
๐ Files with secrets: 1
๐ Secret types found: 1
๐จ DETAILED FINDINGS
------------------------------
๐ File 1: D:\All data\test\index.js
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1. API Key Pattern
Line: 4
Code: const apiKey="AIzaSyA-FAKEKEY1234567890abcdefgHIJKL"
๐ก RECOMMENDATIONS
------------------------------
1. Remove hardcoded secrets from your code
2. Use environment variables (.env files)
3. Add .env to your .gitignore
4. Use secret management tools for production
==================================================
๐ Scan completed successfully!
Color-coded, clean, and actionable. You know exactly what to fix and where to find it.
๐ฅ Real-World Use Cases
1. Pre-Commit Safety Check
# Your new workflow
git add .
npx secret-hunter
# Only commit if no secrets found
git commit -m "Clean commit"
2. Code Review Process
Before approving any pull request, run secret-hunter
to catch secrets that might have slipped through manual review.
3. Project Auditing
Just inherited a legacy codebase? Run secret-hunter
to see what secrets might be lurking in the code.
4. Team Onboarding
Perfect for showing new developers what secrets look like and how to avoid committing them.
5. Open Source Preparation
Before making your private repo public, scan it to ensure no internal secrets are exposed.
๐ How It Compares to Alternatives
Tool | Setup Required | Speed | Primary Use Case |
gitleaks | Medium (TOML config) | Medium | Git history scanning |
truffleHog | Heavy setup | Slow | Deep forensic analysis |
detect-secrets | Medium config | Medium | Pre-commit hooks |
secret-hunter | None | Fast | Daily development |
Why Choose secret-hunter
?
For gitleaks
users: If you want something that works without writing config files and focuses on current code, not git history.
For truffleHog
users: If you need speed over deep analysis and want to scan before commits, not after.
For detect-secrets
users: If you want zero setup and don't need Python-specific features.
๐ก The Philosophy Behind It
I built this tool with one principle: Security shouldn't slow you down.
Most developers don't need enterprise-grade secret management. They need something that:
Works immediately without setup
Fits into their existing workflow
Catches problems before they become disasters
Doesn't require learning new tools
๐งช Installation & Usage
Quick Start
# Run once without installing
npx secret-hunter
# Install globally for repeated use
npm install -g secret-hunter
secret-hunter
Command Line Options
# Scan specific directory
secret-hunter /path/to/project
# Scan current directory (default)
secret-hunter .
# Get help
secret-hunter --help
Integration Examples
Pre-commit hook:
{
"husky": {
"hooks": {
"pre-commit": "secret-hunter"
}
}
}
Package.json script:
{
"scripts": {
"security-check": "secret-hunter",
"pre-commit": "secret-hunter && git add ."
}
}
๐ What's Coming Next
Based on user feedback, here's what's planned:
โ JSON output format for CI/CD pipeline integration
โ Custom ignore patterns for project-specific needs
โ Configurable sensitivity levels
โ Git hook integration for automatic scanning
โ Plugin system for custom secret patterns
โ Directory-specific scanning for large monorepos
๐ Try It Right Now
Want to see if your current project has any exposed secrets?
npx secret-hunter
Most projects scan in under 10 seconds.
๐ Performance Benchmarks
Here's how secret-hunter
performs on different project sizes:
Small project (< 100 files): ~1-2 seconds
Medium project (100-1000 files): ~3-5 seconds
Large project (1000+ files): ~8-15 seconds
Tested on MacBook Pro M1, results may vary based on your system.
๐ ๏ธ Technical Details
What It Scans
All text files in your project
Common code file extensions (.js, .ts, .py, .go, .rb, .php, etc.)
Configuration files (.env, .yml, .json, .xml)
Documentation files (.md, .txt)
What It Ignores
Binary files
node_modules
directories.git
directoriesBuild output folders (
dist
,build
,.next
)Cache directories
Log files
Detection Method
Uses pattern matching with carefully crafted regular expressions that balance accuracy with performance. No false positives from comments or documentation.
๐ค Contributing
Found a bug? Want to add support for a new secret type? Contributions are welcome!
Easy ways to contribute:
Report bugs or suggest features on GitHub
Add new secret patterns
Improve documentation
Share the tool with other developers
๐งก Final Thoughts
Every developer will accidentally expose a secret at some point. The question isn't "if" โ it's "when."
secret-hunter
exists to be your safety net. It's the tool that runs quickly in the background, catching mistakes before they become problems.
I built this because I needed it. If it helps even one developer avoid a security incident, it's accomplished its purpose.
๐ Get Started
๐ Links:
๐ฆ npm package
If you find secret-hunter
helpful:
โญ Star the repo to help others discover it
๐ Report issues to help improve it
๐ Contribute โ PRs are always welcome
๐ข Share with your team
Let's build more secure code, one scan at a time.
Built by Anurag Singh ๐จโ๐ป
Making developer security simple, one tool at a time.
Subscribe to my newsletter
Read articles from Anurag Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
