-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop when encountering exclamation mark symbol firstly for BIND9Parser #23
Comments
Nor does it match the supplied BIND9Parser regex given in this code snippet as fixed by Ajenti Issue 419: Regex debugger here. |
Related issue Ajenti #484 ajenti/ajenti#484 |
Updated bind9 tokens (which greatly speeds up from 27 minutes to 5 seconds) to as followed: tokens = [
(r"(masters)\s+?([^\s{}]*)\s+?(port|dscp)\s+?([^\s{}]*\s*)\s*(port|dscp)\s*?([^\s{}]*\s*)\s*{", lambda s, t: ('clause5_start', t)),
(r"(listen-on-v6|listen-on|masters)\s+?(port|dscp)\s+?([^\s{}]*\s*)\s*{", lambda s, t: ('clause3_start', t)),
(r"(channel|masters)\s+?([^\s{}]*\s*)\s*{", lambda s, t: ('clause1_start', t)),
(r"(acl|key|server)\s+?([^\s{}]*\s*)\s*{", lambda s, t: ('clause1_start', t)),
(r"(controls|logging|options)\s+?([^\s{}]*\s*)*{", lambda s, t: ('clause0_start', t)),
(r"(view|zone)\s+?([^\s{}]*)?\s+?([^\s{}]*)\s*{", lambda s, t: ('clause12_start', t)),
(r"(allow-notify|allow-query-on|allow-query|allow-recursion-on|allow-recursion|allow-transfer|allow-update-forwarding|allow|also-notify|alt-transfer-source-v6|alt-transfer-source|disable-algorithms|dual-stack-servers|forwarders|match-clients|match-destinations|rrset-order|sortlist|update-policy)\s+?([^\s{}]*\s*)*{", lambda s, t: ('statement_start', t)),
(r"\#.*?\n", lambda s, t: ('comment', t)),
(r"//.*?\n", lambda s, t: ('comment', t)),
(r"/\*.*?\*/", lambda s, t: ('comment', t)),
(r"((([^\s{};#]+)|({\s*([^\s{};#]+;\s*)*}))\s*?)+;", lambda s, t: ('option', t)),
(r"\s", lambda s, t: 'whitespace'),
(r"$^", lambda s, t: 'newline'),
(r"\};", lambda s, t: 'clause_end'),
] Test passes :~/work/python/reconfigure/reconfigure/reconfigure/tests$ pytest -v parsers/*_tests.py
============================= test session starts ==============================
platform linux -- Python 3.5.3, pytest-3.7.1, py-1.5.4, pluggy-0.7.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: ~/work/python/reconfigure/reconfigure, inifile:
collected 23 items
parsers/bind9_tests.py::BIND9ParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 4%]
parsers/bind9_tests.py::BIND9ParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 8%]
parsers/bind9_tests.py::BIND9ParserHangTest::test_hang PASSED [ 13%]
parsers/crontab_tests.py::CrontabParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 17%]
parsers/crontab_tests.py::CrontabParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 21%]
parsers/exports_tests.py::ExportsParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 26%]
parsers/exports_tests.py::ExportsParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 30%]
parsers/ini_tests.py::IniParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 34%]
parsers/ini_tests.py::IniParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 39%]
parsers/iptables_tests.py::IPTablesParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 43%]
parsers/iptables_tests.py::IPTablesParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 47%]
parsers/jsonparser_tests.py::JsonParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 52%]
parsers/jsonparser_tests.py::JsonParserTest::test_stringify PASSED [ 56%]
parsers/nginx_tests.py::NginxParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 60%]
parsers/nginx_tests.py::NginxParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 65%]
parsers/nsd_tests.py::BIND9ParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 69%]
parsers/nsd_tests.py::BIND9ParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 73%]
parsers/shell_tests.py::ShellParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 78%]
parsers/shell_tests.py::ShellParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 82%]
parsers/squid_tests.py::SquidParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 86%]
parsers/squid_tests.py::SquidParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [ 91%]
parsers/ssv_tests.py::SSVParserTest::test_parse <- reconfigure/tests/parsers/base_test.py PASSED [ 95%]
parsers/ssv_tests.py::SSVParserTest::test_stringify <- reconfigure/tests/parsers/base_test.py PASSED [100%]
========================== 23 passed in 0.83 seconds ===========================
~/work/python/reconfigure/reconfigure/reconfigure/tests$ |
I'm going to submit a bigger bind9_test to ensure that all bind9 version passes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When encountering the following content:
The infinite loop resides at the line:
Apparently, the exclamation mark is tripping that up when pressing
Ctrl-C
, as traceback shows:The loop is not stuck in the NginxParser(BaseParser), but in the following function:
According to the traceback, it is stuck in
match()
:Probably a bad regex. I realized that NginxParser is being used. I do think that
tokens
can be enhanced to allow exclamation mark.reconfigure/reconfigure/parsers/nginx.py
Line 24 in 2b8729a
The text was updated successfully, but these errors were encountered: