+
        !                         ^ RI Ht ^RIHt ^RIHt ^RIHtHtH	t	 ^RI
Ht ^RIHt  ! R R]4      t ! R	 R
]	]P                  ,          4      tR# )    )defaultdict)	policyrep)DiffResultDescriptor)
DifferenceSymbolWrapperWrapper)class_wrapper_factory)RuleListc                   4  a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 lt]	]
P                  ,          ! ]4      t]	]
P                  ,          ! ]4      t]	]
P                  ,          ! ]4      t]	]
P                  ,          ! ]4      t]	]
P                   ,          ! ]4      t]	]
P                   ,          ! ]4      t]	]
P                   ,          ! ]4      t]	]
P                   ,          ! ]4      tR
tR
tV 3R lR ltV 3R lR ltV 3R ltRtV tR
# )ConstraintsDifferenceaV  
Determine the difference in constraints between two policies.

Since the compiler does not union constraints, there may be multiple
constraints with the same ruletype, object class, and permission
set, so constraints can only be added or removed, not modified.

The constraint expressions are compared only on a basic level.
Expressions that are logically equivalent but are structurally
different, for example, by associativity, will be considered
different.  Type and role attributes are also not expanded,
so if there are changes to attribute members, it will not
be reflected as a difference.
c                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "?/usr/lib64/python3.14/site-packages/setools/diff/constraints.py__annotate__"ConstraintsDifference.__annotate__!   s     : : :    c                   V P                   P                  RV P                   RV P                   24       V P                  e   V P
                  f   V P                  4        V P                  f   Q R4       hV P
                  f   Q R4       hV P                  R V P                  \        P                  P                  ,           4       R V P
                  \        P                  P                  ,           4       4      w  V n        V n        pR# )zAGenerate the difference in constraint rules between the policies.z'Generating constraint differences from  to N)Left constraints didn't load, this a bug.*Right constraints didn't load, this a bug.c              3   8   "   T F  p\        V4      x  K  	  R # 5iNConstraintWrapper.0cs   & r   	<genexpr>8ConstraintsDifference.diff_constrains.<locals>.<genexpr>.   !      9 ,8aq!! ,8   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   r$   0   r%   r&   )loginfoleft_policyright_policy_left_constraints_right_constraints_create_constrain_lists	_set_diffr   ConstraintRuletype	constrainadded_constrainsremoved_constrainsself_s   & r   diff_constrains%ConstraintsDifference.diff_constrains!   s     	5d6F6F5GtDL]L]K^_	a !!)T-D-D-L((*%%1^3^^1&&2`4``2<@NN94+A+A,,66,8 994+B+B,,66,8 9=:9t6r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   3   s     = =D =r   c                   V P                   P                  RV P                   RV P                   24       V P                  e   V P
                  f   V P                  4        V P                  f   Q R4       hV P
                  f   Q R4       hV P                  R V P                  \        P                  P                  ,           4       R V P
                  \        P                  P                  ,           4       4      w  V n        V n        pR# )zEGenerate the difference in MLS constraint rules between the policies.z+Generating MLS constraint differences from r   Nr   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   ;ConstraintsDifference.diff_mlsconstrains.<locals>.<genexpr>A   !      < ,;aq!! ,;r&   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   r<   C   r=   r&   )r(   r)   r*   r+   r,   r-   r.   r/   r   r0   mlsconstrainadded_mlsconstrainsremoved_mlsconstrainsr4   s   & r   diff_mlsconstrains(ConstraintsDifference.diff_mlsconstrains3   s     	9$:J:J9K L##$&	' !!)T-D-D-L((*%%1^3^^1&&2`4``2BF..<4+A+A,,99,; <<4+B+B,,99,; <C=? $"<ar   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   F   s     > >D >r   c                   V P                   P                  RV P                   RV P                   24       V P                  e   V P
                  f   V P                  4        V P                  f   Q R4       hV P
                  f   Q R4       hV P                  R V P                  \        P                  P                  ,           4       R V P
                  \        P                  P                  ,           4       4      w  V n        V n        pR# )zDGenerate the difference in validatetrans rules between the policies.z*Generating validatetrans differences from r   Nr   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   ;ConstraintsDifference.diff_validatetrans.<locals>.<genexpr>S   !      = ,<aq!! ,<r&   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   rG   U   rH   r&   )r(   r)   r*   r+   r,   r-   r.   r/   r   r0   validatetransadded_validatetransremoved_validatetransr4   s   & r   diff_validatetrans(ConstraintsDifference.diff_validatetransF   s     	89I9I8J$tO`O`Nab	d !!)T-D-D-L((*%%1^3^^1&&2`4``2BF..=4+A+A,,::,< ==4+B+B,,::,< =C>? $"<ar   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   X   s     A At Ar   c                   V P                   P                  RV P                   RV P                   24       V P                  e   V P
                  f   V P                  4        V P                  f   Q R4       hV P
                  f   Q R4       hV P                  R V P                  \        P                  P                  ,           4       R V P
                  \        P                  P                  ,           4       4      w  V n        V n        pR# )zHGenerate the difference in MLS validatetrans rules between the policies.z-Generating mlsvalidatetrans differences from r   Nr   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   >ConstraintsDifference.diff_mlsvalidatetrans.<locals>.<genexpr>f   "      @ ,?aq!! ,?r&   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r   r    s   & r   r#   rR   h   rS   r&   )r(   r)   r*   r+   r,   r-   r.   r/   r   r0   mlsvalidatetransadded_mlsvalidatetransremoved_mlsvalidatetransr4   s   & r   diff_mlsvalidatetrans+ConstraintsDifference.diff_mlsvalidatetransX   s     	;D<L<L;M N##$&	' !!)T-D-D-L((*%%1^3^^1&&2`4``2HL@4+A+A,,==,? @@4+B+B,,==,? @IAE#T%BAr   Nc                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   ~   s     D D Dr   c                   \        \        4      V n        V P                  P	                  RV P
                   24       V P
                  P                  4        F/  pV P                  VP                  ,          P                  V4       K1  	  V P                  P                  4        F0  w  r#V P                  P	                  R\        V4       RV R24       K2  	  \        \        4      V n        V P                  P	                  RV P                   24       V P                  P                  4        F/  pV P                  VP                  ,          P                  V4       K1  	  V P                  P                  4        F0  w  r#V P                  P	                  R\        V4       RV R24       K2  	  V P                  P	                  R4       R# )z$Create rule lists for both policies.zBuilding constraint lists from zLoaded  z rules.z)Completed building constraint rule lists.N)r   listr,   r(   debugr*   constraintsruletypeappenditemslenr-   r+   )r5   ruler`   ruless   &   r   r.   -ConstraintsDifference._create_constrain_lists~   s[   !,T!289I9I8JKL$$002D""4==188> 3  $55;;=OHHHNNWSZL(7CD  > #.d"389J9J8KLM%%113D##DMM299$? 4  $66<<>OHHHNNWSZL(7CD  ? 	BCr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     ' 'T 'r   c                x    V P                   P                  R4       V =V =V =V =V =V =V =V =	RV n
        RV n        R# )z%Reset diff results on policy changes.z%Resetting all constraints differencesN)r(   r^   r2   r3   r@   rA   rK   rL   rV   rW   r,   r-   r5   s   &r   _reset_diff!ConstraintsDifference._reset_diff   sU    >?!#$&$&') "&"&r   c                   < V ^8  d   Qh/ S[ S[P                  S[P                  3,          ;R&   S[ S[P                  S[P                  3,          ;R&   # )r   r,   r-   )r
   r   r0   AnyConstraint)r   r   s   "r   r   r      sO     P  	 < <i>U>U UV]Q R !!=!=y?V?V!VW^S r   )
