????

Your IP : 3.16.139.90


Current Path : /lib/python3.9/site-packages/sepolgen/__pycache__/
Upload File :
Current File : //lib/python3.9/site-packages/sepolgen/__pycache__/objectmodel.cpython-39.pyc

a


z
fw�@sbdZgd�ZdZdZdZeeBZeeeed�Zedededed	iZGd
d�d�ZGdd
�d
�Z	dS)z�
This module provides knowledge object classes and permissions. It should
be used to keep this knowledge from leaking into the more generic parts of
the policy generation.
)	Zsocket�fdZprocess�fileZlnk_fileZ	fifo_fileZdbusZ
capabilityZunix_stream_socket���)�n�r�w�brrrr	c@s eZdZdZdd�Zdd�ZdS)�PermMapaA mapping between a permission and its information flow properties.

    PermMap represents the information flow properties of a single permission
    including the direction (read, write, etc.) and an abstract representation
    of the bandwidth of the flow (weight).
    cCs||_||_||_dS�N)�perm�dir�weight)�selfrr
r�r�8/usr/lib/python3.9/site-packages/sepolgen/objectmodel.py�__init__TszPermMap.__init__cCsd|jt|j|jfS)Nz'<sepolgen.objectmodel.PermMap %s %s %d>)r�
dir_to_strr
r�rrrr�__repr__Ys�zPermMap.__repr__N)�__name__�
__module__�__qualname__�__doc__rrrrrrr
Msr
c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�PermMappingsz�The information flow properties of a set of object classes and permissions.

    PermMappings maps one or more classes and permissions to their PermMap objects
    describing their information flow characteristics.
    cCsi|_d|_t|_dS)N�)�classes�default_weight�	FLOW_BOTH�default_dirrrrrrdszPermMappings.__init__cCs�d}|D]�}|��}t|�dkst|�dks|ddkr:q|ddkrv|d}||jvr`td��i|j|<|j|}qt|�dkr�td��|dur�td	��t|dt|dt|d
��}|||j<qdS)zsRead the permission mappings from a file. This reads the format used
        by Apol in the setools suite.
        Nrr�#�classzduplicate class in perm map�z!error in object class permissionszpermission outside of classr)�split�lenr�
ValueErrorr
�
str_to_dir�intr)rrZcur�line�fields�c�pmrrr�	from_fileis"	$

 zPermMappings.from_filecCs|j||S)z�Get the permission map for the object permission.

        Returns:
          PermMap representing the permission
        Raises:
          KeyError if the object or permission is not defined
        )r)r�objrrrr�get�szPermMappings.getcCs:z|j||}Wn"ty4t||j|j�YS0|S)aGet the permission map for the object permission or a default.

        getdefault is the same as get except that a default PermMap is
        returned if the object class or permission is not defined. The
        default is FLOW_BOTH with a weight of 5.
        )r�KeyErrorr
rr)rr-rr+rrr�
getdefault�s
zPermMappings.getdefaultcCs(t}|D]}|�||�}||jB}q|Sr)�	FLOW_NONEr0r
)rr-�permsr
rr+rrr�getdefault_direction�s
z!PermMappings.getdefault_directioncCs(d}|D]}|�||�}||j7}q|S)Nr)r0r)rr-r2�totalrr+rrr�getdefault_distance�s
z PermMappings.getdefault_distanceN)
rrrrrr,r.r0r3r5rrrrr^s

rN)
rZimplicitly_typed_objectsr1Z	FLOW_READZ
FLOW_WRITErr&rr
rrrrr�<module>s