3 ^t@srddlZddlZddlmZmZddlmZmZddlm Z m Z ddl m Z ddl mZGdd d ejejZdS) N)mixinsquery)CriteriaDescriptorCriteriaSetDescriptor) InvalidType RuleUseError) RBACRuletype)match_indirect_regexcseZdZdZeedZeddZdZ dZ dZ dZ dZ edd ZdZed dZdZed d Zejd d ZfddZddZZS) 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_regexcCs|jS)N)_target)selfr%/usr/lib64/python3.6/rbacrulequery.pytargetGszRBACRuleQuery.targetc CsZ|s d|_nJ|jr tj||_n6y|jj||_Wn"tk rT|jj||_YnXdS)N)r target_regexrecompilepolicyZlookup_type_or_attrrr)rvaluerrrrKsc s$tt|j|f|tjt|_dS)N)superr __init__loggingZ getLogger__name__log)rrkwargs) __class__rrrWszRBACRuleQuery.__init__ccs>|jjdj||jjdj||jjdj||jjdj||j|j|jjdj|x|jjD]}|jr|j|jkrqr|jrt |j|j|j |j  rqr|j rt |j |j |j |j rqry|j|swrWntk rwrYnX|jr0yt |j|jd|jswrWntk r.wrYnX|VqrWdS)z/Generator which yields all matching RBAC rules.z,Generating RBAC rule results from {0.policy}zRuletypes: {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)rinfoformatdebugZ_match_object_class_debugrZ rbacrulesruletypesourcer source_indirectr rtarget_indirectrZ_match_object_classrdefaultr)rZrulerrrresults[sP        zRBACRuleQuery.results)r __module__ __qualname____doc__rr r%rr&r r'rrr(Ztclassrr)rpropertyrsetterrr* __classcell__rr)r!rr s       r )rrrrZ descriptorsrrZ exceptionrrZ policyrepr utilr Z MatchObjClassZ PolicyQueryr rrrrs