404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.144.227.187: ~ $
3

O+e�U�	@s�ddlZddlZddlmZmZddlmZddlZddl	m
Z
mZddlm
Z
mZddlmZdgZed	d
ddd
dddg�Zed
ddddg�ZGdd�d�ZGdd�d�ZdS)�N)�defaultdict�
namedtuple)�suppress)�
NetworkXError�NetworkXNoPath�)�EdgeAttrDict�EdgeAttrList)�
TERuletype�DomainTransitionAnalysis�step�source�target�
transition�entrypoints�setexec�
dyntransition�
setcurrent�name�
entrypoint�execute�type_transitionc@s�eZdZdZd!dd�Zedd��Zejdd��Zed	d
��Zejdd
��Zdd
�Z	d"dd�Z
dd�Zdd�Zdd�Z
edd��Zdd�Zdd�Zdd�Zdd �ZdS)#rzDomain transition analysis.FNcCs>tjt�|_||_||_||_d|_d|_t	j
�|_d|_dS)zD
        Parameter:
        policy   The policy to analyze.
        TN)
�loggingZ	getLogger�__name__�log�policy�exclude�reverse�rebuildgraph�rebuildsubgraph�nxZDiGraph�G�subG)�selfrrr�r$�/usr/lib64/python3.6/dta.py�__init__6s
z!DomainTransitionAnalysis.__init__cCs|jS)N)�_reverse)r#r$r$r%rEsz DomainTransitionAnalysis.reversecCst|�|_d|_dS)NT)�boolr'r)r#�	directionr$r$r%rIs
cCs|jS)N)�_exclude)r#r$r$r%rNsz DomainTransitionAnalysis.excludecs*|r�fdd�|D��_ng�_d�_dS)Ncsg|]}�jj|��qSr$)r�lookup_type)�.0�t)r#r$r%�
<listcomp>Usz4DomainTransitionAnalysis.exclude.<locals>.<listcomp>T)r*r)r#�typesr$)r#r%rRsccsj|jj|�}|jj|�}|jr&|j�|jjdj||��tt��|j	t
j|j||��VWdQRXdS)a�
        Generator which yields one shortest domain transition path
        between the source and target types (there may be more).

        Parameters:
        source  The source type.
        target  The target type.

        Yield: generator(steps)

        steps   A generator that returns the tuple of
                source, target, and rules for each
                domain transition.
        z8Generating one domain transition path from {0} to {1}...N)
rr+r�_build_subgraphr�info�formatrr�)_DomainTransitionAnalysis__generate_stepsr �
shortest_pathr")r#r
r�sr-r$r$r%r4[s
z&DomainTransitionAnalysis.shortest_path�ccs�|dkrtd��|jj|�}|jj|�}|jr6|j�|jjdj|||��tt	��.x&t
j|j|||�D]}|j
|�VqjWWdQRXdS)a�
        Generator which yields all domain transition paths between
        the source and target up to the specified maximum path
        length.

        Parameters:
        source   The source type.
        target   The target type.
        maxlen   Maximum length of paths.

        Yield: generator(steps)

        steps    A generator that returns the tuple of
                 source, target, and rules for each
                 domain transition.
        rz%Maximum path length must be positive.zIGenerating all domain transition paths from {0} to {1}, max length {2}...N)�
ValueErrorrr+rr0rr1r2rrr Zall_simple_pathsr"r3)r#r
r�maxlenr5r-�pathr$r$r%�	all_pathsxs

z"DomainTransitionAnalysis.all_pathsccsx|jj|�}|jj|�}|jr&|j�|jjdj||��tt��,x$t	j
|j||�D]}|j|�VqVWWdQRXdS)a�
        Generator which yields all shortest domain transition paths
        between the source and target types.

        Parameters:
        source   The source type.
        target   The target type.

        Yield: generator(steps)

        steps    A generator that returns the tuple of
                 source, target, and rules for each
                 domain transition.
        zBGenerating all shortest domain transition paths from {0} to {1}...N)
rr+rr0rr1r2rrr �all_shortest_pathsr"r3)r#r
rr5r-r9r$r$r%r;�s


z+DomainTransitionAnalysis.all_shortest_pathsccs�|jj|�}|jr|j�|jjdj||jr0dnd��tt	��nxf|j
j|�D]V\}}t|j
||�}|jrx||}}n
||}}t
|||j|j|�|j|j|j�VqPWWdQRXdS)aM
        Generator which yields all domain transitions out of a
        specified source type.

        Parameters:
        type_   The starting type.

        Yield: generator(steps)

        steps   A generator that returns the tuple of
                source, target, and rules for each
                domain transition.
        z)Generating all domain transitions {1} {0}zin tozout fromN)rr+rr0rr1r2rrrr"Z	out_edges�Edge�step_outputr�/_DomainTransitionAnalysis__generate_entrypointsrrr)r#Ztype_r5r
