CLI tool to detect hardcoded secrets and API keys before they leak to git
Project description
SecretGuard 🔐
Stop leaking API keys before they cost you.
In 2025, 28.6 million hardcoded secrets were exposed on GitHub — a 34% YoY increase. AI coding assistants make it 2× worse. SecretGuard blocks secrets at commit time.
$ secretguard scan .
config/settings.py:12
Rule : [OAI001] OpenAI API Key (legacy)
Severity : 🔴 CRITICAL
Match : sk-aB************lmn
Line : OPENAI_API_KEY = "sk-aBcDe..."
Found 1 secret(s) in 43 file(s) scanned
1 CRITICAL
Install
pip install secretguard
Usage
# Scan current directory
secretguard scan .
# Scan specific file
secretguard scan src/config.py
# Git pre-commit hook (blocks commits with CRITICAL secrets)
secretguard install
# JSON output (CI/CD integration)
secretguard scan . --format json
# HTML report
secretguard scan . --format html --output report.html
# Only fail on HIGH or above
secretguard scan . --fail-on high
# List all 50+ detection rules
secretguard list-rules
What it detects
50+ patterns across all major providers:
| Provider | Rules |
|---|---|
| AWS | Access Key ID, Secret Access Key, MWS Key |
| OpenAI | Legacy key, Project key, Service account |
| Anthropic/Claude | API Key |
| GitHub | PAT (classic + fine-grained), OAuth, Actions tokens |
| Stripe | Live/test secret keys, restricted keys, webhook secrets |
| Slack | Bot token, user token, app token, webhook URL |
| API Key, OAuth token | |
| HuggingFace | API Token |
| SendGrid | API Key |
| Azure | Storage connection string, subscription key |
| Private keys | RSA, OpenSSH, EC, PGP |
| Generic | API key assignments, hardcoded passwords, DB URLs with creds |
| + more | Replicate, DeepSeek, Twilio, Mailgun, npm, Docker Hub, Firebase, Telegram, Supabase |
Git pre-commit hook
# Install (one-time per repo)
secretguard install
# Now every git commit is checked automatically:
# git commit -m "feat: add payment"
# → SecretGuard scans staged files
# → Blocks commit if CRITICAL secrets found
# → Shows exactly where secrets are
# Remove
secretguard uninstall
pre-commit framework
Add to .pre-commit-config.yaml:
repos:
- repo: https://github.com/your-handle/secretguard
rev: v0.1.0
hooks:
- id: secretguard
CI/CD integration
# GitHub Actions
- name: Scan for secrets
run: |
pip install secretguard
secretguard scan . --format json --fail-on high
Options
| Flag | Default | Description |
|---|---|---|
--staged |
false | Scan only git staged files |
--format |
terminal | Output: terminal, json, html |
--output |
— | Output file (for --format html) |
--fail-on |
critical | Exit 1 when: critical, high, medium, low, any, none |
--no-color |
false | Disable ANSI colors |
Why not GitGuardian or GitHub Advanced Security?
- GitGuardian: Enterprise pricing ($$$), sends your code to their servers
- GitHub Advanced Security: Enterprise plans only (~$49/seat/month)
- SecretGuard: Free, open source, fully local — your code never leaves your machine
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secretguard-0.1.0.tar.gz.
File metadata
- Download URL: secretguard-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
469cb12521f9218dd69f7009d2f60be2a9cbb2f5905e516527301bdc433d0b07
|
|
| MD5 |
59d438e38b9b04f8e2ac7ff2501ede24
|
|
| BLAKE2b-256 |
871741ea41df5b3d68ced02516e04a8c5d510c9630b848509eac4596ca8aa307
|
File details
Details for the file secretguard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: secretguard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700b31a207c83d113fdded9b23e5cd59154ba25e57578039b9ab7d0f8b27aca4
|
|
| MD5 |
45bf8d63178f0a8a18c62e8c265de742
|
|
| BLAKE2b-256 |
f733b2f2c0205716d1b55a2e58513b8bd559528023873f28a859d3b9df86920a
|