
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
^t                 @   sr   d dl Z d dlZddlmZmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ G dd	 d	ejejZdS )
    N   )mixinsquery)CriteriaDescriptorCriteriaSetDescriptor)InvalidTypeRuleUseError)RBACRuletype)match_indirect_regexc                   s   e Zd ZdZeedZeddZdZ	dZ
dZdZdZedd	ZdZed
dZdZedd Zejdd Z fddZdd Z  ZS )RBACRuleQuerya  
    Query the RBAC rules.

    Parameter:
    policy            The policy to query.

    Keyword Parameters/Class attributes:
    ruletype        The list of rule type(s) to match.
    source          The name of the source role/attribute to match.
    source_indirect If true, members of an attribute will be
                    matched rather than the attribute itself.
    source_regex    If true, regular expression matching will
                    be used on the source role/attribute.
                    Obeys the source_indirect option.
    target          The name of the target role/attribute to match.
    target_indirect If true, members of an attribute will be
                    matched rather than the attribute itself.
    target_regex    If true, regular expression matching will
                    be used on the target role/attribute.
                    Obeys target_indirect option.
    tclass          The object class(es) to match.
    tclass_regex    If true, use a regular expression for
                    matching the rule's object class.
    default         The name of the default role to match.
    default_regex   If true, regular expression matching will
                    be used on the default role.
    )
enum_classsource_regexlookup_roleFTNtclass_regexZlookup_classdefault_regexc             C   s   | j S )N)_target)self r   %/usr/lib64/python3.6/rbacrulequery.pytargetG   s    zRBACRuleQuery.targetc             C   sZ   |sd | _ nJ| jr tj|| _ n6y| jj|| _ W n" tk
rT   | jj|| _ Y nX d S )N)r   target_regexrecompilepolicyZlookup_type_or_attrr   r   )r   valuer   r   r   r   K   s    c                s$   t t| j|f| tjt| _d S )N)superr   __init__loggingZ	getLogger__name__log)r   r   kwargs)	__class__r   r   r   W   s    zRBACRuleQuery.__init__c             c   s>  | j jdj|  | j jdj|  | j jdj|  | j jdj|  | j| j  | j jdj|  x| jj D ]}| jr|j| jkrqr| jrt	|j| j| j
| j rqr| jrt	|j| j| j| j rqry| j|swrW n tk
r   wrY nX | jr0yt	|j| jd| jswrW n tk
r.   wrY nX |V  qrW dS )z/Generator which yields all matching RBAC rules.z,Generating RBAC rule results from {0.policy}zRuletypes: {0.ruletype}zLSource: {0.source!r}, indirect: {0.source_indirect}, regex: {0.source_regex}zLTarget: {0.target!r}, indirect: {0.target_indirect}, regex: {0.target_regex}z0Default: {0.default!r}, regex: {0.default_regex}TN)r   infoformatdebugZ_match_object_class_debugr   Z	rbacrulesruletypesourcer
   source_indirectr   r   target_indirectr   Z_match_object_classr   defaultr   )r   Zruler   r   r   results[   sP    





zRBACRuleQuery.results)r   
__module____qualname____doc__r   r	   r%   r   r&   r   r'   r   r   r(   Ztclassr   r)   r   propertyr   setterr   r*   __classcell__r   r   )r!   r   r      s    



r   )r   r    r   r   Zdescriptorsr   r   Z	exceptionr   r   Z	policyrepr	   utilr
   ZMatchObjClassZPolicyQueryr   r   r   r   r   <module>   s   