/usr/lib/python3.9/site-packages/sepolgen/__pycache__
NameSizeModeActions
access.cpython-39.opt-1.pyc113610644editdlrm
access.cpython-39.pyc113610644editdlrm
audit.cpython-39.opt-1.pyc172600644editdlrm
audit.cpython-39.pyc172600644editdlrm
classperms.cpython-39.opt-1.pyc24710644editdlrm
classperms.cpython-39.pyc24710644editdlrm
defaults.cpython-39.opt-1.pyc22980644editdlrm
defaults.cpython-39.pyc22980644editdlrm
interfaces.cpython-39.opt-1.pyc125920644editdlrm
interfaces.cpython-39.pyc125920644editdlrm
lex.cpython-39.opt-1.pyc213770644editdlrm
lex.cpython-39.pyc213770644editdlrm
matching.cpython-39.opt-1.pyc61690644editdlrm
matching.cpython-39.pyc61690644editdlrm
module.cpython-39.opt-1.pyc71700644editdlrm
module.cpython-39.pyc71700644editdlrm
objectmodel.cpython-39.opt-1.pyc39710644editdlrm
objectmodel.cpython-39.pyc39710644editdlrm
output.cpython-39.opt-1.pyc35450644editdlrm
output.cpython-39.pyc35450644editdlrm
policygen.cpython-39.opt-1.pyc128870644editdlrm
policygen.cpython-39.pyc129200644editdlrm
refparser.cpython-39.opt-1.pyc292590644editdlrm
refparser.cpython-39.pyc292590644editdlrm
refpolicy.cpython-39.opt-1.pyc401730644editdlrm
refpolicy.cpython-39.pyc401730644editdlrm
sepolgeni18n.cpython-39.opt-1.pyc3940644editdlrm
sepolgeni18n.cpython-39.pyc3940644editdlrm
util.cpython-39.opt-1.pyc63640644editdlrm
util.cpython-39.pyc63640644editdlrm
yacc.cpython-39.opt-1.pyc531330644editdlrm
yacc.cpython-39.pyc532120644editdlrm
__init__.cpython-39.opt-1.pyc1440644editdlrm
__init__.cpython-39.pyc1440644editdlrm
Edit: /usr/lib/python3.9/site-packages/sepolgen/__pycache__/matching.cpython-39.pyc (6169B)
a BÒiÑ!ã@sbdZddlZddlmZddlmZddlmZGdd„dejƒZGd d „d ƒZGd d „d ƒZ dS) zI Classes and algorithms for matching requested access to access vectors. éNé)Úaccess)Ú objectmodel)Úutilc@seZdZddd„Zdd„ZdS)ÚMatchNrcCs||_||_d|_d|_dS©NF)Ú interfaceÚdistÚinfo_dir_changeÚ__hash__)Úselfrr ©r ú5/usr/lib/python3.9/site-packages/sepolgen/matching.pyÚ__init__ szMatch.__init__c CsDz$|j|jf}|j|jf}|||ƒWSttfy>tYS0dS©N)r r ÚAttributeErrorÚ TypeErrorÚNotImplemented)r ÚotherÚmethodÚaÚbr r rÚ_compare(s    zMatch._compare)Nr)Ú__name__Ú __module__Ú __qualname__rrr r r rrs rc@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)Ú MatchListé–cCs$g|_g|_|j|_d|_d|_dSr)ÚchildrenÚbastardsÚDEFAULT_THRESHOLDÚ thresholdÚallow_info_dir_changeÚav©r r r rr3s zMatchList.__init__cCs,t|jƒr|jdSt|jƒr(|jdSdS©Nr©Úlenrrr$r r rÚbest<s     zMatchList.bestcCst|jƒt|jƒSrr&r$r r rÚ__len__CszMatchList.__len__cCs t|jƒSr)Úiterrr$r r rÚ__iter__IszMatchList.__iter__cCst |j|j¡Sr)Ú itertoolsÚchainrrr$r r rÚallLsz MatchList.allcCsD|j|jkr4|jr|jr&|j |¡q@|j |¡n |j |¡dSr)r r!r r"rÚappendr)r Úmatchr r rr/Os   zMatchList.appendcCs|j ¡|j ¡dSr)rÚsortrr$r r rr1Xs zMatchList.sortN) rrrr rr(r)r+r.r/r1r r r rr1s  rc@s>eZdZddd„Zdd„Zdd„Zdd „Zd d „Zd d „ZdS)Ú AccessMatcherNcCs,d|_d|_|r||_n t ¡|_d|_dS)Né éd)Ú type_penaltyÚ obj_penaltyÚ perm_mapsrZ PermMappingsÚinfo_dir_penalty)r r7r r rr^s  zAccessMatcher.__init__cCs"||kst |¡rdS|j SdSr%)rÚ is_idparamr5)r rrr r rÚ type_distancejszAccessMatcher.type_distancecCsR|j |j¡}t|ƒdkr0|j |j|¡}| S|j |j¡}|j |j|¡SdSr%)ÚpermsÚ differencer'r7Úgetdefault_distanceÚ obj_class)r Zav_reqZav_provÚdiffÚtotalr r rÚ perm_distanceqs  zAccessMatcher.perm_distancecCs¼d}|| |j|j¡7}|| |j|j¡7}|j|jkrNt |j¡sN||j8}|dkrj|j |j|j ¡}n |  ||¡}|dkr˜|dkrŽ||S||Sn |dkr¸|dkr°||S||SdS)a,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 access 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. rN) r:Zsrc_typeÚtgt_typer>rr9r6r7r=r;rA)r ZreqZprovr Zpdistr r rÚ av_distance|s '   zAccessMatcher.av_distancecCsìd}|D]^}| ||¡}|dur&|}q|dkrL|dkr@||7}qf|| }q|dkr^||7}q||8}q|j |j|j¡}|jdur°tj|_|D]}|j|j |j|j¡B|_q�|tj@dkrè|jtj@rè|dkrÞ||j 8}n ||j 7}|S)z Nr) rCr7Zgetdefault_directionr>r;Zinfo_dirrZ FLOW_NONEZ FLOW_WRITEr8)r Zav_setr#r ÚxÚtmpZav_dirr r rÚ av_set_matchÄs0      ÿ  zAccessMatcher.av_set_matchcCsd||_t |j|j |jg¡¡D]6}|js,q | |j |¡}|dkr t ||ƒ}|  |¡q |  ¡dSr%) r#r,r-Z tgt_type_allZ tgt_type_mapÚgetrBZenabledrFrrr/r1)r Zifsetr#Z match_listZivr Úmr r rÚ search_ifsìsÿ  zAccessMatcher.search_ifs)N) rrrrr:rArCrFrIr r r rr2]s   H(r2) Ú__doc__r,ÚrrrZ Comparisonrrr2r r r rÚs   ,