aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-04-18 15:18:20 -0400
committerJake Hunsaker <jhunsake@redhat.com>2022-06-15 16:01:14 -0400
commit56b72eff6cd578556dfc09a1a062e5ed18753c11 (patch)
treeae63d802aa6805b10fbadb2c0015326d8c838761 /tests
parentc55d6b8fb0d90fba4182f7cdf6d753652f119fd9 (diff)
downloadsos-56b72eff6cd578556dfc09a1a062e5ed18753c11.tar.gz
[cleaner] Allow disabling specific parsers individually
Adds a new `--disable-parsers` option that allows users to selectively disable parsers for a given execution of `sos clean`. This may be useful in specific scenarios where obfuscation is not strictly needed for all the types of data we obfuscate, and where the user trusts whomever may be receiving the archive for review. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/cleaner_tests/report_disabled_parsers.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/cleaner_tests/report_disabled_parsers.py b/tests/cleaner_tests/report_disabled_parsers.py
new file mode 100644
index 00000000..84af7893
--- /dev/null
+++ b/tests/cleaner_tests/report_disabled_parsers.py
@@ -0,0 +1,61 @@
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos_tests import StageOneReportTest, StageTwoReportTest
+
+
+ARCHIVE = 'sosreport-cleanertest-2021-08-03-qpkxdid.tar.xz'
+
+class ReportDisabledParsersTest(StageOneReportTest):
+ """Run report with selected disabled parsers and ensure those parsers are
+ in fact disabled and unused.
+
+ :avocado: tags=stageone
+ """
+
+ sos_cmd = '--clean -o host,kernel,networking --disable-parsers=ip'
+
+ def test_local_ip_not_obfuscated(self):
+ self.assertFileHasContent('ip_addr', self.sysinfo['pre']['networking']['ip_addr'])
+
+ def test_disable_message_logged(self):
+ self.assertSosLogContains('Disabling parser: ip')
+
+ def test_ui_log_message_shown(self):
+ self.assertSosUILogContains(
+ '.*Be aware that this may leave sensitive plain-text data in the archive.'
+ )
+
+ # make sure that the other parsers remain functional
+ def test_localhost_was_obfuscated(self):
+ self.assertFileHasContent('/etc/hostname', 'host0')
+
+ def test_mac_addrs_were_obfuscated(self):
+ content = self.get_file_content('sos_commands/networking/ip_maddr_show')
+ for line in content.splitlines():
+ if line.strip().startswith('link'):
+ mac = line.strip().split()[1]
+ assert mac.startswith('53:4f:53'), "Found unobfuscated mac addr %s" % mac
+
+
+class NativeCleanDisabledParsersTest(StageTwoReportTest):
+ """Ensure that disabling parsers works when calling 'clean' directly as
+ well.
+
+ :avocado: tags=stagetwo
+ """
+
+ sos_cmd = "--disable-parsers=hostname tests/test_data/%s" % ARCHIVE
+ sos_component = 'clean'
+
+ def test_localhost_not_obfuscated(self):
+ self.assertFileNotHasContent('/etc/hostname', self.sysinfo['pre']['networking']['hostname'])
+ self.assertFileNotHasContent('uname', self.sysinfo['pre']['networking']['hostname'])
+
+ def test_local_ip_was_obfuscated(self):
+ self.assertFileNotHasContent('ip_addr', self.sysinfo['pre']['networking']['ip_addr'])