From 47465338a510b05a4104deb68e9b209391ea37bd Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Wed, 9 Mar 2022 11:33:09 -0500 Subject: [mac_parser] Match quoted mac addresses, fix duplication check First, update the regexes to account for possible quotes wrapping the mac address to match. Second, fix an edge case with these quoted mac addresses in our check for avoiding duplicating obfuscations of already obfuscated addresses by checking the stripped mac address instead of the raw one. Closes: #2873 Signed-off-by: Jake Hunsaker --- tests/unittests/cleaner_tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/unittests/cleaner_tests.py') diff --git a/tests/unittests/cleaner_tests.py b/tests/unittests/cleaner_tests.py index b59eade9..39f81a78 100644 --- a/tests/unittests/cleaner_tests.py +++ b/tests/unittests/cleaner_tests.py @@ -131,6 +131,30 @@ class CleanerParserTests(unittest.TestCase): _test = self.mac_parser.parse_line(line)[0] self.assertNotEqual(line, _test) + def test_mac_parser_with_quotes(self): + line = "foobar foo '12:34:56:78:90:AA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "aa:12:bb:34:cc:56" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + + def test_mac_parser_with_quotes_ipv6(self): + line = "foobar foo 'FF:EE:DD:FF:FE:CC:BB:AA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "DD:EE:FF:FF:FE:BB:CC:AA" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + + def test_mac_parser_with_quotes_ipv6_quad(self): + line = "foobar foo 'AABB:CCDD:EEFF:FFAA' bar barfoo" + _test = self.mac_parser.parse_line(line)[0] + self.assertNotEqual(line, _test) + dline = 'foobar foo "AAFF:FFEE:DDCC:BBAA" bar barfoo' + _dtest = self.mac_parser.parse_line(dline)[0] + self.assertNotEqual(dline, _dtest) + def test_hostname_load_hostname_string(self): fqdn = 'myhost.subnet.example.com' self.host_parser.load_hostname_into_map(fqdn) -- cgit