509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^   ã               @   sh   d dl mZ ddlmZ ddlmZ ddlmZmZ edddd	gƒZ	G d
d„ deƒZ
G dd„ deƒZdS )é    )Ú
namedtupleé   )ÚContextWrapper)ÚDiffResultDescriptor)Ú
DifferenceÚWrapperZmodified_genfsÚruleZadded_contextZremoved_contextc               @   s8   e Zd ZdZedƒZedƒZedƒZdd„ Zdd„ Z	dS )ÚGenfsconsDifferencez@Determine the difference in genfscon rules between two policies.Údiff_genfsconsc             C   s�   | j jdj| ƒƒ | jdd„ | jjƒ D ƒdd„ | jjƒ D ƒƒ\| _| _}g | _	x<|D ]4\}}t
|jƒt
|jƒkrT| j	jt||j|jƒƒ qTW dS )z?Generate the difference in genfscon rules between the policies.zHGenerating genfscon differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |ƒV  qd S )N)ÚGenfsconWrapper)Ú.0Úfs© r   ú /usr/lib64/python3.6/genfscon.pyú	<genexpr>/   s    z5GenfsconsDifference.diff_genfscons.<locals>.<genexpr>c             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   0   s    N)ÚlogÚinfoÚformatZ	_set_diffZleft_policyZ	genfsconsZright_policyÚadded_genfsconsÚremoved_genfsconsÚmodified_genfsconsr   ÚcontextÚappendÚmodified_genfs_record)ÚselfZmatchedZ	left_ruleZ
right_ruler   r   r   r
   '   s     
z"GenfsconsDifference.diff_genfsconsc             C   s"   | j jdƒ d| _d| _d| _dS )z%Reset diff results on policy changes.z#Resetting genfscon rule differencesN)r   Údebugr   r   r   )r   r   r   r   Ú_reset_diff?   s    zGenfsconsDifference._reset_diffN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r
   r   r   r   r   r   r	      s   r	   c               @   s4   e Zd ZdZdZdd„ Zdd	„ Zd
d„ Zdd„ ZdS )r   z,Wrap genfscon rules to allow set operations.r   ÚpathÚfiletyper   c             C   s8   || _ |j| _|j| _|j| _t|jƒ| _t|ƒ| _d S )N)Úoriginr   r!   r"   r   r   ÚhashÚkey)r   r   r   r   r   Ú__init__M   s    zGenfsconWrapper.__init__c             C   s   | j S )N)r%   )r   r   r   r   Ú__hash__U   s    zGenfsconWrapper.__hash__c             C   s   | j |j k S )N)r%   )r   Úotherr   r   r   Ú__lt__X   s    zGenfsconWrapper.__lt__c             C   s$   | j |j ko"| j|jko"| j|jkS )N)r   r!   r"   )r   r(   r   r   r   Ú__eq__[   s    zGenfsconWrapper.__eq__N)r   r!   r"   r   )	r   r   r   r    Ú	__slots__r&   r'   r)   r*   r   r   r   r   r   G   s   r   N)Úcollectionsr   r   r   Zdescriptorsr   Ú
differencer   r   r   r	   r   r   r   r   r   Ú<module>   s   (