id/(.ddlZddlmZGddeZy)N)SoSMapcveZdZdZgdZddgZdZdZdZiZ iZ dZ dZ d Z d Zfd Zd Zd ZdZdZxZS)SoSHostnameMapaLMapping store for hostnames and domain names Hostnames are obfuscated using an incrementing counter based on the total number of hosts matched regardless of domain name. Domain names are obfuscated based on the host's hostname, plus any user defined domains passed in by the `--domains` options. Domains are obfuscated as whole units, meaning the domains 'example.com' and 'host.foo.example.com' will be separately obfuscated with no relation for example as 'obfuscatedomdain1.com' and 'obfuscatedomain2.com'. Top-level domains are left untouched. ) localhostz.*localdomain.*z^com..*wwwapi) z.yamlz.ymlz.crtz.keyz.pemz.logz.repoz.rulesz.confz.cfgrc|jjD]2\}}t|jddk(r/|j||j|jdd<S|j dr"|jdd|j |<dj|jddd}|s|jjD]j}dj|jddd}||k(s,dj|j|jddd}||j |<l5|jy)zBecause we use 'intermediary' dicts for host names and domain names in this parser, we need to re-inject entries from the map_file into these dicts and not just the underlying 'dataset' dict .robfuscateddomainN) datasetitemslensplithosts startswith_domainsjoinkeysset_initial_counts)selfdomainob_pair_domain_to_injectexisting_domain _existing _ob_domains C/usr/lib/python3/dist-packages/sos/cleaner/mappings/hostname_map.pyload_domains_from_mapz$SoSHostnameMap.load_domains_from_map3sI $||113 FOFG6<<$%*37<<3G 6<<,Q/0%%&89,3MM#,>q,ADMM&)%(HHV\\#->q-D$E!('+||'8'8':FO #)>)>s)CCR)H II $55%(XX LL9??DSbI& 7djj( (  >"&//"%> ??s6Bcd}d}d}|jdr||dz }|dd}|jdr|jdr||dz }|dd}|jdr||jvr|j|S|j|j sdj |||gS|j|j r.d|jddz}|j|d}||z }||jjvr t|jjdd D]}d }|j|}|jd} | dr!| d|jjvrd}t|dk(s|dsa|s:|djds|j|rtt|?|}nI|j|ds |j|dd} |dtt|?| z}n|stt|?|}||z|zS#t $rYwxYw) N)r _rr r r Tct|S)N)r)xs rz$SoSHostnameMap.get..s #a&r!)r*keyF)rr6rr9lowerr strip_extsrr#rr,rrsuperrget Exception) rr'prefixsuffixfinalextr _host_substr_test_hitm __class__s rrDzSoSHostnameMap.getsS ooj) d1g F8Dooj)mmJ' d2h F":DmmJ' 4<< <<% %11$**,?77FD&12 2 == ) 3++C<<R(D cMF t||((* *$DLL$5$5$7(8:  $  9-__S)a5RUdjjoo&77#'Lu:?%(%58+<+++DGMMO< < t9>((.E.AAIIK./ L t9q=AwH!"XF8}q "66x~~7GH ( ,,V4I!*DLL HHk956E.AAIIK./ L% /&/s *EEc|r||jvr|S||jvrSd|jz}||j|<|xjdz c_||j|<|j ||j|S)zObfuscate the short name of the host with an incremented counter based on the total number of obfuscated host names zhost%sr ) skip_keysrr/radd_regex_item)rrXob_hosts rrRz"SoSHostnameMap.sanitize_short_namesx8t~~5O 4<< '0G#*DJJx OOq O%,DLL "    )||H%%r!c|jD]:}tj|dj|s)dj|cS|dj }dj|ddj }|j |}dj||g}||j dj|<|S)zeObfuscate the domainname, broken out into subdomains. Top-level domains are ignored. r r r)ignore_matchesr$matchrrA_new_obfuscated_domainr)rr_skip top_domainrWrZs rrSzSoSHostnameMap.sanitize_domains(( (Exxsxx/0xx'' (BZ%%' "&,,.//6 HHi45 )2 SXXf%&r!c||jvr1d|jz|j|<|xjdz c_|j|S)zDGenerate an obfuscated domain for each subdomain name given zobfuscateddomain%sr )rr1)rrWs rrdz%SoSHostnameMap._new_obfuscated_domainsI  %#7$:K:K#KDMM%    " }}U##r!)__name__ __module__ __qualname____doc__rbr^rBr/r1rrr r(rr9rDr\rRrSrd __classcell__)rNs@rrrsj N  I -JJLH E"@&( :'x> & $r!r)r$sos.cleaner.mappingsrrr!rros 'n$Vn$r!