r�edge�real_source�real_targetr$r$r%�transitions�s"


z$DomainTransitionAnalysis.transitionscCs|jr|j�tj|j�S)zR
        Get the domain transition graph statistics.

        Return: str
        )r�_build_graphr r1r!)r#r$r$r%�	get_stats�sz"DomainTransitionAnalysis.get_statscs�fdd��jD�S)a�
        Creates a list of entrypoint, execute, and
        type_transition rules for each entrypoint.

        Parameter:
        data     The dictionary of entrypoints.

        Return: list of tuple(type, entry, exec, trans)

        type     The entrypoint type.
        entry    The list of entrypoint rules.
        exec     The list of execute rules.
        trans    The list of type_transition rules.
        cs,g|]$}t|�j|�j|�j|��qSr$)�entrypoint_outputrrr)r,�e)r?r$r%r.szCDomainTransitionAnalysis.__generate_entrypoints.<locals>.<listcomp>)r)r?r$)r?r%Z__generate_entrypoints�s
z/DomainTransitionAnalysis.__generate_entrypointsc	cs~xxtdt|��D]f}||d}||}t|j||�}|jrH||}}n
||}}t|||j|j|�|j|j	|j
�VqWdS)a
        Generator which yields the source, target, and associated rules
        for each domain transition.

        Parameter:
        path     A list of graph node names representing an information flow path.

        Yield: tuple(source, target, transition, entrypoints,
                     setexec, dyntransition, setcurrent)

        source          The source type for this step of the domain transition.
        target          The target type for this step of the domain transition.
        transition      The list of transition rules.
        entrypoints     Generator which yields entrypoint-related rules.
        setexec         The list of setexec rules.
        dyntranstion    The list of dynamic transition rules.
        setcurrent      The list of setcurrent rules.
        rN)�range�lenr<r"rr=rr>rrr)r#r9r5r
rr?r@rAr$r$r%Z__generate_stepss
z)DomainTransitionAnalysis.__generate_stepscCs�|jj�dj|j�|j_|jjdj|j��tt�}tt�}tdd��}tdd��}tdd��}�x4|jj	�D�]$}|j
tjk�r8|j
dkr�qp|j}|j
dk�r�d	|kr�xJtj|jj�|jj��D].\}}	||	kr�t|j||	d
d�}
|
jj|�q�Wd|k�rPxNtj|jj�|jj��D]2\}}	||	k�rt|j||	d
d�}|jj|��qWd
|k�r~x"|jj�D]}||j|��qfWd|k�r6x�|jj�D]}||j|��q�Wn�d|k�r�x8tj|jj�|jj��D]\}}	|||	j|��q�Wd|k�r�x�tj|jj�|jj��D]\}}	|||	j|��qWqp|j
tjkrp|j
dk�rRqp|j}x<tj|jj�|jj��D] \}}	|||	|j|��qrWqpWg}
g}g}�x�|jj�D�]�\}}	t|j||	�}
d}d}|
j�r�t||	j��}t||j��}|j|�}|�sd
}n�x�|D]�}||k�s4|||�rh|
j|||	|7<|
j||||7<||||	�r|
j|||||	7<�qW||k�r�|
j j!||�|
j �r�|
j�r�d
}nd
}|
j�r||k�r�|
j"j!||�nd
}nd
}|�r|�r|
j|
�n"|�r.|j|
�n|�r�|j|
��q�W|jj#|
�x"|D]}
|
`|
`|
`|
`|
` �qVWx|D]}
|
`|
`"�qzWd|_$d
|_%|jjd�|jj&djt'j(|j�t'j)|j���dS)Nz Domain transition graph for {0}.z,Building domain transition graph from {0}...cSstt�S)N)r�listr$r$r$r%�<lambda>nsz7DomainTransitionAnalysis._build_graph.<locals>.<lambda>cSstt�S)N)rrIr$r$r$r%rJoscSstdd��S)NcSstt�S)N)rrIr$r$r$r%rJrszIDomainTransitionAnalysis._build_graph.<locals>.<lambda>.<locals>.<lambda>)rr$r$r$r%rJrs�process�filerT)�createrrrrrFz+Completed building domain transition graph.z$Graph stats: nodes: {0}, edges: {1}.)rKrL)*r!�clearr2rrrr1rrIZterulesZruletyper
ZallowZtclass�perms�	itertools�productr
�expandrr<r�appendrr�default�edges�set�keys�intersectionrrr�extendr�remove_edges_fromrr�debugr �number_of_nodes�number_of_edges)r#rrrrZ
type_transZrulerOr5r-r?rF�dZinvalid_edgeZclear_transitionZclear_dyntransitionZ
invalid_transZinvalid_dyntrans�entryZexe�match�mr$r$r%rCas�

"
"




"" 

$







z%DomainTransitionAnalysis._build_graphcCs�g}x�|jj�D]�\}}t|j||�}t|j�}|j|j�|sBqx8|D]0}|j|=|j|=tt	��|j
|=WdQRXqHW|jr|jr|j|�qW|jj
|�dS)N)r"rUr<rVr�intersection_updaterrr�KeyErrorrrrSrZ)r#Z
invalid_edgesr
rr?rrFr$r$r%Z__remove_excluded_entrypoints�s


z6DomainTransitionAnalysis.__remove_excluded_entrypointscCs�|jr|j�|jjd�|jjdj|j��|jjdj|j��|jrZ|jjdd�|_	n|jj
�|_	|jr�|j	j|j�|j�d|_
|jjd�|jjdjtj|j	�tj|j	���dS)	Nz$Building domain transition subgraph.z
Excluding {0}zReverse {0}T)�copyFz.Completed building domain transition subgraph.z'Subgraph stats: nodes: {0}, edges: {1}.)rrCrr1r[r2rrr!r"rdZremove_nodes_from�6_DomainTransitionAnalysis__remove_excluded_entrypointsrr r\r])r#r$r$r%r0s 

z(DomainTransitionAnalysis._build_subgraph)FN)r6)r�
__module__�__qualname__�__doc__r&�propertyr�setterrr4r:r;rBrD�staticmethodr>r3rCrer0r$r$r$r%r2s"
	
$'^c@sbeZdZdZed�Zed�Zed�Zed�Ze	d�Z
e	d�Ze	d�Zdd
d�Z
dd
�Zdd�ZdS)r<aS
    A graph edge.  Also used for returning domain transition steps.

    Parameters:
    graph       The NetworkX graph.
    source      The source type of the edge.
    target      The target tyep of the edge.

    Keyword Parameters:
    create      (T/F) create the edge if it does not exist.
                The default is False.
    rrrrrrrFcCsj||_||_||_|jj||�sf|s.td��n8|jj||�d|_d|_d|_d|_	d|_
d|_d|_dS)NzEdge does not exist in graph)
r!r
rZhas_edger7Zadd_edgerrrrrrr)r#Zgraphr
rrMr$r$r%r&Es
z
Edge.__init__cs4t|t�r&�fdd�t|jd��D�S�j|�SdS)Ncsg|]}�j|��qSr$)�_index_to_item)r,�i)r#r$r%r.[sz$Edge.__getitem__.<locals>.<listcomp>r6)�
isinstance�slicerG�indicesrl)r#�keyr$)r#r%�__getitem__Ws
zEdge.__getitem__cCs.|dkr|jS|dkr|jStdj|���dS)z'Return source or target based on index.rrz,Invalid index (edges only have 2 items): {0}N)r
r�
IndexErrorr2)r#�indexr$r$r%rl_s
zEdge._index_to_itemN)F)rrfrgrhr	rrrrrrrrr&rrrlr$r$r$r%r<.s

r<)rPr�collectionsrr�
contextlibrZnetworkxr Znetworkx.exceptionrrZdescriptorsrr	Z	policyrepr
�__all__r=rErr<r$r$r$r%�<module>s2

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 2.34 KB 0644
__init__.cpython-36.pyc File 2.34 KB 0644
boolquery.cpython-36.opt-1.pyc File 1.8 KB 0644
boolquery.cpython-36.pyc File 1.8 KB 0644
boundsquery.cpython-36.opt-1.pyc File 1.67 KB 0644
boundsquery.cpython-36.pyc File 1.67 KB 0644
categoryquery.cpython-36.opt-1.pyc File 1.49 KB 0644
categoryquery.cpython-36.pyc File 1.49 KB 0644
commonquery.cpython-36.opt-1.pyc File 1.71 KB 0644
commonquery.cpython-36.pyc File 1.71 KB 0644
constraintquery.cpython-36.opt-1.pyc File 4.42 KB 0644
constraintquery.cpython-36.pyc File 4.42 KB 0644
defaultquery.cpython-36.opt-1.pyc File 2.12 KB 0644
defaultquery.cpython-36.pyc File 2.12 KB 0644
descriptors.cpython-36.opt-1.pyc File 7.36 KB 0644
descriptors.cpython-36.pyc File 7.56 KB 0644
devicetreeconquery.cpython-36.opt-1.pyc File 2.31 KB 0644
devicetreeconquery.cpython-36.pyc File 2.31 KB 0644
dta.cpython-36.opt-1.pyc File 13.23 KB 0644
dta.cpython-36.pyc File 13.23 KB 0644
exception.cpython-36.opt-1.pyc File 8.63 KB 0644
exception.cpython-36.pyc File 8.63 KB 0644
fsusequery.cpython-36.opt-1.pyc File 2.81 KB 0644
fsusequery.cpython-36.pyc File 2.81 KB 0644
genfsconquery.cpython-36.opt-1.pyc File 2.96 KB 0644
genfsconquery.cpython-36.pyc File 2.96 KB 0644
ibendportconquery.cpython-36.opt-1.pyc File 3.01 KB 0644
ibendportconquery.cpython-36.pyc File 3.01 KB 0644
ibpkeyconquery.cpython-36.opt-1.pyc File 4.22 KB 0644
ibpkeyconquery.cpython-36.pyc File 4.22 KB 0644
infoflow.cpython-36.opt-1.pyc File 11.33 KB 0644
infoflow.cpython-36.pyc File 11.33 KB 0644
initsidquery.cpython-36.opt-1.pyc File 2.41 KB 0644
initsidquery.cpython-36.pyc File 2.41 KB 0644
iomemconquery.cpython-36.opt-1.pyc File 3.67 KB 0644
iomemconquery.cpython-36.pyc File 3.67 KB 0644
ioportconquery.cpython-36.opt-1.pyc File 3.67 KB 0644
ioportconquery.cpython-36.pyc File 3.67 KB 0644
mixins.cpython-36.opt-1.pyc File 6.31 KB 0644
mixins.cpython-36.pyc File 6.31 KB 0644
mlsrulequery.cpython-36.opt-1.pyc File 2.95 KB 0644
mlsrulequery.cpython-36.pyc File 2.95 KB 0644
netifconquery.cpython-36.opt-1.pyc File 2.48 KB 0644
netifconquery.cpython-36.pyc File 2.48 KB 0644
nodeconquery.cpython-36.opt-1.pyc File 3.53 KB 0644
nodeconquery.cpython-36.pyc File 3.53 KB 0644
objclassquery.cpython-36.opt-1.pyc File 2.87 KB 0644
objclassquery.cpython-36.pyc File 2.87 KB 0644
pcideviceconquery.cpython-36.opt-1.pyc File 2.65 KB 0644
pcideviceconquery.cpython-36.pyc File 2.65 KB 0644
permmap.cpython-36.opt-1.pyc File 11.67 KB 0644
permmap.cpython-36.pyc File 11.9 KB 0644
pirqconquery.cpython-36.opt-1.pyc File 2.58 KB 0644
pirqconquery.cpython-36.pyc File 2.58 KB 0644
polcapquery.cpython-36.opt-1.pyc File 1.29 KB 0644
polcapquery.cpython-36.pyc File 1.29 KB 0644
portconquery.cpython-36.opt-1.pyc File 4.21 KB 0644
portconquery.cpython-36.pyc File 4.21 KB 0644
query.cpython-36.opt-1.pyc File 1003 B 0644
query.cpython-36.pyc File 1003 B 0644
rbacrulequery.cpython-36.opt-1.pyc File 3.75 KB 0644
rbacrulequery.cpython-36.pyc File 3.75 KB 0644
rolequery.cpython-36.opt-1.pyc File 1.94 KB 0644
rolequery.cpython-36.pyc File 1.94 KB 0644
sensitivityquery.cpython-36.opt-1.pyc File 2.12 KB 0644
sensitivityquery.cpython-36.pyc File 2.12 KB 0644
terulequery.cpython-36.opt-1.pyc File 6.13 KB 0644
terulequery.cpython-36.pyc File 6.13 KB 0644
typeattrquery.cpython-36.opt-1.pyc File 2.09 KB 0644
typeattrquery.cpython-36.pyc File 2.09 KB 0644
typequery.cpython-36.opt-1.pyc File 2.81 KB 0644
typequery.cpython-36.pyc File 2.81 KB 0644
userquery.cpython-36.opt-1.pyc File 3.64 KB 0644
userquery.cpython-36.pyc File 3.64 KB 0644
util.cpython-36.opt-1.pyc File 4.59 KB 0644
util.cpython-36.pyc File 4.59 KB 0644