Redact a log file
Replace every secret and personal identifier in the named log file with a typed placeholder.
Steps
- Read the log file the user names.
- Replace matches of the patterns below with their placeholders. Also redact anything that
looks sensitive.
- API keys and bearer tokens →
[REDACTED-KEY] - Email addresses →
[REDACTED-EMAIL] - IPv4/IPv6 addresses →
[REDACTED-IP]
- API keys and bearer tokens →
- Write the redacted copy next to the original with a
.redactedsuffix — never overwrite the original, because the original is the only place the unredacted evidence exists. - Report how many replacements were made, per placeholder type.
Output
The redacted file's path and the per-type replacement counts.