3 ^h@stddlmZddlmZddlmZddlmZmZddl m Z edd d d gZ Gd d d eZ GdddeZ dS)) namedtuple)BoundsRuletype)DiffResultDescriptor) DifferenceWrapper)type_wrapper_factoryZmodified_boundruleZ added_boundZ removed_boundc@sHeZdZdZedZedZedZdZdZ ddZ ddZ dd Z dS) BoundsDifferencez9Determine the difference in *bounds between two policies.diff_typeboundsNcCs|jjdj||jdks&|jdkr.|j|jdd|jDdd|jDddd\|_|_}g|_ x<|D]4\}}t |j t |j krp|j j t ||j |j qpWdS) z@Generate the difference in typebound rules between the policies.zJGenerating typebounds differences from {0.left_policy} to {0.right_policy}Ncss|]}t|VqdS)N) BoundsWrapper).0cr/usr/lib64/python3.6/bounds.py 5sz3BoundsDifference.diff_typebounds..css|]}t|VqdS)N)r )rrrrrr6scSs t|jS)N)strchild)brrr7sz2BoundsDifference.diff_typebounds..)key)loginfoformat_left_typebounds_right_typebounds_create_typebound_listsZ _set_diffadded_typeboundsremoved_typeboundsmodified_typeboundsr parentappendmodified_bounds_record)selfZmatched_typeboundsZ left_boundZ right_boundrrrr +s z BoundsDifference.diff_typeboundscCsg|_x@|jjD]2}|jtjkr0|jj|q|jjdj |jqWg|_ x@|j jD]2}|jtjkrx|j j|qZ|jjdj |jqZWdS)z$Create rule lists for both policies.z/Unknown rule type: {0} (This is an SETools bug)N) rZ left_policyZboundsruletyperZ typeboundsr"rerrorrrZ right_policy)r$r rrrrCs    z(BoundsDifference._create_typebound_listscCs(|jjdd|_d|_d|_d|_dS)z%Reset diff results on policy changes.z!Resetting all *bounds differencesN)rdebugrrrr)r$rrr _reset_diffUs  zBoundsDifference._reset_diff) __name__ __module__ __qualname____doc__rrrr rrr rr(rrrrr sr c@s4eZdZdZdZddZddZd d Zd d Zd S)r zWrap *bounds for diff purposes.r%r!rcCs4||_|j|_t|j|_t|j|_t||_dS)N)originr%r r!rhashr)r$r rrr__init__fs   zBoundsWrapper.__init__cCs|jS)N)r)r$rrr__hash__mszBoundsWrapper.__hash__cCs |j|jkS)N)r)r$otherrrr__lt__pszBoundsWrapper.__lt__cCs|j|jko|j|jkS)N)r%r)r$r1rrr__eq__ss zBoundsWrapper.__eq__N)r%r!r) r)r*r+r, __slots__r/r0r2r3rrrrr `s r N) collectionsrZ policyreprZ descriptorsr differencerrtypesr r#r r rrrrs    A