a qéqeWã@sšddlZddlZddlmZmZmZmZmZddlm Z m Z ddl m Z m Z ddlmZmZddlmZmZmZmZddlmZGd d „d e je jƒZdS) éN)ÚcastÚIterableÚOptionalÚPatternÚUnioné)ÚmixinsÚquery)ÚCriteriaDescriptorÚCriteriaSetDescriptor)Ú InvalidTypeÚ RuleUseError)Ú AnyRBACRuleÚ RBACRuletypeÚRoleÚ TypeOrAttr)Úmatch_indirect_regexcseZdZUdZeed�ZeddƒZdZ e e d<dZ e e d<dZ eeeeefe d <dZe e d <dZe e d <ed d ƒZdZe e d <eddƒZdZe e d<eeeeeefdœdd„ƒZejeeeeefddœdd„ƒZddœ‡fdd„ Zeedœdd„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_roleFTÚsource_indirectNÚ_targetÚ target_regexÚtarget_indirectÚ tclass_regexZ lookup_classÚ default_regex)ÚreturncCs|jS©N)r)Úself©r ú;/usr/lib64/python3.9/site-packages/setools/rbacrulequery.pyÚtarget:szRBACRuleQuery.target)Úvaluerc Cst|s d|_nd|jr t |¡|_nPz |j tttt f|ƒ¡|_Wn.t yn|j  tttt f|ƒ¡|_Yn0dSr) rrÚreÚcompileÚpolicyZlookup_type_or_attrrrÚstrrr rr)rr#r r r!r">s  c s(tt|ƒj|fi|¤Žt t¡|_dSr)ÚsuperrÚ__init__ÚloggingZ getLoggerÚ__name__Úlog)rr&Úkwargs©Ú __class__r r!r)JszRBACRuleQuery.__init__c cs:|j d |¡¡|j d |¡¡|j d |¡¡|j d |¡¡| |j¡|j d |¡¡|j ¡D]Ä}|jrˆ|j|jvrˆqp|jr¦t |j|j|j |j ƒs¦qp|j rÄt |j |j |j |jƒsÄqpz| |¡sÔWqpWntyìYqpYn0|j�r.zt |j|jd|jƒ�sWqpWnt�y,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,ÚinfoÚformatÚdebugZ_match_object_class_debugr&Z rbacrulesÚruletypeÚsourcerrrr"rrZ_match_object_classr Údefaultr)rZruler r r!ÚresultsNsZ ÿ ÿ  üü   ü zRBACRuleQuery.results)"r+Ú __module__Ú __qualname__Ú__doc__r rr3r r4rÚboolÚ__annotations__rrrrrrrrrZtclassrr5rÚpropertyr"Úsetterr'r)rrr6Ú __classcell__r r r.r!rs$            r)r*r$ÚtypingrrrrrÚrr Z descriptorsr r Ú exceptionr r Z policyreprrrrÚutilrZ MatchObjClassZ PolicyQueryrr r r r!Ús