aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-03-25 12:52:24 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-04-15 11:33:03 -0400
commit0fac82c90d6493aef21ef84c3132416ba2c5e9fb (patch)
tree3532dd4324fa7f9d7eba2ec8fed86ae172d0eb1f
parente753d9c35054cc5e0430a5e739036e5f88635b15 (diff)
downloadsos-0fac82c90d6493aef21ef84c3132416ba2c5e9fb.tar.gz
[keyword_parser] Pre-generate keyword obfuscation mappings
In events where a user-provided keyword matches a filename before, or instead of, any file _content_, that filename would go unobfuscated due to how we match filenames to obfuscated values. To resolve this, pre-generate an obfuscation map during parser initialization for each keyword provided. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/cleaner/parsers/keyword_parser.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/sos/cleaner/parsers/keyword_parser.py b/sos/cleaner/parsers/keyword_parser.py
index 4315f2a4..3dc2b7f0 100644
--- a/sos/cleaner/parsers/keyword_parser.py
+++ b/sos/cleaner/parsers/keyword_parser.py
@@ -29,7 +29,13 @@ class SoSKeywordParser(SoSCleanerParser):
for _keyword in self.mapping.dataset.keys():
self.user_keywords.append(_keyword)
if keywords:
- self.user_keywords.extend(keywords)
+ for keyword in keywords:
+ if keyword not in self.user_keywords:
+ # pre-generate an obfuscation mapping for each keyword
+ # this is necessary for cases where filenames are being
+ # obfuscated before or instead of file content
+ self.mapping.get(keyword)
+ self.user_keywords.append(keyword)
if keyword_file and os.path.exists(keyword_file):
with open(keyword_file, 'r') as kwf:
self.user_keywords.extend(kwf.read().splitlines())