JFIF$        dd7 

Viewing File: /usr/lib64/python3.9/site-packages/setools/diff/__pycache__/mls.cpython-39.opt-1.pyc

a

q�qe�'�@sVUddlmZddlmZmZddlmZmZmZm	Z	m
Z
ddlmZddl
mZmZmZddlmZee�Zeeed	<ee�Zee
ed
<Gdd�de�ZGd
d�de�ZGdd�de�Zeeed�dd�Ze
ee
d�dd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dee�ZGdd �d ee�ZGd!d"�d"ee	�Z d#S)$�)�defaultdict)�
NamedTuple�Set�)�Category�Level�	LevelDecl�Range�Sensitivity�)�DiffResultDescriptor)�
Difference�
SymbolWrapper�Wrapper)�SymbolCache�_cats_cache�_sens_cachec@s6eZdZUdZeeed<eeed<eeed<dS)�ModifiedCategoryz+Difference details for a modified category.�
added_aliases�removed_aliases�matched_aliasesN��__name__�
__module__�__qualname__�__doc__r�str�__annotations__�rr�6/usr/lib64/python3.9/site-packages/setools/diff/mls.pyrs
rc@s6eZdZUdZeeed<eeed<eeed<dS)�ModifiedSensitivityz.Difference details for a modified sensitivity.rrrNrrrrrr s
r c@s>eZdZUdZeed<eeed<eeed<eeed<dS)�ModifiedLevelDeclz4Difference details for a modified level declaration.�level�added_categories�removed_categories�matched_categoriesN)rrrrrrrrrrrrr!%s

r!)�category�returncCsBzt|j|WSty<t|�}|t|j|<|YS0dS)z
    Wrap category from the specified policy.

    This caches results to prevent duplicate wrapper
    objects in memory.
    N)r�policy�KeyErrorr)r&�crrr�category_wrapper_factory/sr+)�sensitivityr'cCsBzt|j|WSty<t|�}|t|j|<|YS0dS)z�
    Wrap sensitivity from the specified policy.

    This caches results to prevent duplicate wrapper
    objects in memory.
    N)rr(r)r)r,r*rrr�sensitivity_wrapper_factory>sr-c@sDeZdZdZed�Zed�Zed�Zdd�dd�Zdd�dd�Z	dS)	�CategoriesDifferencez<Determine the difference in categories between two policies.�diff_categoriesN�r'cCs�|j�d�|��|�dd�|j��D�dd�|j��D��\|_|_}t	�|_
