A context-aware DevSecOps tool to audit and prevent secrets leakage in local Git repositories.
Project description
DevGuard 🛡️
Stop credentials from reaching GitHub. Catch them on your machine first.
DevGuard is a CLI tool that scans your code for leaked API keys, passwords, and tokens — and blocks the git push if it finds any.
How DevGuard compares
| Feature | gitleaks | detect-secrets | DevGuard |
|---|---|---|---|
| Regex-based detection | ✅ | ✅ | ✅ |
| Shannon entropy analysis | ✅ | ✅ | ✅ |
| Detects secrets in dicts, f-strings, comments | ⚠️ partial | ⚠️ partial | ✅ |
Detects secrets in .env format |
✅ | ✅ | ✅ |
| False positive filter (commit SHAs, placeholders) | ⚠️ partial | ⚠️ partial | ✅ |
| Pre-push git hook | ✅ | ❌ | ✅ |
| Pre-commit scan (warns before you even commit) | ❌ | ❌ | ✅ |
| Line-preserving ignore list | ❌ | ❌ | ✅ |
| Two-tier audit trail (private log + committed report) | ❌ | ❌ | ✅ |
| Enterprise-overridable entropy threshold via config | ❌ | ❌ | ✅ |
| Custom org-specific regex patterns via config | ✅ | ✅ | ✅ |
What those last three mean in practice
Pre-commit scanning — most tools only block at git push, which means you write code, stage it, commit it, then get told it's bad. DevGuard warns you during devguard scan before you commit anything, so you fix it at the source, not after the fact.
Line-preserving ignore list — when you mark a string as safe, most tools regenerate the entire config file and silently destroy every comment and custom indent a senior wrote into it. DevGuard rewrites only the one relevant line, leaving everything else byte-identical.
Two-tier audit trail — a private audit.log (never committed) stores full details per device. A sanitized audit.report gets committed to the repo so team leads can see who almost leaked what, without the secret value ever touching version control.
Install
pip install devguard-cli
Quickstart
# 1. Set up DevGuard inside your repo (one time)
devguard init
# 2. Scan manually anytime
devguard scan
# 3. Scan a specific targeted file or subdirectory
devguard scan "file path"
# 3. Filter by severity
devguard scan --severity HIGH
# 5. Mark a false positive as safe (by its hash)
devguard ignore 9b55a56a4e3208b8
# 6. Check hook + config status
devguard status
After devguard init, every git push is automatically scanned. If a secret is found, the push is blocked entirely. Clean code goes through untouched.
What gets detected
| Format | Method |
|---|---|
| AWS Access Key ID / Secret | Regex + entropy + context |
| Google API Key | Regex |
| JSON Web Token (JWT) | Regex |
| RSA / Private Key blocks | Regex |
| Slack Webhook URLs | Regex |
| Stripe Secret Keys | Regex |
| Custom org tokens | Regex via .devguard.yml |
| Unknown high-randomness strings | Shannon entropy analysis |
Configuration
Running devguard init creates .devguard.yml in your repo root. Commit this — it's safe, it contains no secrets.
Every field is optional. DevGuard ships with sensible defaults; your config only needs to list what you want to override.
# Override the default entropy threshold (default: 3.8)
# Lower = more sensitive, catches more strings but may increase false positives
# Enterprise teams with stricter standards can set this as low as 3.0
entropy_threshold: 3.5
# Add org-specific secret formats that no public tool would know about
custom_patterns:
- name: "Internal API token"
regex: "MYCOMPANY_[A-Z0-9]{32}"
- name: "Legacy auth header"
regex: "Bearer legacy_[a-z0-9]{24}"
# Files that should never be pushed, regardless of content
blacklisted_files:
- "*.env"
- "secrets.json"
- "**/credentials/*.yml"
# Safe strings, stored as hashes — never paste the actual value here
allowlist:
- "9b55a56a4e3208b8" # confirmed safe: internal build token
The allowlist stores hashes of ignored strings, not the strings themselves. Safe to commit publicly, safe to code review.
Audit trail
Every scan appends to two files:
.devguard/
├── audit.log # full detail, in .gitignore, never leaves your machine
└── audit.report # sanitized, committed to repo, safe for team review
audit.report shows who, when, which file, which pattern — with no secret values or line numbers included.
How the detection works
Layer 1 — Regex: Matches known secret formats by their structural shape, anywhere on a line, regardless of surrounding syntax. A key inside a dict, a comment, or an f-string is caught the same as a clean assignment.
Layer 2 — Shannon Entropy: Measures how random a string actually is. Real secrets (machine-generated) score high. Placeholders, UUIDs, and commit hashes score low and are ignored. Combined with proximity checking (does the word aws, secret, or key appear nearby?) to eliminate false positives.
Development
git clone https://github.com/reva-32/test_cybersecurity
pip install -e .
pytest tests/ -v
License
MIT — free to use, modify, and distribute, including in commercial projects. Just keep the copyright notice.
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 devguard_cli-1.0.0.tar.gz.
File metadata
- Download URL: devguard_cli-1.0.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52b7b2f99350c21b5d0c172d5dd5db79ee0fe8d717b249358923735ece6f00a2
|
|
| MD5 |
a603073a74c9f98d48697e1097a59e59
|
|
| BLAKE2b-256 |
d1c92224d7fa088edf3ca1f2246e14b83bc5e63fbfbc3d93bf456403157f56f2
|
File details
Details for the file devguard_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: devguard_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60415642dfb362b8e297a4591cf4771e086591b58f462e16d6f2269584051ffb
|
|
| MD5 |
40386e89171c3c0c5c9936b385e4ac04
|
|
| BLAKE2b-256 |
4f2a69d8673fdf1d78e96471d5fc33c84bd4675fc77a80dea4d14d468f40dbc6
|