EasySecurityPython 3
Secret Redactor
Redact common emails, bearer tokens, and API-key-shaped strings from log text.
25m2 sample tests3 hidden tests
Redact common secret-like values from logs before they are stored.
Requirements
- Define
redact_secrets(text). - Replace email addresses with
<email>. - Replace bearer tokens like
Bearer abc123withBearer <redacted>. - Replace keys beginning with
sk-followed by at least eight letters, digits,_, or-withsk-<redacted>. - Return the redacted string.
- Preserve other text unchanged.
Example
python
1assert redact_secrets("Authorization: Bearer abc123") == "Authorization: Bearer <redacted>"Constraints
- Use standard-library Python only.
- Do not over-redact short strings like
sk-test. - Redaction should be deterministic.
Editor
Results
Run sample tests or submit all tests.