Keep Secrets Out of the Logs
150 points · 0 solved
Leaked credentials in logs are a classic breach. The first line is T; each next line is a log line. Redact, in this order:
password=,passwd=,token=,api_key=orsecret=(key in any case, at a word boundary) followed by a value up to the next whitespace or&→ keep the key as written, replace the value with[REDACTED].- AWS access keys:
AKIAfollowed by exactly 16 ofA-Z 0-9, as a whole word →[REDACTED]. Bearer(any case) followed by a token ofA-Za-z0-9._~+/-and optional trailing=→Bearer [REDACTED].
Example 1 input
2 POST /api?api_key=sk_live_123&debug=1 user=alice password=correct-horse
Expected output
POST /api?api_key=[REDACTED]&debug=1 user=alice password=[REDACTED]
main.py
Ctrl+Enter runs · Ctrl+Shift+Enter submits