From: Jason Ish Date: Tue, 8 Apr 2025 22:26:14 +0000 (-0600) Subject: cleanups: apply valid cleanups suggested by copilot X-Git-Tag: 1.3.5~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90302d6877bbc6cc0c762a9432eda31bbe972524;p=thirdparty%2Fsuricata-update.git cleanups: apply valid cleanups suggested by copilot Add test for gid/sed/rev that shouldn't match. --- diff --git a/suricata/update/main.py b/suricata/update/main.py index 8b893f2..f94d7c2 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -1409,7 +1409,8 @@ def _main(): else: logger.info("Reload command returned: {}".format(output.decode("utf-8"))) except Exception as err: - logger.error("Reload command failed: {}".format(err.output)) + logger.error("Reload command failed: {}".format( + getattr(err, 'output', str(err)))) logger.info("Done.") diff --git a/suricata/update/matchers.py b/suricata/update/matchers.py index 9cbf1fa..6e6515e 100644 --- a/suricata/update/matchers.py +++ b/suricata/update/matchers.py @@ -76,7 +76,7 @@ class IdRuleMatcher(object): def __init__(self, generatorId=None, signatureId=None, rev=None): self.signatureIds = [] - if generatorId and signatureId and rev: + if generatorId and signatureId and rev is not None: self.signatureIds.append((generatorId, signatureId, rev)) elif generatorId and signatureId: self.signatureIds.append((generatorId, signatureId)) diff --git a/tests/test_matchers.py b/tests/test_matchers.py index adaec72..07b27fb 100644 --- a/tests/test_matchers.py +++ b/tests/test_matchers.py @@ -113,6 +113,7 @@ class IdRuleMatcherTestCase(unittest.TestCase): self.assertIsNotNone(matcher) self.assertEqual(1, len(matcher.signatureIds)) self.assertEqual(matcher.signatureIds[0], (1, 234, 5)) + self.assertNotEqual(matcher.signatureIds[0], (1, 234, 0)) class MetadataAddTestCase(unittest.TestCase):