Class PiiScrubber
Default PII scrubber for CrashProtection uploads. Designed to
be subclassed: override scrubMessage(String) or
scrubFrame(String, String) to extend the behaviour, then
register the subclass with CrashProtection.setScrubber(PiiScrubber).
Default behaviour applied to exception message strings only:
- Emails partially redacted: the local part is truncated to its first
three characters followed by
***, the domain is preserved. Example:johndoe@example.combecomesjoh***@example.com. - Runs of six or more consecutive digits are replaced with
[num], catching phone numbers, long IDs, etc. - URLs are NOT scrubbed (they routinely carry useful debugging context; if a particular app embeds tokens in URLs it can opt-in to URL scrubbing by overriding this class).
Stack frames are not scrubbed by default. Class and method names do
not carry PII; subclasses that emit synthetic frames containing user
data may override scrubFrame(String, String).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringReplaces every run of six or more consecutive ASCII digits with the literal token[num].protected static StringReplaces all occurrences of an email-like substring with the form<first-three>***@<domain>.scrubFrame(String className, String methodName) Scrubs PII from a single stack frame.scrubMessage(String message) Scrubs PII from a free-form message, typically an exception message.
-
Constructor Details
-
PiiScrubber
public PiiScrubber()
-
-
Method Details
-
scrubMessage
Scrubs PII from a free-form message, typically an exception message. The default implementation applies email partial redaction and long-digit-run masking.
Parameters
message: original message; may benull.
Returns
scrubbed message, or
nullifmessageisnull. -
scrubFrame
Scrubs PII from a single stack frame. Default implementation returns the original method name unchanged.
Parameters
className: fully-qualified class name of the frame.methodName: method name of the frame.
Returns
the (possibly modified) method name to upload.
-
scrubEmails
Replaces all occurrences of an email-like substring with the form
<first-three>***@<domain>. Local parts shorter than three characters are not padded; the original prefix is preserved and followed by***. The domain (including TLD) is preserved verbatim.This implementation is character-driven rather than regex-based to stay compatible with the Java 5 source level enforced by the core framework module.
-
scrubDigitRuns
-