a qqe@sddlmZmZmZmZddlmZmZmZddl m Z ddl m Z m Z ddlmZGdd d eZGd d d e ZGd d d e eZdS))castList NamedTupleOptional)BoundsBoundsRuletypeType)DiffResultDescriptor) DifferenceWrapper)type_wrapper_factoryc@s*eZdZUdZeed<eed<eed<dS)ModifiedBoundsz.Difference details for a modified bounds rule.ruleZ added_boundZ removed_boundN)__name__ __module__ __qualname____doc__r__annotations__r rr9/usr/lib64/python3.9/site-packages/setools/diff/bounds.pyrs rc@s|eZdZUdZedZedZedZdZe e e e d<dZ e e e e d<ddddZddd d Zddd d ZdS) BoundsDifferencez9Determine the difference in *bounds between two policies.diff_typeboundsN_left_typebounds_right_typebounds)returncCs|jd||jdus&|jdur.||jddttt |jDddttt |jDddd\|_ |_ }g|_ |D]4\}}t |jt |jkr|j t||j|jqdS) z@Generate the difference in typebound rules between the policies.zJGenerating typebounds differences from {0.left_policy} to {0.right_policy}Ncss|]}t|VqdSN BoundsWrapper.0crrr -z3BoundsDifference.diff_typebounds..css|]}t|VqdSrrr rrrr#.r$cSs t|jSr)strchild)brrr/r$z2BoundsDifference.diff_typebounds..key)loginfoformatrr_create_typebound_listsZ _set_diffrrradded_typeboundsremoved_typeboundsmodified_typeboundsrparentappendr)selfZmatched_typeboundsZ left_boundZ right_boundrrrr#s    z BoundsDifference.diff_typeboundscCsg|_|jD]2}|jtjkr.|j|q|jd |jqg|_ |j D]2}|jtjkrr|j |qT|jd |jqTdS)z$Create rule lists for both policies.z/Unknown rule type: {0} (This is an SETools bug)N) rZ left_policyZboundsruletyperZ typeboundsr3r+errorr-rZ right_policyr4rrrrr.;s    z(BoundsDifference._create_typebound_listscCs(|jdd|_d|_d|_d|_dS)z%Reset diff results on policy changes.z!Resetting all *bounds differencesN)r+debugr/r0rrr4rrr _reset_diffMs  zBoundsDifference._reset_diff)rrrrr r/r0r1rrrrrrrr.r:rrrrrs rc@s<eZdZdZdZeddddZddZd d Zd d Z dS) rzWrap *bounds for diff purposes.)r5r2r&N)rrcCs4||_|j|_t|j|_t|j|_t||_dSr)originr5rr2r&hashr*r7rrr__init__^s   zBoundsWrapper.__init__cCs|jSrr)r9rrr__hash__eszBoundsWrapper.__hash__cCs |j|jkSrr)r4otherrrr__lt__hszBoundsWrapper.__lt__cCs|j|jko|j|jkSr)r5r&r?rrr__eq__ks  zBoundsWrapper.__eq__) rrrr __slots__rr=r>rArBrrrrrXs rN)typingrrrrZ policyreprrr Z descriptorsr differencer r typesrrrrrrrrs   A