api-key-guardian
v1.0.13
Published
Prevents accidental exposure of API keys in commits
Maintainers
Readme
API Key Guardian
Prevents accidental exposure of API keys and secrets in your codebase by scanning files and blocking commits/pushes if secrets are found.
Features
- Detects API keys, secrets, tokens, and database URIs in your project
- Blocks git commits and pushes if secrets are found
- Supports custom patterns and ignore rules
- Fast scanning, even for large projects
Installation
Install globally (recommended):
npm install -g api-key-guardianOr use with npx (no install needed):
npx api-key-guardian --scan-allUsage
Scan the entire project
npx api-key-guardian --scan-allScan specific files or folders
npx api-key-guardian src/config.js
npx api-key-guardian src/Install git hooks (pre-commit & pre-push)
npx api-key-guardian --install-hooks
# or
npm run install-hooksThis will block commits and pushes if secrets are detected.
Show current configuration
npx api-key-guardian --configShow help
npx api-key-guardian --helpConfiguration
Create a .apiguardian.json file in your project root to customize ignored files, extensions, and patterns:
{
"ignoredFiles": [
".git/",
"node_modules/",
"dist/",
"build/",
".next/",
".env.example",
"*.log"
],
"ignoredExtensions": [
".jpg", ".png", ".gif", ".pdf", ".zip", ".tar.gz"
],
"customPatterns": [
{
"name": "Custom API Key",
"pattern": "/custom_api_key_[a-zA-Z0-9]{32}/",
"severity": "high"
}
]
}Example Output
License
MIT
