a qqeW@sddlZddlZddlmZmZmZmZmZddlm Z m Z ddl m Z m Z ddlmZmZddlmZmZmZmZddlmZGd d d e je jZdS) N)castIterableOptionalPatternUnion)mixinsquery)CriteriaDescriptorCriteriaSetDescriptor) InvalidType RuleUseError) AnyRBACRule RBACRuletypeRole TypeOrAttr)match_indirect_regexcseZdZUdZeedZeddZdZ e e d<dZ e e d<dZ eeeeefe d <dZe e d <dZe e d <ed d ZdZe e d <eddZdZe e d<eeeeeefdddZejeeeeefddddZddfdd ZeedddZ 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_roleFTsource_indirectN_target target_regextarget_indirect tclass_regexZ lookup_class default_regex)returncCs|jSN)r)selfr ;/usr/lib64/python3.9/site-packages/setools/rbacrulequery.pytarget:szRBACRuleQuery.target)valuerc Cst|s d|_nd|jr t||_nPz |jtttt f||_Wn.t yn|j tttt f||_Yn0dSr) rrrecompilepolicyZlookup_type_or_attrrrstrrr rr)rr#r r r!r">s  c s(tt|j|fi|tt|_dSr)superr__init__loggingZ getLogger__name__log)rr&kwargs __class__r r!r)JszRBACRuleQuery.__init__c cs:|jd||jd||jd||jd|||j|jd||jD]}|jr|j|jvrqp|jrt |j|j|j |j sqp|j rt |j |j |j |jsqpz||sWqpWntyYqpYn0|jr.zt |j|jd|jsWqpWnty,YqpYn0|VqpdS)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)r,infoformatdebugZ_match_object_class_debugr&Z rbacrulesruletypesourcerrrr"rrZ_match_object_classr defaultr)rZruler r r!resultsNsZ        zRBACRuleQuery.results)"r+ __module__ __qualname____doc__r rr3r r4rbool__annotations__rrrrrrrrrZtclassrr5rpropertyr"setterr'r)rrr6 __classcell__r r r.r!rs$            r)r*r$typingrrrrrrr Z descriptorsr r exceptionr r Z policyreprrrrutilrZ MatchObjClassZ PolicyQueryrr r r r!s