CredLock ๐
Prevent accidental credential commits to Git
CredLock is an automatic secret detection tool that scans your code before pushing to GitHub. It detects 50+ types of secrets (API keys, passwords, tokens, private keys) and blocks commits if sensitive data is found.
๐ฏ Features
- โ 50+ Detection Patterns: Detects AWS keys, API tokens, passwords, database URLs, private keys, JWT tokens, and more
- โ Automatic Git Integration: Pre-commit hook runs automatically before every push
- โ Zero Configuration: Works out of the box, no complex setup
- โ Beautiful Terminal Output: Color-coded, formatted scan results
- โ Scan History: Tracks all scans locally in JSON format
- โ Custom Patterns: Add your own detection rules
- โ Cross-Platform: Works on macOS, Linux, and Windows
- โ Fast: Scans directories in milliseconds
๐ฆ Installation
From PyPI (Recommended)
pip install credlock
From Source
git clone https://github.com/yourusername/credlock.git
cd credlock
pip install -e .
๐ Quick Start
1. Install CredLock
pip install credlock
2. Setup Git Hook in Your Project
cd your-project
credlock setup-git
โ
Git pre-commit hook installed!
3. That's It!
Now every time you git push, CredLock will automatically scan for secrets:
$ git push origin main
๐ Running CredLock...
โ
No secrets found. Push allowed!
๐ Commands
Scan Directory
credlock scan # Scan current directory
credlock scan /path/to/dir # Scan specific directory
View Scan History
credlock history # Show last 10 scans
credlock history --limit=5 # Show last 5 scans
Configure Settings
credlock configure # Interactive configuration
Show Version
credlock --version
๐ What Does It Detect?
AWS Credentials
- AWS Access Key ID:
AKIA... - AWS Secret Access Key
- AWS Config files
API Keys
- Generic API keys
- GitHub tokens
- Stripe keys (live and test)
- Firebase keys
- SendGrid API keys
Passwords & Secrets
- Password assignments
- Database URLs (MySQL, PostgreSQL, MongoDB)
- Private SSH keys
- JWT tokens
Communication Tokens
- Slack tokens
- Discord webhooks
- Telegram tokens
Cloud Providers
- Google Cloud credentials
- Azure keys
- DigitalOcean tokens
- Heroku API keys
More
- Environment variables with secrets
- Authorization headers
- OAuth tokens
- 50+ total patterns
๐ Example Output
When Secrets Are Found
๐ Scanning current directory...
โ SECRETS DETECTED! Found 3 potential secrets
๐ .env (2 secrets)
Line 2: [aws_access_key] AWS_ACCESS_KEY_ID=AKIA...
Line 3: [database_password] DB_PASSWORD=mysecret123
๐ src/config.js (1 secret)
Line 45: [stripe_key] API_KEY = "sk_live_4eC39HqLyjWDar..."
โ PUSH BLOCKED - 3 SECRETS FOUND
Recommendations:
1. Move secrets to .env file
2. Add .env to .gitignore
3. Use environment variables in code
$ echo ".env" >> .gitignore
$ git rm --cached .env
$ git commit --amend
$ git push origin main
When No Secrets Found
๐ Scanning current directory...
โ
No secrets found. Scan clean!
Files scanned: 15
Duration: 0.234 seconds
โ๏ธ Configuration
CredLock is configured via ~/.credlock/config.yaml:
patterns_enabled: 50
custom_patterns: {}
ignored_files:
- .git/*
- node_modules/*
- __pycache__/*
auto_scan: true
Add Custom Pattern
credlock configure
Choose: 1 (Add custom pattern)
Pattern name: my_api_key
Regex: MY_KEY_[A-Z0-9]{32}
๐ Security Notes
- Secrets are NOT stored: CredLock only detects and blocks commits
- No network calls: Everything runs locally
- Scan history is local: Stored in
~/.credlock/history.json - No data collection: Your code never leaves your machine
๐ How It Works
- Pre-commit Hook: Git runs CredLock before every push
- File Scanning: Reads all project files (respects .gitignore)
- Pattern Matching: Uses 50+ regex patterns to detect secrets
- Reporting: Shows findings with file names and line numbers
- Exit Code: Returns 1 if secrets found (blocks push), 0 if clean
๐ Troubleshooting
"credlock: command not found"
Ensure CredLock is installed globally:
pip install credlock
which credlock # Should show /path/to/credlock
Pre-commit hook not running
Check hook is installed and executable:
cat .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
False positives (normal code flagged as secret)
Add custom ignore patterns in config:
credlock configure
# Choose to disable specific patterns
Want to force push anyway?
You can temporarily bypass CredLock:
# This skips the pre-commit hook
git push --no-verify
But don't make this a habit! ๐จ
๐ Performance
- Scans 100+ files in <1 second
- Minimal CPU/memory overhead
- No impact on normal Git workflow
๐ค Contributing
Found a bug? Want to add more patterns? Contributions welcome!
- Fork the repository
- Create a branch:
git checkout -b feature/new-pattern - Add tests for new patterns
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
โญ Support
- Documentation: Read this README
- Issues: Report bugs on GitHub
- Discussions: Ask questions in GitHub Discussions
๐ Interview Points
When asked about CredLock:
- "What problem does it solve?" โ Prevents accidental secret commits, which happen all the time
- "How does it work?" โ Git pre-commit hook + regex pattern matching
- "Why local storage?" โ Fast, no dependencies, users control their data
- "How is it different?" โ Better UX than existing tools, modern CLI, easy setup
- "What's the hardest part?" โ Balancing security (not too many patterns) with usability (not too many false positives)
๐ Future Enhancements
- Team shared config (EnvVault integration)
- Real-time monitoring dashboard
- Slack/email notifications
- Repository statistics
- CI/CD pipeline integration
- Custom rule templates
Made with โค๏ธ for developers who value security
Star this repo if you found it useful! โญ
Metadata
Release files for credlock 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| credlock-1.0.0.tar.gz | 22.2 kB | Without provenance | Details for credlock-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| credlock-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for credlock-1.0.0-py3-none-any.whl |
Total release size: 45.1 kB
Release files / credlock-1.0.0.tar.gz
| Download URL | credlock-1.0.0.tar.gz |
|---|---|
| Size | 22.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5bb706041b3ad4cf0a58c916e7bf28f4385c84aca7829dbea6ada400bb74115
|
|
BLAKE2b-256 checksum How to use checksums |
e297e0a179249af87440b9b390e6f9cca9bc50f1f6d5fef7bac6518e748e17a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Release files / credlock-1.0.0-py3-none-any.whl
| Download URL | credlock-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da1960402d8df36a9513f98561ea83e2be6754d4f21bbf44058d0535c5852c92
|
|
BLAKE2b-256 checksum How to use checksums |
3b77aee23a013f6d78186ed4616a27765a4b3cca13fc88e001231fd1edcdecb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Security for credlock 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.