3
í«„^¥ ã @ sZ d dl Z d dlZd dlmZmZ ddlmZ ddlmZ ddl m
Z
G dd„ dee
ƒZdS ) é N)ÚAF_INETÚAF_INET6é )ÚMatchContext)ÚNodeconIPVersion)ÚPolicyQueryc sh e Zd ZdZdZdZdZedd„ ƒZej dd„ ƒZedd„ ƒZ
e
j d d„ ƒZ
‡ fd
d„Zdd
„ Z‡ Z
S )ÚNodeconQueryaI
Query nodecon statements.
Parameter:
policy The policy to query.
Keyword Parameters/Class attributes:
network The IPv4/IPv6 address or IPv4/IPv6 network address
with netmask, e.g. 192.168.1.0/255.255.255.0 or
"192.168.1.0/24".
network_overlap If true, the net will match if it overlaps with
the nodecon's network instead of equality.
ip_version The IP version of the nodecon to match. (socket.AF_INET
for IPv4 or socket.AF_INET6 for IPv6)
user The criteria to match the context's user.
user_regex If true, regular expression matching
will be used on the user.
role The criteria to match the context's role.
role_regex If true, regular expression matching
will be used on the role.
type_ The criteria to match the context's type.
type_regex If true, regular expression matching
will be used on the type.
range_ The criteria to match the context's range.
range_subset If true, the criteria will match if it is a subset
of the context's range.
range_overlap If true, the criteria will match if it overlaps
any of the context's range.
range_superset If true, the criteria will match if it is a superset
of the context's range.
range_proper If true, use proper superset/subset operations.
No effect if not using set operations.
NFc C s | j S )N)Ú_ip_version)Úself© r ú$/usr/lib64/python3.6/nodeconquery.pyÚ
ip_versionF s zNodeconQuery.ip_versionc C s |rt j|ƒ| _nd | _d S )N)r Úlookupr )r
Úvaluer r r r
J s c C s | j S )N)Ú_network)r
r r r ÚnetworkQ s zNodeconQuery.networkc C s |rt j|ƒ| _nd | _d S )N)Ú ipaddressZ
ip_networkr )r
r r r r r U s c s$ t t| ƒj|f|Ž tjtƒ| _d S )N)Úsuperr Ú__init__ÚloggingZ getLoggerÚ__name__Úlog)r
ÚpolicyÚkwargs)Ú __class__r r r \ s zNodeconQuery.__init__c c s® | j jdj| ƒƒ | j jdj| ƒƒ | j jdj| ƒƒ | j| j ƒ xf| jjƒ D ]X}| jr~| jrp| jj |jƒs~qNn|j| jks~qN| j
r’| j
|j
kr’qN| j|jƒs qN|V qNW dS )z-Generator which yields all matching nodecons.z*Generating nodecon results from {0.policy}z4Network: {0.network!r}, overlap: {0.network_overlap}zIP Version: {0.ip_version!r}N)
r ÚinfoÚformatÚdebugZ_match_context_debugr Znodeconsr Únetwork_overlapZoverlapsr
Z_match_contextÚcontext)r
Znodeconr r r Úresults` s zNodeconQuery.results)r Ú
__module__Ú__qualname__Ú__doc__r r r Úpropertyr
Úsetterr r r Ú
__classcell__r r )r r r s "r )r r Zsocketr r Zmixinsr Z policyrepr Zqueryr r r r r r Ú