Skip to main content

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

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

  1. Pre-commit Hook: Git runs CredLock before every push
  2. File Scanning: Reads all project files (respects .gitignore)
  3. Pattern Matching: Uses 50+ regex patterns to detect secrets
  4. Reporting: Shows findings with file names and line numbers
  5. 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!

  1. Fork the repository
  2. Create a branch: git checkout -b feature/new-pattern
  3. Add tests for new patterns
  4. 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 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for credlock 2.0.1
File Size Uploaded Provenance Actions
credlock-2.0.1.tar.gz 26.0 kB Without provenance Details for credlock-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for credlock 2.0.1
File Interpreter ABI Platform Actions
credlock-2.0.1-py3-none-any.whl Python 3 none any Details for credlock-2.0.1-py3-none-any.whl

Total release size: 54.0 kB

Release files / credlock-2.0.1.tar.gz

Download URL credlock-2.0.1.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
46426dd61f16b29d05057b73c9433a6feef0265976f36d2e9dfe59082122c99a
BLAKE2b-256 checksum
How to use checksums
a896b9234a75d3f1962f170ad549c9c150684976a590cc206eeb110351148a16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Release files / credlock-2.0.1-py3-none-any.whl

Download URL credlock-2.0.1-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cf6fd879ea6ad5960c5e45ef9a7335268d93799b4eedeaa25cae4945112f372
BLAKE2b-256 checksum
How to use checksums
e5186476e8c4c203f89e212f5b9c95b08c806c6a0a48ed6367a3f81ebc239a66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Security for credlock 2.0.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page