|
|
c71a15 |
From d4d4d5509fe4f0e29260b33a1c51bf62297ef0b9 Mon Sep 17 00:00:00 2001
|
|
|
c71a15 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
c71a15 |
Date: Tue, 7 Mar 2023 13:16:02 +0100
|
|
|
c71a15 |
Subject: [PATCH 1/2] [cleaner] dont clean sys_tmp from final_path
|
|
|
c71a15 |
|
|
|
c71a15 |
When generating location of final tarball, apply cleaner obfuscation to
|
|
|
c71a15 |
the filename but not to the tmp path itself. Otherwise
|
|
|
c71a15 |
|
|
|
c71a15 |
sos clean --keywords tmp
|
|
|
c71a15 |
|
|
|
c71a15 |
fails in attempt to move file to nonexisting /var/obfuscatedword0
|
|
|
c71a15 |
directory.
|
|
|
c71a15 |
|
|
|
c71a15 |
Resolves: #3160
|
|
|
c71a15 |
|
|
|
c71a15 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
c71a15 |
---
|
|
|
c71a15 |
sos/cleaner/__init__.py | 5 +++--
|
|
|
c71a15 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
c71a15 |
|
|
|
c71a15 |
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
|
|
|
c71a15 |
index d3e32992..b8e4aafd 100644
|
|
|
c71a15 |
--- a/sos/cleaner/__init__.py
|
|
|
c71a15 |
+++ b/sos/cleaner/__init__.py
|
|
|
c71a15 |
@@ -400,8 +400,9 @@ third party.
|
|
|
c71a15 |
cf.write(checksum)
|
|
|
c71a15 |
self.write_cleaner_log()
|
|
|
c71a15 |
|
|
|
c71a15 |
- final_path = self.obfuscate_string(
|
|
|
c71a15 |
- os.path.join(self.sys_tmp, arc_path.split('/')[-1])
|
|
|
c71a15 |
+ final_path = os.path.join(
|
|
|
c71a15 |
+ self.sys_tmp,
|
|
|
c71a15 |
+ self.obfuscate_string(arc_path.split('/')[-1])
|
|
|
c71a15 |
)
|
|
|
c71a15 |
shutil.move(arc_path, final_path)
|
|
|
c71a15 |
arcstat = os.stat(final_path)
|
|
|
c71a15 |
--
|
|
|
c71a15 |
2.39.2
|
|
|
c71a15 |
|
|
|
c71a15 |
|
|
|
c71a15 |
From 622a26ee2faff91df03532892ca386c39e36a5fe Mon Sep 17 00:00:00 2001
|
|
|
c71a15 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
c71a15 |
Date: Tue, 7 Mar 2023 17:55:19 +0100
|
|
|
c71a15 |
Subject: [PATCH 2/2] [tests] add a test covering #3160
|
|
|
c71a15 |
|
|
|
c71a15 |
Run the cleaner tests with obfuscating (also) "tmp" to cover files
|
|
|
c71a15 |
handling under sys_tmp.
|
|
|
c71a15 |
|
|
|
c71a15 |
Related to: #3160
|
|
|
c71a15 |
|
|
|
c71a15 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
c71a15 |
---
|
|
|
c71a15 |
tests/cleaner_tests/existing_archive.py | 19 +++++++++++++++++++
|
|
|
c71a15 |
1 file changed, 19 insertions(+)
|
|
|
c71a15 |
|
|
|
c71a15 |
diff --git a/tests/cleaner_tests/existing_archive.py b/tests/cleaner_tests/existing_archive.py
|
|
|
c71a15 |
index e13d1cae..7f31f88e 100644
|
|
|
c71a15 |
--- a/tests/cleaner_tests/existing_archive.py
|
|
|
c71a15 |
+++ b/tests/cleaner_tests/existing_archive.py
|
|
|
c71a15 |
@@ -89,3 +89,22 @@ class ExistingArchiveCleanTest(StageTwoReportTest):
|
|
|
c71a15 |
"""Ensure that the 'testuser1' user created at install is obfuscated
|
|
|
c71a15 |
"""
|
|
|
c71a15 |
self.assertFileNotHasContent('var/log/anaconda/journal.log', 'testuser1')
|
|
|
c71a15 |
+
|
|
|
c71a15 |
+class ExistingArchiveCleanTmpTest(StageTwoReportTest):
|
|
|
c71a15 |
+ """Continuation of above tests which requires cleaning var / tmp keywords
|
|
|
c71a15 |
+
|
|
|
c71a15 |
+ Note that this copies heavily from the full_report_run test.
|
|
|
c71a15 |
+
|
|
|
c71a15 |
+ :avocado: tags=stagetwo
|
|
|
c71a15 |
+ """
|
|
|
c71a15 |
+
|
|
|
c71a15 |
+ sos_cmd = '-v --keywords var,tmp,avocado --disable-parsers ip,ipv6,mac,username \
|
|
|
c71a15 |
+ --no-update tests/test_data/%s.tar.xz' % ARCHIVE
|
|
|
c71a15 |
+ sos_component = 'clean'
|
|
|
c71a15 |
+
|
|
|
c71a15 |
+ def test_sys_tmp_not_obfuscated(self):
|
|
|
c71a15 |
+ """ Ensure that keywords var, tmp and avocado remains in the final archive
|
|
|
c71a15 |
+ path despite they are parts of the --tmp-dir
|
|
|
c71a15 |
+ """
|
|
|
c71a15 |
+ self.assertTrue(self.archive.startswith(os.getenv('AVOCADO_TESTS_COMMON_TMPDIR')))
|
|
|
c71a15 |
+
|
|
|
c71a15 |
--
|
|
|
c71a15 |
2.39.2
|
|
|
c71a15 |
|