Пример #1
0
optviewzone_stmt_auto_dnssec = (
    Keyword('auto-dnssec').suppress()
    + (
        (
            CaselessLiteral('allow')
            | CaselessLiteral('maintain')
            | CaselessLiteral('off')
        )
    )('auto_dnssec')
    + semicolon
)

optviewzone_stmt_dialup = (
    Keyword('dialup')
    - isc_boolean('dialup')
    + semicolon
)

optviewzone_stmt_dnssec_loadkeys_interval = (
    Keyword('dnssec-loadkeys-interval').suppress()
    + minute_type('dnssec_loadkeys_interval')
    + semicolon
)

# forward ( only | first ); [ Opt View Zone ]  # v8.1+
optviewzone_stmt_forward = (
    Keyword('forward').suppress()
    + (
        Literal('only')
        | Literal('first')
Пример #2
0
    inet_ip_port_keyword_and_number_element
from bind9_parser.isc_domain import domain_generic_fqdn,\
    domain_charset_alphanums_dash_underscore, domain_fqdn,\
    quoted_domain_generic_fqdn
from bind9_parser.isc_aml import  aml_nesting, aml_choices


options_stmt_acache_cleaning_interval = (
    Keyword('acache-cleaning-interval').suppress()
    - seconds_type('acache_cleaning_interval')
    + semicolon
)

options_stmt_acache_enable = (
    Keyword('acache-enable').suppress()
    - isc_boolean('acache-enable')
    + semicolon
)

options_stmt_answer_cookie = (
    Keyword('answer-cookie').suppress()
    - isc_boolean('answer-cookie')
    + semicolon
)

options_stmt_automatic_interface_scan = (
    Keyword('automatic-interface-scan').suppress()
    - isc_boolean('automatic_interface_scan')
    + semicolon
)
Пример #3
0
    inet_ip_port_keyword_and_wildcard_element,\
    inet_dscp_port_keyword_and_number_element

#  Be careful of deleting any statements here
#
#  Over times, 'server' clause is ALSO incorporating these
#  statements (which in turn gets included by 'view' clause)
#
#  In short, ISC architects are moving statements around.
#
#  Redundancy is necessary here.

#   bogus ( yes | no );  # [ server ]
server_stmt_bogus = (
    Keyword('bogus')
    - isc_boolean('bogus')
    + semicolon
)

#  edns ( yes | no);  # [ server ]
server_stmt_edns = (
    Keyword('edns')
    - isc_boolean('edns')
    + semicolon
)


#  edns-version <number>;  # [ server ]
server_stmt_edns_version = (
    Keyword('edns-version')
    - byte_type('edns_version')
Пример #4
0
from bind9_parser.isc_aml import aml_nesting
from bind9_parser.isc_trusted_keys import trusted_keys_statements_set

#   match-clients { aml; } ; [ View ]
view_stmt_match_clients = (
    Keyword('match-clients').suppress() -
    Group(aml_nesting(''))('match_clients'))(
        '')  # remove List label as 'match-clients' occurs exactly once

#  match-destinations { aml; } ; [ View ]
view_stmt_match_destinations = (
    Keyword('match-destinations').suppress() -
    Group(aml_nesting(''))('match_destinations'))(
        '')  # remove List label as 'match-destinations' occurs exactly once

#  match-recursive-only { boolean; } ; [ View ]
view_stmt_match_recursive_only = (Keyword('match-recursive-only').suppress() -
                                  isc_boolean('match_recursive_only') +
                                  semicolon)('')

# Keywords are in dictionary-order, but with longest pattern as having been listed firstly
view_statements_set = (
    view_stmt_match_recursive_only
    | view_stmt_match_destinations
    | view_stmt_match_clients
    # Don't put clause_stmt_trusted_keys here, you'll get a circular dependency at Python-level
    # Insert the clause_stmt_trusted_keys into isc_clause_view.py instead
)

view_statements_series = ZeroOrMore(view_statements_set)
Пример #5
0
                )  # never set a ResultsLabel here, you get duplicate but un-nested 'addr'
            )  # never set a ResultsLabel here, you get no []
        )(None))('aml') + rbrack
    # NOSEMICOLON HERE!
)('allow')

#  keys { key_id; [ ... ] };
controls_keys_element = (
    Keyword('keys').suppress() + lbrack +
    ZeroOrMore(Group(key_id(None) + semicolon)) + rbrack
    # NO SEMICOLON HERE!
)('keys')

#  read-only <boolean>
controls_inet_read_only_element = (
    Keyword('read-only').suppress() - isc_boolean('read-only')
    # NO SEMICOLON HERE!
)

#  inet
#      ( ip46_addr_or_prefix | * ) [ port ( ip_port | * ) ]
#      allow { <aml>; }
#      [ keys { key_id; [ ... ] } ]
#      [ read-only <boolean> ]
#      ;
controls_inet_set = Group(
    Keyword('inet').suppress() + controls_inet_addr_and_port(None) -
    controls_inet_allow_element(None) + Optional(controls_keys_element) +
    Optional(controls_inet_read_only_element) + semicolon)('inet')

