Commit 85eea804 authored by afakhry's avatar afakhry Committed by Commit bot

Scrub peripheral serial numbers from logs

Add a new pattern to detect and scrub serial numbers logged in
/var/log/messages

BUG=714802
TEST=components_unittests --gtest_filter=AnonymizerToolTest.AnonymizeCustomPatterns

Review-Url: https://codereview.chromium.org/2842263005
Cr-Commit-Position: refs/heads/master@{#468334}
parent f64d99f9
......@@ -41,11 +41,12 @@ namespace {
// (?-s) turns off "dot matches newline" for the remainder of the regex.
// (?:regex) denotes non-capturing parentheses group.
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
"(\\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
};
// Helper macro: Non capturing group
......
......@@ -95,6 +95,13 @@ TEST_F(AnonymizerToolTest, AnonymizeCustomPatterns) {
"a\nb [SSID=1] [SSID=2] [SSID=foo\nbar] b",
AnonymizeCustomPatterns("a\nb [SSID=foo] [SSID=bar] [SSID=foo\nbar] b"));
EXPECT_EQ("SerialNumber: 1",
AnonymizeCustomPatterns("SerialNumber: 1217D7EF"));
EXPECT_EQ("serial number: 2",
AnonymizeCustomPatterns("serial number: 50C971FEE7F3x010900"));
EXPECT_EQ("SerialNumber: 3",
AnonymizeCustomPatterns("SerialNumber: EVT23-17BA01-004"));
EXPECT_EQ("<email: 1>",
AnonymizeCustomPatterns("foo@bar.com"));
EXPECT_EQ("Email: <email: 1>.",
......
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