Expand description
Free-form secret redaction for log lines, telemetry events, and diagnostic surfaces.
The seven rules and the order they run in are documented at https://redact.rust.phpboyscout.uk/reference/rules/. The original design is spec 0010: https://gitlab.com/phpboyscout/rust-tool-base/-/wikis/specs/0010-rtb-redact-v0.1.
use rtb_redact::string;
let scrubbed = string("connect to postgres://app:hunter2@db/mydb");
assert!(scrubbed.contains("[redacted]"));
assert!(!scrubbed.contains("hunter2"));Statics§
- SENSITIVE_
HEADERS - Header names whose values must be redacted at DEBUG / TRACE log
levels. Case-insensitive match via
is_sensitive_header.phf::Setkeeps lookup O(1) as the list grows.
Functions§
- is_
sensitive_ header - Case-insensitive membership check against
SENSITIVE_HEADERS. - redact_
header_ value - Unconditionally redact a header value. Callers invoke this for
any header name matching
is_sensitive_header. - string
- Redact secrets in
input, returning a borrowedCowwhen no redactions apply and an ownedStringotherwise. - string_
into - Same as
string, but writes into a caller-suppliedString. Useful for hot loops that want to reuse a buffer.