PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` 3 Klf!@sbdZddlZddlmZddlmZddlmZGdddejZGd d d ZGd d d Z dS) zI Classes and algorithms for matching requested access to access vectors. N)access) objectmodel)utilc@seZdZdddZddZdS)MatchNrcCs||_||_d|_d|_dS)NF) interfacedistinfo_dir_change__hash__)selfrrr /usr/lib/python3.6/matching.py__init__ szMatch.__init__c Cs@y"|j|jf}|j|jf}|||Sttfk r:tSXdS)N)rr AttributeError TypeErrorNotImplemented)r othermethodabr r r _compare(s    zMatch._compare)Nr)__name__ __module__ __qualname__rrr r r r rs rc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS) MatchListcCs$g|_g|_|j|_d|_d|_dS)NF)childrenbastardsDEFAULT_THRESHOLD thresholdallow_info_dir_changeav)r r r r r3s zMatchList.__init__cCs,t|jr|jdSt|jr(|jdSdS)Nr)lenrr)r r r r best<s     zMatchList.bestcCst|jt|jS)N)r"rr)r r r r __len__CszMatchList.__len__cCs t|jS)N)iterr)r r r r __iter__IszMatchList.__iter__cCstj|j|jS)N) itertoolschainrr)r r r r allLsz MatchList.allcCsF|j|jkr6|j s|jr(|jj|qB|jj|n |jj|dS)N)rrr r rappendr)r matchr r r r*Os  zMatchList.appendcCs|jj|jjdS)N)rsortr)r r r r r,Xs zMatchList.sortN) rrrrrr#r$r&r)r*r,r r r r r1s  rc@s>eZdZdddZddZddZdd Zd d Zd d ZdS) AccessMatcherNcCs,d|_d|_|r||_n tj|_d|_dS)N d) type_penalty obj_penalty perm_mapsrZ PermMappingsinfo_dir_penalty)r r2r r r r^s  zAccessMatcher.__init__cCs"||kstj|rdS|j SdS)Nr)r is_idparamr0)r rrr r r type_distancejszAccessMatcher.type_distancecCsR|jj|j}t|dkr0|jj|j|}| S|jj|j}|jj|j|SdS)Nr)perms differencer"r2getdefault_distance obj_class)r Zav_reqZav_provZdiffZtotalr r r perm_distanceqs  zAccessMatcher.perm_distancecCsd}||j|j|j7}||j|j|j7}|j|jkrPtj|j rP||j8}|dkrl|jj|j|j }n |j ||}|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 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. rN) r5Zsrc_typetgt_typer9rr4r1r2r8r6r:)r ZreqZprovrZpdistr r r av_distance|s '   zAccessMatcher.av_distancecCsd}xf|D]^}|j||}|dkr(|}q |dkrN|dkrB||7}qh|| }q |dkr`||7}q ||8}q W|jj|j|j}|jdkrtj|_x&|D]}|j|jj|j|jB|_qW|tj@dkr|jtj@r|dkr||j 8}n ||j 7}|S)z Nr) r<r2Zgetdefault_directionr9r6Zinfo_dirrZ FLOW_NONEZ FLOW_WRITEr3)r Zav_setr!rxZtmpZav_dirr r r av_set_matchs.          zAccessMatcher.av_set_matchcCsh||_xTtj|j|jj|jgD]6}|js.q"|j|j |}|dkr"t ||}|j |q"W|j dS)Nr) r!r'r(Z tgt_type_allZ tgt_type_mapgetr;Zenabledr>rrr*r,)r Zifsetr!Z match_listZivrmr r r search_ifss  zAccessMatcher.search_ifs)N) rrrrr5r:r<r>rAr r r r r-]s   H(r-) __doc__r'rrrZ Comparisonrrr-r r r r s   ,