diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-09-01 00:28:58 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-09-13 10:47:04 -0400 |
commit | decd39b7799a0579ea085b0da0728b6eabd49b38 (patch) | |
tree | fdb55757592367a0f9ac61d2eef9d3f66ab84d22 /tests | |
parent | 9f739f98114633ae2f2813f348eef3cd599aa516 (diff) | |
download | sos-decd39b7799a0579ea085b0da0728b6eabd49b38.tar.gz |
[clean] Provide archive abstractions to obfuscate more than sos archives
This commit removes the restriction imposed on `sos clean` since its
introduction in sos-4.0 to only work against known sos report archives
or build directories. This is because there has been interest in using
the obfuscation bits of sos in other data-collector projects.
The `SoSObfuscationArchive()` class has been revamped to now be an
abstraction for different types of archives, and the cleaner logic has
been updated to leverage this new abstraction rather than assuming we're
working on an sos archive.
Abstractions are added for our own native use cases - that being `sos
report` and `sos collect` for at-runtime obfuscation, as well as
standalone archives previously generated. Further generic abstractions
are available for plain directories and tarballs however these will not
provide the same level of coverage as fully supported archive types, as
is noted in the manpage for sos-clean.
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cleaner_tests/existing_archive.py | 7 | ||||
-rw-r--r-- | tests/cleaner_tests/full_report_run.py | 3 | ||||
-rw-r--r-- | tests/cleaner_tests/report_with_mask.py | 3 |
3 files changed, 13 insertions, 0 deletions
diff --git a/tests/cleaner_tests/existing_archive.py b/tests/cleaner_tests/existing_archive.py index 0eaf6c8d..e13d1cae 100644 --- a/tests/cleaner_tests/existing_archive.py +++ b/tests/cleaner_tests/existing_archive.py @@ -28,6 +28,13 @@ class ExistingArchiveCleanTest(StageTwoReportTest): def test_obfuscation_log_created(self): self.assertFileExists(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE)) + def test_archive_type_correct(self): + with open(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE), 'r') as log: + for line in log: + if "Loaded %s" % ARCHIVE in line: + assert 'as type sos report archive' in line, "Incorrect archive type detected: %s" % line + break + def test_from_cmdline_logged(self): with open(os.path.join(self.tmpdir, '%s-obfuscation.log' % ARCHIVE), 'r') as log: for line in log: diff --git a/tests/cleaner_tests/full_report_run.py b/tests/cleaner_tests/full_report_run.py index 3b28e7a2..2de54946 100644 --- a/tests/cleaner_tests/full_report_run.py +++ b/tests/cleaner_tests/full_report_run.py @@ -35,6 +35,9 @@ class FullCleanTest(StageTwoReportTest): def test_tarball_named_obfuscated(self): self.assertTrue('obfuscated' in self.archive) + def test_archive_type_correct(self): + self.assertSosLogContains('Loaded .* as type sos report directory') + def test_hostname_not_in_any_file(self): host = self.sysinfo['pre']['networking']['hostname'] # much faster to just use grep here diff --git a/tests/cleaner_tests/report_with_mask.py b/tests/cleaner_tests/report_with_mask.py index 4f94ba33..08e873d4 100644 --- a/tests/cleaner_tests/report_with_mask.py +++ b/tests/cleaner_tests/report_with_mask.py @@ -31,6 +31,9 @@ class ReportWithMask(StageOneReportTest): def test_tarball_named_obfuscated(self): self.assertTrue('obfuscated' in self.archive) + def test_archive_type_correct(self): + self.assertSosLogContains('Loaded .* as type sos report directory') + def test_localhost_was_obfuscated(self): self.assertFileHasContent('/etc/hostname', 'host0') |