env-leak
Scan your codebase for leaked API keys, tokens, and secrets before they reach production.
Install
pip install env-leak
Usage
# Scan current directory
env-leak .
# Scan a specific path, skip test fixtures
env-leak ./src --exclude tests --exclude fixtures
# Disable entropy detection (pattern-only)
env-leak . --no-entropy
# Output JSON for CI pipelines
env-leak . --json > report.json
What it detects
| Type | Examples |
|---|---|
| OpenAI / Anthropic API keys | sk-..., sk-ant-... |
| AWS credentials | AKIA... access key IDs, secret key assignments |
| GitHub tokens | ghp_, gho_, github_pat_ |
| Stripe keys | sk_live_, pk_live_ |
| Google / Firebase | AIza..., Firebase server keys |
| Slack tokens | xoxb-, xoxp- |
| JWT tokens | Any eyJ...eyJ... pattern |
| Private keys | PEM headers in source files |
| Passwords in URLs | https://user:pass@host |
| Generic assignments | api_key = "...", secret = "..." |
| High-entropy strings | Statistically random strings ≥ 20 chars |
CI integration
# .github/workflows/secret-scan.yml
- name: Scan for secrets
run: pip install env-leak && env-leak . --no-entropy --json
Exit code 1 when secrets are found — makes it a natural CI gate.
How entropy detection works
env-leak computes Shannon entropy for tokens longer than 20 characters. Real API keys and tokens are nearly random (entropy ≥ 4.5 bits/char). Normal English words and code identifiers score ~3.5. This catches secrets that don't match any known pattern.
License
MIT
Metadata
Release files for env-leak 0.1.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 |
|---|---|---|---|---|
| env_leak-0.1.0.tar.gz | 5.8 kB | Without provenance | Details for env_leak-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| env_leak-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for env_leak-0.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / env_leak-0.1.0.tar.gz
| Download URL | env_leak-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc58ca39f92af6004d6d80d3bfa60c7c4683581aef20bb7c00124d6db7a10e7b
|
|
BLAKE2b-256 checksum How to use checksums |
a030f213508ad8d66520aaf6b4ba02d7303875815aad4eebe579b58d198a89c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / env_leak-0.1.0-py3-none-any.whl
| Download URL | env_leak-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95e6934406c5024ea108a6cd9bbf59ff4e768f057cdcbe7fe166820004c2e98e
|
|
BLAKE2b-256 checksum How to use checksums |
85b6016e056d86ac62d9fb2c56fd692a9a155ca98068157570274c341af1f7b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for env-leak 0.1.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.