controls_unix_set = (
Пример #6
0
    quotable_domain_generic_fqdn, quoted_domain_generic_fqdn, rr_fqdn_w_absolute
from bind9_parser.isc_viewzone import viewzone_stmt_database, viewzone_stmt_dlz
# from bind9_parser.isc_clause_masters import clause_stmt_masters_standalone

######## Zone statements #############################################
zone_stmt_check_names = (Keyword('check-names').suppress() -
                         check_options('check_names') + semicolon)

database_arg = path_name
zone_stmt_database_former = (
    Keyword('database').suppress() -
    Group(path_name - ZeroOrMore(database_arg('arg'))('args'))('') +
    semicolon)('database')

zone_stmt_delegation_only = (Keyword('delegation-only').suppress() -
                             isc_boolean('delegation-only') + semicolon)

zone_stmt_file = (Keyword('file').suppress() - path_name('file') + semicolon)

zone_stmt_in_view = (Keyword('in-view').suppress() - view_name('in_view') +
                     semicolon)

zone_stmt_inline_signing = (Keyword('inline-signing').suppress() -
                            isc_boolean('inline-signing') + semicolon)

# ixfr-base got obsoleted; 9.15.0 doesn't have it, might be before
zone_stmt_ixfr_base = (Keyword('ixfr-base').suppress() -
                       isc_file_name('ixfr_base') + semicolon)

zone_stmt_ixfr_from_differences = (
    Keyword('ixfr-from-differences').suppress() -
Пример #7
0
#!/usr/bin/env python3.7
"""
File: isc_optzone.py

Clause: options, zone

Title: Statements Used Only By options And zone Clauses.

Description: isc_optzone contains all parse elements pertaining
             to both options and zone (but not view)
"""
from pyparsing import Group, Keyword, OneOrMore
from bind9_parser.isc_utils import isc_boolean, semicolon, parse_me

optzone_stmt_notify_to_soa = (Keyword('notify-to-soa') -
                              isc_boolean('notify_to_soa') + semicolon)

# Keywords are in dictionary-order, but with longest pattern as
# having been listed firstly
optzone_statements_set = (optzone_stmt_notify_to_soa)

optzone_statements_series = (OneOrMore(optzone_statements_set))
Пример #8
0
    | Literal('error')
    | Literal('warning')
    | Literal('notice')
    | Literal('info')
    | Literal('dynamic')
    |
    (Literal('debug').suppress() - Optional(number_type(''))(''))('debug'))('')
logging_chan_syslog_severity_select.setName(
    'critical|error|warning|notice|info|debug <level>|dynamic')

logging_chan_syslog_severity_element = (Group(
    Keyword('severity').suppress() -
    logging_chan_syslog_severity_select)('severity') + semicolon)('')

logging_chan_print_category_element = (
    (Keyword('print-category').suppress() - isc_boolean('print_category')) +
    semicolon)

logging_chan_print_severity_element = (Keyword('print-severity').suppress() -
                                       isc_boolean('print_severity') +
                                       semicolon)

#  [ print-time ( iso8601 | iso8601-utc | local | <boolean>) ;  ]
logging_chan_print_time_element = (Keyword('print-time').suppress() -
                                   (Keyword('iso8601-utc')
                                    | Keyword('iso8601')
                                    | Keyword('local')
                                    | isc_boolean)('print_time') + semicolon)

#  [ buffered <boolean>; ]
logging_chan_buffered_element = (Keyword('buffered').suppress() -
Пример #9
0
"""
File: isc_optzone.py

Clause: options, zone

Title: Statements Used Only By options And zone Clauses.

Description: isc_optzone contains all parse elements pertaining
             to both options and zone (but not view)
"""
from pyparsing import Keyword, OneOrMore
from bind9_parser.isc_utils import isc_boolean, semicolon


optzone_stmt_notify_to_soa = (
    Keyword('notify-to-soa')
    - isc_boolean('notify_to_soa')
    + semicolon
)

# Keywords are in dictionary-order, but with longest pattern as
# having been listed firstly
optzone_statements_set = (
    optzone_stmt_notify_to_soa
)

optzone_statements_series = (
    OneOrMore(optzone_statements_set)
)

Пример #10
0
Description: Provides 'options' and 'server'-related grammar in
             PyParsing engine for ISC-configuration style
"""
from pyparsing import ZeroOrMore, Keyword, Literal
from bind9_parser.isc_utils import semicolon, isc_boolean, number_type

#  edns-udp-size <number>;  # [ server ]
optviewserver_stmt_edns_udp_size = (
    Keyword('edns-udp-size') -
    number_type('edns_udp_size')  # valid range is 512-4096
    + semicolon)

#  provide-ixfr ( yes | no) ; [ Opt, View, server ]
optviewserver_stmt_provide_ixfr = (Keyword('provide-ixfr') -
                                   isc_boolean('provide_ixfr') + semicolon)

#  request-ixfr <boolean>;  # [ server ]  # v9.1.0+
optviewserver_stmt_request_ixfr = (Keyword('request-ixfr') +
                                   isc_boolean('request_ixfr') + semicolon)

#  transfer-format ( 'one-answer' | 'many-answers' )  # [ server ]
optviewserver_stmt_transfer_format = (
    Keyword('transfer-format') +
    (Literal('one-answer')
     | Literal('many-answers'))('transfer_format') + semicolon)

# Keywords are in dictionary-order, but with longest pattern as
# having been listed firstly
optviewserver_statements_set = (optviewserver_stmt_provide_ixfr
                                | optviewserver_stmt_request_ixfr
Пример #11
0
#  alt-transfer-source-v6 ( ipv4_address | * ) [ port ( integer | * )];
optviewzone_stmt_alt_transfer_source_v6 = (
    Keyword('alt-transfer-source-v6').suppress() - Group(
        ((ip6_addr('ip6_addr')
          | Literal('*')) + Optional(inet_ip_port_keyword_and_wildcard_element)
         + Optional(inet_dscp_port_keyword_and_number_element))(''))
    ('alt_transfer_source_v6') + semicolon)('')

optviewzone_stmt_auto_dnssec = (Keyword('auto-dnssec').suppress() +
                                ((CaselessLiteral('allow')
                                  | CaselessLiteral('maintain')
                                  | CaselessLiteral('off')))('auto_dnssec') +
                                semicolon)

optviewzone_stmt_dialup = (Keyword('dialup') - isc_boolean('dialup') +
                           semicolon)

optviewzone_stmt_dnssec_loadkeys_interval = (
    Keyword('dnssec-loadkeys-interval').suppress() +
    minute_type('dnssec_loadkeys_interval') + semicolon)

# forward ( only | first ); [ Opt View Zone ]  # v8.1+
optviewzone_stmt_forward = (Keyword('forward').suppress() +
                            (Literal('only')
                             | Literal('first'))('forward') + semicolon)

forwarders_ip46_addr_prefix_port_element = (
    ip46_addr_or_prefix('addr') +
    Optional(inet_ip_port_keyword_and_number_element) +
    Optional(inet_dscp_port_keyword_and_number_element) + semicolon)
Пример #12
0
    ungroup
from bind9_parser.isc_utils import isc_boolean, semicolon, lbrack, rbrack, \
    squote, dquote, number_type, name_type, minute_type, seconds_type, \
    byte_type, parse_me, run_me, path_name, check_options, \
    quoted_path_name, size_spec, exclamation
from bind9_parser.isc_aml import aml_nesting, aml_choices
from bind9_parser.isc_inet import ip4_addr, ip6_addr, \
    inet_ip_port_keyword_and_number_element, \
    inet_ip_port_keyword_and_wildcard_element
from bind9_parser.isc_zone import zone_name
from bind9_parser.isc_domain import quoted_domain_generic_fqdn, \
    domain_generic_fqdn, rr_fqdn_w_absolute

optview_stmt_acache_cleaning_interval = (
    Keyword('acache-cleaning-interval').suppress() -
    isc_boolean('acache_cleaning_interval') + semicolon)

optview_stmt_acache_enable = (Keyword('acache-enable').suppress() -
                              isc_boolean('acache_enable') + semicolon)

optview_stmt_additional_from_auth = (
    Keyword('additional-from-auth').suppress() -
    isc_boolean('additional_from_auth') + semicolon)

optview_stmt_additional_from_cache = (
    Keyword('additional-from-cache').suppress() -
    isc_boolean('additional_from_cache') + semicolon)

# allow-new-zones <boolean>; [ Opt View ]  # v9.5.0+
optview_stmt_allow_new_zones = (Keyword('allow-new-zones').suppress() -
                                isc_boolean('allow_new_zones') + semicolon)
Пример #13
0
Title: Clause statement for the DLZ

Description:
"""

from pyparsing import Group, CaselessKeyword, alphanums, Word, ZeroOrMore, OneOrMore
from bind9_parser.isc_utils import semicolon, name_type, isc_boolean, \
        lbrack, rbrack, dlz_name_type,\
        path_name

#  database <string>;
dlz_database_element = (CaselessKeyword('database').suppress() -
                        path_name('db_args') + semicolon)

#  search <boolean>;
dlz_search_element = (CaselessKeyword('search').suppress() -
                      isc_boolean('search') + semicolon)

# At the moment, orderings matter: 'database' first, then 'search'
dlz_element_group = ((dlz_search_element + dlz_database_element)
                     | (dlz_database_element + dlz_search_element))

#  dlz <string> { database <string>; search <boolean>; };  [ DLZ ]
clause_stmt_dlz_standalone = (CaselessKeyword('dlz').suppress() - Group(
    dlz_name_type('dlz_name') - lbrack - OneOrMore(dlz_element_group('')) +
    rbrack) + semicolon)('dlz')

clause_stmt_dlz_series = (ZeroOrMore(clause_stmt_dlz_standalone))('dlz')

#  See isc_viewzone.dlz for a simplified version of 'dlz <string>;' option