pub fn scrub(text: &str) -> StringExpand description
Replaces what must not leave the app in an error report, and what keeps the same error from grouping.
For Subscribers that send reports to an
outside service (Report::scrubbed applies it to a whole report):
| Found | Becomes |
|---|---|
Bearer <token>, Basic <credentials>, well-known key prefixes (sk_live_, whsec_, ghp_, AKIA…) | [secret] |
password=, token=, key=, signature=… query values | <name>=[secret] |
| email addresses | [email] |
| UUIDs | [id] |
| runs of 32 or more letters and digits (tokens, digests) | [secret] |
durations (12 ms, 3.5s, 40µs) | [n]ms, [n]s, [n]µs |
Pure CPU, a single pass per rule over the text.
§Examples
use ocre::errors::scrub;
assert_eq!(scrub("Authorization: Bearer eyJ.abc/def="), "Authorization: [secret]");
assert_eq!(scrub("no user ada.l+x@example.co.uk"), "no user [email]");
assert_eq!(scrub("video 0b9c2f44-1d2e-4f7a-9c3b-2a1b0c9d8e7f gone"), "video [id] gone");
assert_eq!(scrub("GET /reset?token=abc123&x=1 took 12.5 ms"), "GET /reset?token=[secret]&x=1 took [n]ms");