Sindbad~EG File Manager

Current Path : /usr/lib64/python3.6/site-packages/setools/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/setools/__pycache__/nodeconquery.cpython-36.pyc

3

�^��@sZddlZddlZddlmZmZddlmZddlmZddl	m
Z
Gdd�dee
�ZdS)	�N)�AF_INET�AF_INET6�)�MatchContext)�NodeconIPVersion)�PolicyQuerycsheZdZdZdZdZdZedd��Zej	dd��Zedd��Z
e
j	d	d��Z
�fd
d�Zdd
�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.
    NFcCs|jS)N)�_ip_version)�self�r�$/usr/lib64/python3.6/nodeconquery.py�
ip_versionFszNodeconQuery.ip_versioncCs|rtj|�|_nd|_dS)N)r�lookupr	)r
�valuerrrr
JscCs|jS)N)�_network)r
rrr�networkQszNodeconQuery.networkcCs|rtj|�|_nd|_dS)N)�	ipaddressZ
ip_networkr)r
rrrrrUscs$tt|�j|f|�tjt�|_dS)N)�superr�__init__�loggingZ	getLogger�__name__�log)r
�policy�kwargs)�	__class__rrr\szNodeconQuery.__init__ccs�|jjdj|��|jjdj|��|jjdj|��|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|VqNWdS)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_debugrZnodeconsr�network_overlapZoverlapsr
Z_match_context�context)r
Znodeconrrr�results`s zNodeconQuery.results)r�
__module__�__qualname__�__doc__rrr	�propertyr
�setterrrr �
__classcell__rr)rrrs"r)rrZsocketrrZmixinsrZ	policyreprZqueryrrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists