From d672f2504b5cdb0bf638aff0f43ccd45d0030ec5 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 23 Jul 2018 16:02:19 -0600 Subject: [PATCH] issue 2551: python3 issue loading disable.conf ... and likely other related files. The failing disable.conf has been added to the integration tests. Issue: https://redmine.openinfosecfoundation.org/issues/2551 --- CHANGELOG.md | 2 ++ suricata/update/main.py | 2 +- tests/integration_tests.py | 3 ++- tests/test_matchers.py | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9293ac..bf2914f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ https://redmine.openinfosecfoundation.org/issues/2549 - Fix interactive input for add-source command. https://redmine.openinfosecfoundation.org/issues/2550 +- Python fix for loading disable.conf (and other files). + https://redmine.openinfosecfoundation.org/issues/2551 ## 1.0.0rc1 - 2018-07-17 - Python 3 fixes. diff --git a/suricata/update/main.py b/suricata/update/main.py index e4c64ba..2bdf197 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -469,7 +469,7 @@ def parse_matchers(fileobj): matchers = [] for line in fileobj: - line = line.decode().strip() + line = line.strip() if not line or line.startswith("#"): continue line = line.rsplit(" #")[0] diff --git a/tests/integration_tests.py b/tests/integration_tests.py index f104e80..0c61e62 100755 --- a/tests/integration_tests.py +++ b/tests/integration_tests.py @@ -36,7 +36,8 @@ common_args = [ common_update_args = [ "--no-test", "--no-reload", - "--disable-conf", "./tests/empty", + "--suricata-conf", "./tests/suricata.yaml", + "--disable-conf", "./tests/disable.conf", "--enable-conf", "./tests/empty", "--drop-conf", "./tests/empty", "--modify-conf", "./tests/empty", diff --git a/tests/test_matchers.py b/tests/test_matchers.py index c0df407..f7966bb 100644 --- a/tests/test_matchers.py +++ b/tests/test_matchers.py @@ -56,10 +56,10 @@ class LoadMatchersTestCase(unittest.TestCase): def test_trailing_comment(self): """Test loading matchers with a trailing comment.""" - matchers = main.parse_matchers(io.BytesIO("""filename: */trojan.rules + matchers = main.parse_matchers(io.StringIO(u"""filename: */trojan.rules re:.# This is a comment* 1:100 # Trailing comment. -""".encode())) +""")) self.assertEquals( matchers[0].__class__, suricata.update.main.FilenameMatcher) self.assertEquals( -- 2.47.3