aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/cleaner/parsers/ip_parser.py4
-rw-r--r--tests/cleaner_tests/skip_version_ip_parser.py33
-rw-r--r--tests/test_data/fake_plugins/skip_versions.py24
-rw-r--r--tests/test_data/tmp/sos-test-version-noskip6
-rw-r--r--tests/test_data/tmp/sos-test-version.txt6
5 files changed, 71 insertions, 2 deletions
diff --git a/sos/cleaner/parsers/ip_parser.py b/sos/cleaner/parsers/ip_parser.py
index ece9cd73..d5522ac2 100644
--- a/sos/cleaner/parsers/ip_parser.py
+++ b/sos/cleaner/parsers/ip_parser.py
@@ -35,10 +35,10 @@ class SoSIPParser(SoSCleanerParser):
'sos_commands/rpm',
'sos_commands/yum/.*list.*',
'sos_commands/snappy/snap_list_--all',
- 'sos_commands/snappy/snap_--version',
'sos_commands/vulkan/vulkaninfo',
'var/log/.*dnf.*',
- 'var/log/.*packag.*' # get 'packages' and 'packaging' logs
+ 'var/log/.*packag.*', # get 'packages' and 'packaging' logs
+ '.*(version|release)(\\.txt)?$', # obvious version files
]
map_file_key = 'ip_map'
diff --git a/tests/cleaner_tests/skip_version_ip_parser.py b/tests/cleaner_tests/skip_version_ip_parser.py
new file mode 100644
index 00000000..882244ea
--- /dev/null
+++ b/tests/cleaner_tests/skip_version_ip_parser.py
@@ -0,0 +1,33 @@
+# 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 StageTwoReportTest
+
+DO_SKIP = '/tmp/sos-test-version.txt'
+NO_SKIP = '/tmp/sos-test-version-noskip'
+
+class SkipVersionIPParser(StageTwoReportTest):
+ """Ensures that we _skip_ files ending in 'version' (or 'version.txt') to
+ avoid incorrectly obfuscating version numbers.
+
+ :avocado: tags=stagetwo
+ """
+
+ files = [DO_SKIP, NO_SKIP]
+ install_plugins = ['skip_versions']
+ sos_cmd = '--clean -o skip_versions'
+
+ def test_version_file_skipped(self):
+ self.assertFileCollected(DO_SKIP)
+ self.assertFileHasContent(DO_SKIP, '10.11.12.13')
+ self.assertFileHasContent(DO_SKIP, '6.0.0.1')
+
+ def test_incorrect_version_file_not_skipped(self):
+ self.assertFileCollected(NO_SKIP)
+ self.assertFileNotHasContent(NO_SKIP, '10.11.12.13')
+ self.assertFileNotHasContent(NO_SKIP, '6.0.0.1')
diff --git a/tests/test_data/fake_plugins/skip_versions.py b/tests/test_data/fake_plugins/skip_versions.py
new file mode 100644
index 00000000..e8a1d533
--- /dev/null
+++ b/tests/test_data/fake_plugins/skip_versions.py
@@ -0,0 +1,24 @@
+# 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.report.plugins import Plugin, IndependentPlugin
+
+
+class SkipVersions(Plugin, IndependentPlugin):
+ """Collect the fake version files from the test suite, to ensure proper
+ skipping of version files
+ """
+
+ plugin_name = 'skip_versions'
+ short_desc = 'fake plugin to test skipping version files via the IP parser'
+
+ def setup(self):
+ self.add_copy_spec([
+ '/tmp/sos-test-version.txt',
+ '/tmp/sos-test-version-noskip'
+ ])
diff --git a/tests/test_data/tmp/sos-test-version-noskip b/tests/test_data/tmp/sos-test-version-noskip
new file mode 100644
index 00000000..bc5558de
--- /dev/null
+++ b/tests/test_data/tmp/sos-test-version-noskip
@@ -0,0 +1,6 @@
+This is a test file for skipping version files with the IP parser.
+
+All dotted-quad strings SHOULD be changed in this file.
+
+10.11.12.13
+6.0.0.1
diff --git a/tests/test_data/tmp/sos-test-version.txt b/tests/test_data/tmp/sos-test-version.txt
new file mode 100644
index 00000000..62a96e57
--- /dev/null
+++ b/tests/test_data/tmp/sos-test-version.txt
@@ -0,0 +1,6 @@
+This is a test file for skipping version files with the IP parser.
+
+No dotted-quad strings should be changed in this file.
+
+10.11.12.13
+6.0.0.1