Add call link scrubbing for logs.
This commit is contained in:
parent
6cc8e87d46
commit
3bdffed8c9
2 changed files with 29 additions and 0 deletions
|
@ -89,6 +89,12 @@ public final class Scrubber {
|
|||
"mobi", "by", "cat", "wiki", "la", "ga", "xxx", "cf", "hr", "ng", "jobs", "online", "kz", "ug", "gq", "ae", "is",
|
||||
"lv", "pro", "fm", "tips", "ms", "sa", "app"));
|
||||
|
||||
/**
|
||||
* Base16 Call Link Key Pattern
|
||||
*/
|
||||
private static final Pattern CALL_LINK_PATTERN = Pattern.compile("([bBcCdDfFgGhHkKmMnNpPqQrRsStTxXzZ]{4})(-[bBcCdDfFgGhHkKmMnNpPqQrRsStTxXzZ]{4}){7}");
|
||||
private static final String CALL_LINK_CENSOR_SUFFIX = "-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX";
|
||||
|
||||
public static CharSequence scrub(@NonNull CharSequence in) {
|
||||
|
||||
in = scrubE164(in);
|
||||
|
@ -98,6 +104,7 @@ public final class Scrubber {
|
|||
in = scrubUuids(in);
|
||||
in = scrubDomains(in);
|
||||
in = scrubIpv4(in);
|
||||
in = scrubCallLinkKeys(in);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -171,6 +178,16 @@ public final class Scrubber {
|
|||
(matcher, output) -> output.append(IPV4_CENSOR));
|
||||
}
|
||||
|
||||
private static CharSequence scrubCallLinkKeys(@NonNull CharSequence in) {
|
||||
return scrub(in,
|
||||
CALL_LINK_PATTERN,
|
||||
((matcher, output) -> {
|
||||
String match = matcher.group(1);
|
||||
output.append(match);
|
||||
output.append(CALL_LINK_CENSOR_SUFFIX);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
private static CharSequence scrub(@NonNull CharSequence in, @NonNull Pattern pattern, @NonNull ProcessMatch processMatch) {
|
||||
final StringBuilder output = new StringBuilder(in.length());
|
||||
|
|
|
@ -113,6 +113,18 @@ public final class ScrubberTest {
|
|||
|
||||
{ "Not an ipv4 3.141",
|
||||
"Not an ipv4 3.141"
|
||||
},
|
||||
|
||||
{ "A Call Link Root Key BCDF-FGHK-MNPQ-RSTX-ZRQH-BCDF-FGHM-STXZ",
|
||||
"A Call Link Root Key BCDF-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX"
|
||||
},
|
||||
|
||||
{ "Not a Call Link Root Key (Invalid Characters) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-FGHM-STXZ",
|
||||
"Not a Call Link Root Key (Invalid Characters) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-FGHM-STXZ"
|
||||
},
|
||||
|
||||
{ "Not a Call Link Root Key (Missing Quartet) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-STXZ",
|
||||
"Not a Call Link Root Key (Missing Quartet) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-STXZ"
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue