aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-01-17 11:11:24 -0500
committerJake Hunsaker <jhunsake@redhat.com>2022-01-17 13:29:39 -0500
commit9eb60f0bb6ea36f9c1cf099c1fd20cf3938b4b26 (patch)
tree584aa184561ab7d161f9b7670727c8f065ed30b0
parent747fef695e4ff08f320c5f03090bdefa7154c761 (diff)
downloadsos-9eb60f0bb6ea36f9c1cf099c1fd20cf3938b4b26.tar.gz
[clean] Ignore empty items for obfuscation better
This commit fixes a couple edge cases where an item empty (e.g. and empty string '') was not being properly ignored, which in turned caused failures in writing both obfuscations and replacement files. This should no longer be possible. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/cleaner/mappings/__init__.py5
-rw-r--r--sos/cleaner/mappings/username_map.py2
-rw-r--r--sos/cleaner/parsers/username_parser.py2
3 files changed, 6 insertions, 3 deletions
diff --git a/sos/cleaner/mappings/__init__.py b/sos/cleaner/mappings/__init__.py
index 5cf5c8b2..48171a05 100644
--- a/sos/cleaner/mappings/__init__.py
+++ b/sos/cleaner/mappings/__init__.py
@@ -49,6 +49,8 @@ class SoSMap():
:param item: The plaintext object to obfuscate
"""
with self.lock:
+ if not item:
+ return item
self.dataset[item] = self.sanitize_item(item)
return self.dataset[item]
@@ -67,7 +69,8 @@ class SoSMap():
"""Retrieve an item's obfuscated counterpart from the map. If the item
does not yet exist in the map, add it by generating one on the fly
"""
- if self.ignore_item(item) or self.item_in_dataset_values(item):
+ if (not item or self.ignore_item(item) or
+ self.item_in_dataset_values(item)):
return item
if item not in self.dataset:
return self.add(item)
diff --git a/sos/cleaner/mappings/username_map.py b/sos/cleaner/mappings/username_map.py
index 7ecccd7b..ed6dc091 100644
--- a/sos/cleaner/mappings/username_map.py
+++ b/sos/cleaner/mappings/username_map.py
@@ -24,7 +24,7 @@ class SoSUsernameMap(SoSMap):
def load_names_from_options(self, opt_names):
for name in opt_names:
- if name not in self.dataset.keys():
+ if name and name not in self.dataset.keys():
self.add(name)
def sanitize_item(self, username):
diff --git a/sos/cleaner/parsers/username_parser.py b/sos/cleaner/parsers/username_parser.py
index 49640f7f..2853c860 100644
--- a/sos/cleaner/parsers/username_parser.py
+++ b/sos/cleaner/parsers/username_parser.py
@@ -55,7 +55,7 @@ class SoSUsernameParser(SoSCleanerParser):
user = line.split()[0]
except Exception:
continue
- if user.lower() in self.skip_list:
+ if not user or user.lower() in self.skip_list:
continue
users.add(user)
for each in users: