Commit 21a5d55d authored by Thiemo Nagel's avatar Thiemo Nagel Committed by Commit Bot

AnonymizerTool: Match serials in device_event_log

(Only the serial number pattern has changed, the other patterns have
been reformatted to avoid overly long lines.)

BUG=none
TEST=added test pattern to unittest

Change-Id: Iee036cd0fc71cb4ccb55ea1809534bbdb6d52943
Reviewed-on: https://chromium-review.googlesource.com/822932Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Thiemo Nagel <tnagel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523482}
parent ad912061
......@@ -42,12 +42,19 @@ namespace {
// (?-s) turns off "dot matches newline" for the remainder of the regex.
// (?:regex) denotes non-capturing parentheses group.
constexpr const char* kCustomPatternsWithContext[] = {
"(\\bCell ID: ')([0-9a-fA-F]+)(')", // ModemManager
"(\\bLocation area code: ')([0-9a-fA-F]+)(')", // ModemManager
"(?i-s)(\\bssid[= ]')(.+)(')", // wpa_supplicant
"(?-s)(\\bSSID - hexdump\\(len=[0-9]+\\): )(.+)()", // wpa_supplicant
"(?-s)(\\[SSID=)(.+?)(\\])", // shill
"(?i-s)(serial\\s*number\\s*:\\s*)([0-9a-zA-Z\\-]+)()", // Serial numbers
// ModemManager
"(\\bCell ID: ')([0-9a-fA-F]+)(')",
"(\\bLocation area code: ')([0-9a-fA-F]+)(')",
// wpa_supplicant
"(?i-s)(\\bssid[= ]')(.+)(')",
"(?-s)(\\bSSID - hexdump\\(len=[0-9]+\\): )(.+)()",
// shill
"(?-s)(\\[SSID=)(.+?)(\\])",
// Serial numbers
"(?i-s)(serial\\s*(?:number)?\\s*[:=]\\s*)([0-9a-zA-Z\\-\"]+)()",
};
// Helper macro: Non capturing group
......
......@@ -117,6 +117,7 @@ TEST_F(AnonymizerToolTest, AnonymizeCustomPatterns) {
AnonymizeCustomPatterns("serial number: 50C971FEE7F3x010900"));
EXPECT_EQ("SerialNumber: 3",
AnonymizeCustomPatterns("SerialNumber: EVT23-17BA01-004"));
EXPECT_EQ("serial=4", AnonymizeCustomPatterns("serial=\"1234AA5678\""));
EXPECT_EQ("<email: 1>",
AnonymizeCustomPatterns("foo@bar.com"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment