KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux cs317.bluehost.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : andertr9 ( 1047)
PHP Version : 8.2.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/sepolgen/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/sepolgen/matching.pyo
�
��^c@s�dZddlZddlmZddlmZddlmZdejfd��YZd	d
d
��YZddd��YZ	dS(sI
Classes and algorithms for matching requested access to access vectors.
i����Ni(taccess(tobjectmodel(tutiltMatchcBs eZddd�Zd�ZRS(icCs(||_||_t|_d|_dS(N(t	interfacetdisttFalsetinfo_dir_changetNonet__hash__(tselfRR((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt__init__ s			cCsTy5|j|jf}|j|jf}|||�SWnttfk
rOtSXdS(N(RRtAttributeErrort	TypeErrortNotImplemented(R
tothertmethodtatb((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt_compare(sN(t__name__t
__module__RRR(((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyRst	MatchListcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(i�cCs4g|_g|_|j|_t|_d|_dS(N(tchildrentbastardstDEFAULT_THRESHOLDt	thresholdRtallow_info_dir_changeRtav(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR3s
			cCs8t|j�r|jdSt|j�r4|jdSdS(Ni(tlenRRR(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pytbest<s
cCst|j�t|j�S(N(RRR(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt__len__CscCs
t|j�S(N(titerR(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt__iter__IscCstj|j|j�S(N(t	itertoolstchainRR(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pytallLscCs_|j|jkrK|js%|jr8|jj|�q[|jj|�n|jj|�dS(N(RRRRRtappendR(R
tmatch((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR%Os
cCs|jj�|jj�dS(N(RtsortR(R
((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR'Xs
(
RRRRRRR!R$R%R'(((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR1s								t
AccessMatchercBsAeZdd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs@d|_d|_|r$||_ntj�|_d|_dS(Ni
id(ttype_penaltytobj_penaltyt	perm_mapsRtPermMappingstinfo_dir_penalty(R
R+((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR^s		cCs+||kstj|�rdS|jSdS(Ni(Rt
is_idparamR)(R
RR((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt
type_distancejscCss|jj|j�}t|�dkrD|jj|j|�}|S|jj|j�}|jj|j|�SdS(Ni(tpermst
differenceRR+tgetdefault_distancet	obj_class(R
tav_reqtav_provtdiffttotal((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt
perm_distanceqscCs	d}||j|j|j�7}||j|j|j�7}|j|jkrstj|j�rs||j8}n|dkr�|jj|j|j	�}n|j
||�}|dkr�|dkr�||S||Sn+|dkr|dkr�||S||SndS(s+Determine the 'distance' between 2 access vectors.

        This function is used to find an access vector that matches
        a 'required' access. To do this we comput a signed numeric
        value that indicates how close the req access is to the
        'provided' access vector. The closer the value is to 0
        the closer the match, with 0 being an exact match.

        A value over 0 indicates that the prov access vector provides more
        access than the req (in practice, this means that the source type,
        target type, and object class is the same and the perms in prov is
        a superset of those in req.

        A value under 0 indicates that the prov access less - or unrelated
        - access to the req access. A different type or object class will
        result in a very low value.

        The values other than 0 should only be interpreted relative to
        one another - they have no exact meaning and are likely to
        change.

        Params:
          req - [AccessVector] The access that is required. This is the
                access being matched.
          prov - [AccessVector] The access provided. This is the potential
                 match that is being evaluated for req.
        Returns:
          0   : Exact match between the acess vectors.

          < 0 : The prov av does not provide all of the access in req.
                A smaller value indicates that the access is further.

          > 0 : The prov av provides more access than req. The larger
                the value the more access over req.
        iN(R/tsrc_typettgt_typeR3RR.R*R+R2R0R8(R
treqtprovRtpdist((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pytav_distance|s '%cCsVd}x�|D]�}|j||�}|dkr:|}q
|dkrm|dkr_||7}q�||}q
|dkr�||7}q
||8}q
W|jj|j|j�}|jdkrtj|_x6|D]+}|j|jj|j|j�B|_q�Wn|tj	@dkrR|jtj	@rR|dkrB||j
8}qR||j
7}n|S(s


        iN(RR>R+tgetdefault_directionR3R0tinfo_dirRt	FLOW_NONEt
FLOW_WRITER-(R
tav_setRRtxttmptav_dir((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pytav_set_match�s.
	


&#cCs�||_x~tj|j|jj|jg��D]U}|jsFq1n|j|j	|�}|dkr1t
||�}|j|�q1q1W|j�dS(Ni(
RR"R#ttgt_type_allttgt_type_maptgetR:tenabledRGRRR%R'(R
tifsetRt
match_listtivRtm((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt
search_ifs�s		N(	RRRRR/R8R>RGRP(((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyR(]s			H	((((
t__doc__R"tRRRt
ComparisonRRR((((s7/usr/lib64/python2.7/site-packages/sepolgen/matching.pyt<module>s,

Anon7 - 2021