|D]@\}}|j|��|��dd�\}}}|s�|rTt|||�|j
|<qTdS)z;Generate the difference in categories between the policies.zHGenerating category differences from {0.left_policy} to {0.right_policy}css|]}t|�VqdS�N�r+��.0r*rrr�	<genexpr>\�z7CategoriesDifference.diff_categories.<locals>.<genexpr>css|]}t|�VqdSr1r2r3rrrr5]r6F��unwrapN)
�log�info�format�	_set_diff�left_policy�
categories�right_policyr#r$�dict�modified_categories�aliasesr)�selfr%Z
left_categoryZright_categoryrrrrrrr/Us"����z$CategoriesDifference.diff_categoriescCs"|j�d�d|_d|_d|_dS)�%Reset diff results on policy changes.zResetting category differencesN)r9�debugr#r$rA�rCrrr�_reset_diffosz CategoriesDifference._reset_diff)
rrrrrr#r$rAr/rGrrrrr.Msr.c@sDeZdZdZed�Zed�Zed�Zdd�dd�Zdd�dd�Z	dS)	�SensitivitiesDifferencez?Determine the difference in sensitivities between two policies.�diff_sensitivitiesNr0cCs�|j�d�|��|�dd�|j��D�dd�|j��D��\|_|_}t	�|_
|D]@\}}|j|��|��dd�\}}}|s�|rTt|||�|j
|<qTdS)z>Generate the difference in sensitivities between the policies.zKGenerating sensitivity differences from {0.left_policy} to {0.right_policy}css|]}t|�VqdSr1�r-�r4�srrrr5�r6z=SensitivitiesDifference.diff_sensitivities.<locals>.<genexpr>css|]}t|�VqdSr1rJrKrrrr5�r6Fr7N)
r9r:r;r<r=Z
sensitivitiesr?�added_sensitivities�removed_sensitivitiesr@�modified_sensitivitiesrBr )rCZmatched_sensitivitiesZ	left_sensZ
right_sensrrrrrrrIs(������z*SensitivitiesDifference.diff_sensitivitiescCs"|j�d�d|_d|_d|_dS�rDz!Resetting sensitivity differencesN)r9rErMrNrOrFrrrrG�sz#SensitivitiesDifference._reset_diff)
rrrrrrMrNrOrIrGrrrrrHwsrHc@sDeZdZdZed�Zed�Zed�Zdd�dd�Zdd�dd�Z	dS)	�LevelDeclsDifferencez8Determine the difference in levels between two policies.�diff_levelsNr0cCs�|j�d�|��|�dd�|j��D�dd�|j��D��\|_|_}g|_	|D]T\}}|�dd�|�
�D�dd�|�
�D��\}}}|s�|rR|j	�t||||��qRdS)z7Generate the difference in levels between the policies.zJGenerating level decl differences from {0.left_policy} to {0.right_policy}css|]}t|�VqdSr1��LevelDeclWrapperrKrrrr5�r6z3LevelDeclsDifference.diff_levels.<locals>.<genexpr>css|]}t|�VqdSr1rSrKrrrr5�r6css|]}t|�VqdSr1r2r3rrrr5�r6css|]}t|�VqdSr1r2r3rrrr5�r6N)
r9r:r;r<r=Zlevelsr?�added_levels�removed_levels�modified_levelsr>�appendr!)rCZmatched_levelsZ
left_levelZright_levelr#r$r%rrrrR�s(�����
�z LevelDeclsDifference.diff_levelscCs"|j�d�d|_d|_d|_dSrP)r9rErUrVrWrFrrrrG�sz LevelDeclsDifference._reset_diff)
rrrrrrUrVrWrRrGrrrrrQ�srQc@s<eZdZdZdZedd�dd�Zdd�Zd	d
�Zdd�Z	dS)
rTz-Wrap level declarations to allow comparisons.�r,N�r"r'cCs ||_t|j�|_t|�|_dSr1)�originr-r,�hash�key�rCr"rrr�__init__�szLevelDeclWrapper.__init__cCs|jSr1)r]rFrrr�__hash__�szLevelDeclWrapper.__hash__cCs|j|jkSr1rY�rC�otherrrr�__eq__�szLevelDeclWrapper.__eq__cCs|j|jkSr1rYrarrr�__lt__�szLevelDeclWrapper.__lt__)
rrrr�	__slots__rr_r`rcrdrrrrrT�srTc@s<eZdZdZdZedd�dd�Zdd�Zd	d
�Zdd�Z	dS)
�LevelWrapperz!Wrap levels to allow comparisons.)r,r>NrZcCs.||_t|j�|_tdd�|��D��|_dS)Ncss|]}t|�VqdSr1r2r3rrrr5�r6z(LevelWrapper.__init__.<locals>.<genexpr>)r[r-r,�setr>r^rrrr_�szLevelWrapper.__init__cCs
t|j�Sr1�r\r[rFrrrr`�szLevelWrapper.__hash__cCs4z|j|jko|j|jkWSty.YdS0dS�NF�r,r>�AttributeErrorrarrrrc�s
�zLevelWrapper.__eq__cCs4z|j|jko|j|jkWSty.YdS0dSrirjrarrrrd�s
�zLevelWrapper.__lt__)
rrrrrerr_r`rcrdrrrrrf�s	rfc@s<eZdZdZdZedd�dd�Zdd�Zd	d
�Zdd�Z	dS)
�RangeWrapperz�
    Wrap ranges to allow comparisons.

    This only compares the low and high levels of the range.
    It does not detect additions/removals/modifications
    to levels between the low and high levels of the range.
    )�low�highN)�range_r'cCs"||_t|j�|_t|j�|_dSr1)r[rfrmrn)rCrorrrr_szRangeWrapper.__init__cCs
t|j�Sr1rhrFrrrr`szRangeWrapper.__hash__cCs4z|j|jko|j|jkWSty.YdS0dSri�rmrnrkrarrrrcs
�zRangeWrapper.__eq__cCs4z|j|jko|j|jkWSty.YdS0dSrirprarrrrd$s
�zRangeWrapper.__lt__)
rrrrrer	r_r`rcrdrrrrrls	rlN)!�collectionsr�typingrrZ	policyreprrrr	r
Zdescriptorsr�
differencer
rrrr@rrrrr r!r+r-r.rHrQrTrfrlrrrr�<module>s$		
*,,!
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!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