aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-06-18 14:26:55 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-06-21 12:48:07 -0400
commit581429ca65131711c96f9d56bf2f0e18779aec2e (patch)
tree5800cd59dbae9c2de40b76678e967c4cb257b559
parenteea8e15845a8bcba91b93a5310ba693e8c20ab9c (diff)
downloadsos-581429ca65131711c96f9d56bf2f0e18779aec2e.tar.gz
[cleaner] Fix checksum and archive pruning from archive list
Fixes an issue where checksums may have gotten into the list of archives to be cleaned, which would cause further issues later. Additionally, prevents nested sosreports from top-level archives (such as from `collect`) from being removed for being a binary file when that top-level archive gets obfuscated.
-rw-r--r--sos/cleaner/__init__.py5
-rw-r--r--sos/cleaner/obfuscation_archive.py1
2 files changed, 4 insertions, 2 deletions
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index 88d4d0ea..8280bc50 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -226,8 +226,7 @@ third party.
nested_archives = []
for _file in archive.getmembers():
if (re.match('sosreport-.*.tar', _file.name.split('/')[-1]) and not
- (_file.name.endswith('.md5') or
- _file.name.endswith('.sha256'))):
+ (_file.name.endswith(('.md5', '.sha256')))):
nested_archives.append(_file.name.split('/')[-1])
if nested_archives:
@@ -235,6 +234,8 @@ third party.
nested_path = self.extract_archive(archive)
for arc_file in os.listdir(nested_path):
if re.match('sosreport.*.tar.*', arc_file):
+ if arc_file.endswith(('.md5', '.sha256')):
+ continue
self.report_paths.append(os.path.join(nested_path,
arc_file))
# add the toplevel extracted archive
diff --git a/sos/cleaner/obfuscation_archive.py b/sos/cleaner/obfuscation_archive.py
index 90188358..e357450b 100644
--- a/sos/cleaner/obfuscation_archive.py
+++ b/sos/cleaner/obfuscation_archive.py
@@ -58,6 +58,7 @@ class SoSObfuscationArchive():
Returns: list of files and file regexes
"""
return [
+ 'sosreport-',
'sys/firmware',
'sys/fs',
'sys/kernel/debug',