r,   r-   r2   r@   rV   rK   r3   rA   rW   rL   )__name__
__module____qualname____firstlineno____doc__r7   rB   rM   rX   r   r   
Constraintr2   r3   r@   rA   ValidatetransrK   rL   rV   rW   r,   r-   r.   rj   __annotate_func____static_attributes____classdictcell__r   s   @r   r   r      s    : :$= =&> >$A A& ,I,@,@A/R-i.B.BCOT.y/C/CDEWX01E1EFGYZ.y/F/FGHZ[01H1HIJ\]1)2I2IJK`a3I4K4KLMbc Z^Z^
D D(' 'E  r   r   c                   L   a  ] tR t^t o RtR	tV 3R lR ltR tR tR t	Rt
V tR# )
r   z#Wrap constraints for diff purposes.c                8   < V ^8  d   QhRS[ P                  RR/# )r   rd   r   N)r   rm   )r   r   s   "r   r   ConstraintWrapper.__annotate__   s!     % %Y44 % %r   c                   Wn         VP                  V n        \        VP                  4      V n        V   VP                  V n        \        V4      V n        . V n        VP                   Fa  p\        V\        4      '       d.   V P                  P                  \        R V 4       4      4       KF  V P                  P                  V4       Kc  	  R #   \
         d    R T n         Li ; i)Nc              3   8   "   T F  p\        V4      x  K  	  R # 5ir   )r   )r!   items   & r   r#   -ConstraintWrapper.__init__.<locals>.<genexpr>   s     *N24=+>+>2r&   )originr`   r	   tclasspermsAttributeErrorhashkeyexpr
expression
isinstance	frozensetra   )r5   rd   ops   && r   __init__ConstraintWrapper.__init__   s    +DKK8	DJ
 : KM 		 //B"i((		  *N2*N!NO 		  $ "  	DJ	s   C C%$C%c                    V P                   # r   r   ri   s   &r   __hash__ConstraintWrapper.__hash__   s    xxr   c                4    V P                   VP                   8  # r   r   r5   others   &&r   __lt__ConstraintWrapper.__lt__   s    xx%))##r   c                    V P                   VP                   8H  ;'       d\    V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # r   r`   r   r   r   r   s   &&r   __eq__ConstraintWrapper.__eq__   sg    }}. $ $KK5<<'$ $JJ%++%$ $ II#	$r   )r   r   r   r   r`   r   Nr   )rn   ro   rp   rq   rr   	__slots__r   r   r   r   rv   rw   rx   s   @r   r   r      s+     -7I% %4$$ $r   r   N)collectionsr    r   descriptorsr   
differencer   r   r   objclassr	   typingr
   r   rm   r   r   r   r   <module>r      sB    $  - : : + P'J P'f*$	 7 78 *$r   