Closed garand43 closed 2 years ago
In commit beeee2382a564ba2ba4189cc0aa91ac7afc9be3e, fixed that.
Also saved your example in https://github.com/egberts/bind9_parser/blob/master/tests/bug-reports/github-issue-12.named.conf
Wrapped that config with options { ... };
and quick tested using the following script tester:
$ ./dump-named-conf.py tests/bug-reports/github-issue-12.named.conf
print(result.asDict()):
{'options': [{'disable_algorithms': [{'algorithm_list': ['RSAMD5',
'DSA'],
'domain_name': '"."'}],
'disable_ds_digests': [{'digest_list': ['GOST'],
'domain_name': '"."'}]}]}
end of result.
Hello,
I recently found your module to try and programmatically examine the BIND config files. This environment specifics are below.
OS - CentOS 8 BIND - 9.11.13-6 Python - 3.6.8 bind9-parser - 0.9.8 (installed via pip3) parse_bind9.py from the master branch on github.
The parse_bind9.py example script is throwing errors when trying to process the the named.conf file. In particular it is complaining about:
options { ... memstatistics-file "/var/named/data/named_mem_stats.txt"; ... include "/etc/crypto-policies/back-ends/bind.config"; ... }
The named_mem_stats.txt file does not exist, but shows this exception
Opening /etc/named.rfc1912.zones Opening /etc/named.root.key Start: Is the library quiet? pyparsing.ParseException: Expected, found '-' (at char 576), (line:20, col:22)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/tsl/github/bind9_parser/examples/parse_bind9.py", line 269, in
result = my_clauses.parseString(toplevel_config, parseAll=True)
File "/usr/local/lib/python3.6/site-packages/pyparsing.py", line 1955, in parseString
raise exc
File "/usr/local/lib/python3.6/site-packages/pyparsing.py", line 4065, in parseImpl
raise ParseSyntaxException._from_exception(pe)
pyparsing.ParseSyntaxException: Expected , found '-' (at char 576), (line:20, col:22)
The bind.config does exist and has the following contents:
disable-algorithms "." { RSAMD5; DSA; }; disable-ds-digests "." { GOST; };
Attempting to parse that file gives:
Opening /etc/crypto-policies/back-ends/bind.config Opening /etc/named.rfc1912.zones Opening /etc/named.root.key Start: Is the library quiet? pyparsing.ParseException: Expected "}", found 'd' (at char 1841), (line:49, col:1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/tsl/github/bind9_parser/examples/parse_bind9.py", line 269, in
result = my_clauses.parseString(toplevel_config, parseAll=True)
File "/usr/local/lib/python3.6/site-packages/pyparsing.py", line 1955, in parseString
raise exc
File "/usr/local/lib/python3.6/site-packages/pyparsing.py", line 4065, in parseImpl
raise ParseSyntaxException._from_exception(pe)
pyparsing.ParseSyntaxException: Expected "}", found 'd' (at char 1841), (line:49, col:1)
Commenting both those lines out of the configuration allows the script to parse the the main config files.