From 5c273476934bc5011ef4f377fd1ebbb51d4385ab Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 13 Oct 2022 17:31:37 +0900 Subject: [PATCH 1/3] test: improve assertion message on failure Suggested by CodeQL#169 (https://github.com/systemd/systemd/security/code-scanning/169). --- test/test-exec-deserialization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-exec-deserialization.py b/test/test-exec-deserialization.py index 06a7d369f6..08307b18d7 100755 --- a/test/test-exec-deserialization.py +++ b/test/test-exec-deserialization.py @@ -200,7 +200,7 @@ class ExecutionResumeTest(unittest.TestCase): self.reload() time.sleep(5) - self.assertTrue(subprocess.call("journalctl -b _PID=1 | grep -q 'Freezing execution'", shell=True) != 0) + self.assertNotEqual(subprocess.call("journalctl -b _PID=1 | grep -q 'Freezing execution'", shell=True), 0) def tearDown(self): for f in [self.output_file, self.unitfile_path]: From f9d1709c0314f4ffa6d192debf566f2be8520aa6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 13 Oct 2022 17:34:08 +0900 Subject: [PATCH 2/3] test: drop unused modules Suggested by CodeQL#167 (https://github.com/systemd/systemd/security/code-scanning/167) and CodeQL#168 (https://github.com/systemd/systemd/security/code-scanning/168). --- test/rule-syntax-check.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 9a9e4d1658..ec1c75a854 100755 --- a/test/rule-syntax-check.py +++ b/test/rule-syntax-check.py @@ -8,8 +8,6 @@ import re import sys -import os -from glob import glob rules_files = sys.argv[1:] if not rules_files: From 74522aa87fc31f448248c8a37afc73a8fd9d6f65 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 13 Oct 2022 17:41:45 +0900 Subject: [PATCH 3/3] test: introduce __eq__() and __ne__() Suggested by CodeQL#160 (https://github.com/systemd/systemd/security/code-scanning/160). --- test/sd-script.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/sd-script.py b/test/sd-script.py index 7662b12ab8..51ebf70c39 100644 --- a/test/sd-script.py +++ b/test/sd-script.py @@ -100,6 +100,12 @@ class SD(object): def __cmp__(self, other): return cmp(self._num, other._num) + def __eq__(self, other): + return self.__cmp__(other) == 0 + + def __ne__(self, other): + return not self.__eq__(other) + def __hash__(self): return hash(self._num)