aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-05-05 17:02:04 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-06-15 10:31:03 -0400
commit892bbd8114703f5a4d23aa77ba5829b7ba59446f (patch)
treebfb0aadf56224f18d0d6fc1783baaaca3326a694 /tests/report_tests
parent34d997ebaea769b31e577526613e3e9ccb0893f8 (diff)
downloadsos-892bbd8114703f5a4d23aa77ba5829b7ba59446f.tar.gz
[cleaner] Remove binary files by default
Binary files generally speaking cannot be obfuscated, and as such we should remove them from archives being obfuscated by default so that sensitive data is not mistakenly included in an obfuscated archive. This commits adds a new `--keep-binary-files` option that if used will keep any encountered binary files in the final archive. The default option of `false` will ensure that encountered binary files are removed. The number of removed binary files per archive is reported when obfuscation is completed for that archive. Closes: #2478 Resolves: #2524 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r--tests/report_tests/report_with_mask.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/report_tests/report_with_mask.py b/tests/report_tests/report_with_mask.py
index a62888ae..4f94ba33 100644
--- a/tests/report_tests/report_with_mask.py
+++ b/tests/report_tests/report_with_mask.py
@@ -6,7 +6,7 @@
#
# See the LICENSE file in the source distribution for further information.
-from sos_tests import StageOneReportTest
+from sos_tests import StageOneReportTest, StageTwoReportTest
import re
@@ -67,3 +67,43 @@ class ReportWithCleanedKeywords(StageOneReportTest):
def test_keyword_obfuscated_in_file(self):
self.assertFileNotHasContent('sos_commands/kernel/uname_-a', 'Linux')
+
+
+class DefaultRemoveBinaryFilesTest(StageTwoReportTest):
+ """Testing that binary files are removed by default
+
+ :avocado: tags=stagetwo
+ """
+
+ files = ['/var/log/binary_test.tar.xz']
+ install_plugins = ['binary_test']
+ sos_cmd = '--clean -o binary_test,kernel,host'
+
+ def test_binary_removed(self):
+ self.assertFileNotCollected('var/log/binary_test.tar.xz')
+
+ def test_binaries_removed_reported(self):
+ self.assertOutputContains('\[removed .* unprocessable files\]')
+
+
+class KeepBinaryFilesTest(StageTwoReportTest):
+ """Testing that --keep-binary-files will function as expected
+
+ :avocado: tags=stagetwo
+ """
+
+ files = ['/var/log/binary_test.tar.xz']
+ install_plugins = ['binary_test']
+ sos_cmd = '--clean --keep-binary-files -o binary_test,kernel,host'
+
+ def test_warning_message_shown(self):
+ self.assertOutputContains(
+ 'WARNING: binary files that potentially contain sensitive information '
+ 'will NOT be removed from the final archive'
+ )
+
+ def test_binary_is_in_archive(self):
+ self.assertFileCollected('var/log/binary_test.tar.xz')
+
+ def test_no_binaries_reported_removed(self):
+ self.assertOutputNotContains('\[removed .* unprocessable files\]')