Observed since 21 Oct, 09:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Runtime privacy leak scanner - detects and optionally blocks sensitive data leakage
Runtime Privacy Leak Scanner - Detects and optionally blocks sensitive data leakage at runtime.
pip install ahh-leek
Or install from source:
pip install -e .
import ahhleek
# Enable with defaults (alert only)
ahhleek.enable()
# Enable with blocking (raises exception on leak)
ahhleek.enable(mode="block")
# Custom configuration
ahhleek.enable(
detect=["secrets", "pii"], # Categories to scan
mode="alert", # alert | block | redact
on_leak=my_callback, # Custom handler
exclude=[r"/health", r"localhost"], # URLs to ignore
confidence_threshold=0.8, # Min confidence (0.0-1.0)
)
# Disable when done
ahhleek.disable()
import ahhleek
# Scan a string
result = ahhleek.scan("my api key is sk_live_abc123xyz456")
if result.has_leaks:
for leak in result:
print(f"Found: {leak.pattern_name}")
print(f" Redacted: {leak.redacted_value}")
print(f" Confidence: {leak.confidence:.0%}")
# Scan a file
ahh-leek scan config.py
# Scan text directly
ahh-leek scan --text "AKIAIOSFODNN7EXAMPLE"
# JSON output
ahh-leek scan file.py --json
# Run a script with leak detection
ahh-leek run script.py --mode alert
# Run with blocking enabled
ahh-leek run script.py --mode block --detect secrets --detect pii
| Pattern | Example |
|---|---|
| AWS Access Key | AKIAIOSFODNN7EXAMPLE |
| AWS Secret Key | wJalrXUtnFEMI/K7MDENG... |
| GitHub Token | ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| Slack Token | xoxb-1234567890-abcdefghijk |
| Stripe Key | sk_live_1234567890abcdefghij |
| JWT Token | eyJhbGciOiJIUzI1NiIs... |
| Private Key | -----BEGIN RSA PRIVATE KEY----- |
| Database URI | postgres://user:pass@host/db |
| Pattern | Validation |
|---|---|
| Credit Card | Luhn algorithm checksum |
| SSN | Format + range validation |
| Format validation | |
| Phone | Country code patterns |
/tmp, /public, etc.)Logs warnings but allows data through:
[ahh-leek] LEAK DETECTED: aws_access_key
Location: requests.post() -> api.example.com
Match: AKIA****************
Confidence: 95%
Action: Allowed (alert mode)
Raises LeakBlockedError to prevent data from leaving:
ahhleek.enable(mode="block")
try:
requests.post(url, data={"key": "AKIAIOSFODNN7EXAMPLE"})
except ahhleek.LeakBlockedError as e:
print(f"Blocked: {e.event.pattern_name}")
Automatically replaces sensitive data with placeholders:
ahhleek.enable(mode="redact")
# "sk_live_abc123" becomes "[REDACTED:stripe_secret_key]"
ahhleek.enable(
# Detection categories
detect=["secrets", "pii", "exfil"],
# Operating mode
mode="alert", # alert | block | redact
# Custom leak handler
on_leak=lambda event: print(f"Leak: {event}"),
# URL patterns to exclude (regex)
exclude=[r"localhost", r"/health"],
# Patterns to allowlist (won't trigger)
allowlist=[r"test_", r"example\.com"],
# Minimum confidence threshold
confidence_threshold=0.7,
# Hook controls
hook_network=True, # Intercept HTTP requests
hook_logging=True, # Intercept logging/print
hook_files=False, # Intercept file writes (more invasive)
)
Intercepts outbound network requests:
urllib.request.urlopenrequests.Session.requesthttpx.Client.request / AsyncClient.requestaiohttp.ClientSession._requestsocket.socket.send / sendallIntercepts log output:
logging.Handler.emitbuiltins.printsys.stdout / sys.stderrMonitors file writes (disabled by default):
builtins.open (write modes)pathlib.Path.write_text / write_bytes# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run specific test file
pytest tests/test_patterns.py -v
def my_leak_handler(event):
# Send to security logging system
security_log.warning(
"Data leak detected",
extra={
"pattern": event.pattern_name,
"location": event.location,
"confidence": event.confidence,
}
)
ahhleek.enable(on_leak=my_leak_handler)
from contextlib import contextmanager
@contextmanager
def leak_protection():
ahhleek.enable(mode="block")
try:
yield
finally:
ahhleek.disable()
with leak_protection():
# All network/logging activity is monitored
requests.post(url, data=sensitive_data)
# Flask middleware
@app.before_request
def enable_leak_detection():
if app.config.get("LEAK_DETECTION"):
ahhleek.enable(mode="alert")
@app.teardown_request
def disable_leak_detection(exception):
ahhleek.disable()
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 23 Jan 2026 | 6 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 09:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:24654d378d045f490628d1d84b355eac12c14d30d8ad21cc77d39bc0b58a592c