HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/sos/cleaner/mappings/__pycache__/hostname_map.cpython-36.pyc
3

\��h(�@s(ddlZddlmZGdd�de�ZdS)�N)�SoSMapc
s�eZdZdZdddgZddgZd%ZdZdZdZ	dZ
iZiZdd�Z
�fdd�Zdd�Zdd�Z�fdd�Zdd�Zdd �Zd!d"�Zd#d$�Z�ZS)&�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.
    Z	localhostz.*localdomain.*z^com..*ZwwwZapi�.yaml�.yml�.crt�.key�.pem�.log�.repo�.rules�.conf�.cfgTrcCs�x�|jj�D]�\}}t|jd��dkrB|j||j|jd�d<q|jd�rb|jd�d|j|<qdj|jd�dd��}|s�qxX|jj�D]J\}}dj|jd�dd��}||kr�dj|jd�dd��}||j|<q�WqW|j�dS)	z�Because 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
        �.�r�obfuscateddomainN���rr)	�dataset�items�len�split�hosts�
startswith�_domains�join�set_initial_counts)�self�domainZob_pairZ_domain_to_injectZexisting_domain�value�	_existingZ
_ob_domain�r�"/usr/lib/python3.6/hostname_map.py�load_domains_from_map5s
z$SoSHostnameMap.load_domains_from_mapcs d|kr|jdd�}t�j|�S)z�Override the base get_regex_result() to provide a regex that, if
        this is an FQDN or a straight domain, will include an underscore
        formatted regex as well.
        rz(\.|_))�replace�super�get_regex_result)r�item)�	__class__rr r$SszSoSHostnameMap.get_regex_resultcCs�y2t|jj�dd�djd�d}t|�d|_Wntk
rFYnXy<t|jj�dd�djd�}t|djd�d�d|_Wntk
r�YnXdS)	z�Set the initial counter for host and domain obfuscation numbers
        based on what is already present in the mapping.
        T)�reverser�hostrrrN)	�sortedr�valuesr�int�
host_count�
IndexErrorr�domain_count)r�h�drrr r\s  z!SoSHostnameMap.set_initial_countscsj||jkrdS|jd�}dj|jd�dd���t|�dkrJ|d|jkSt�fdd�|jD��rfdSdS)	zkCheck if a potential domain is in one of the domains we've loaded
        and should be obfuscated
        Trrrc3s|]}�j|�VqdS)N)�endswith)�.0Z_d)�no_tldrr �	<genexpr>{sz?SoSHostnameMap.domain_name_in_loaded_domains.<locals>.<genexpr>Fr)rrrrr�any)rrr(r)r3r �domain_name_in_loaded_domainsps

z,SoSHostnameMap.domain_name_in_loaded_domainscs�d}d}d}x&|jd	�r2||d7}|dd�}qWx&|jd
�rZ||d7}|dd�}q6W||jkrp|j|S|j|j��s�dj|||g�S|j|j�r�d|jd�d
}|j|d�}||7}||jk�r�x�t	|jj
�dtd�D]�}d}|j|�}|jd�}	|	d�r|	d|jk�rd}t|�dks�|d�r6q�|�rh|djd��sZ|j|��rht
�j|�}P|j|d�r�y,|j|d�d}
|dt
�j|
�}PWq�tk
�r�Yq�Xq�W|�s�t
�j|�}|||S)N�r�_rrT)r'�keyF)rr8)rr8rrr)rr1rr6�lowerr�
strip_extsrr"r)�keysrrr#�get�	Exception)rr%�prefix�suffix�finalZextrZ_host_substrZ_testZ_hZitm)r&rr r=�sR




zSoSHostnameMap.getc	Cs�|jd�}t|�dkr(|j|dj��St|�dkr\|j|�}tdd�|D��rX|j�}|St|�dkr�|d}|dd�}t|�dkr�|j|j��}nd}|j|�}||j|<dj||g�}tdd�|D��r�|j�}|SdS)	Nrrr�css|]}|j�VqdS)N)�isupper)r2r/rrr r4�sz/SoSHostnameMap.sanitize_item.<locals>.<genexpr>�unknowncss|]}|j�VqdS)N)rC)r2r/rrr r4�s)	rr�sanitize_short_namer:�sanitize_domain�all�upperrr)	rr%r(�dname�hostnamerZob_hostname�	ob_domainZ_fqdnrrr �
sanitize_item�s*



zSoSHostnameMap.sanitize_itemcCs`|s||jkr|S||jkrVd|j��}||j|<|jd7_||j|<|j|�|j|S)z�Obfuscate the short name of the host with an incremented counter
        based on the total number of obfuscated host names
        r(r)�	skip_keysrr,rZadd_regex_item)rrJZob_hostrrr rE�s



z"SoSHostnameMap.sanitize_short_namecCszx*|jD] }tj|dj|��rdj|�SqW|dj�}dj|dd��j�}|j|�}dj||g�}||jdj|�<|S)zeObfuscate the domainname, broken out into subdomains. Top-level
        domains are ignored.
        rrrrr)�ignore_matches�re�matchrr:�_new_obfuscated_domainr)rrZ_skipZ
top_domainrIrKrrr rF�s
zSoSHostnameMap.sanitize_domaincCs4||jkr*d|j��|j|<|jd7_|j|S)zDGenerate an obfuscated domain for each subdomain name given
        rr)rr.)rrIrrr rQ�s
z%SoSHostnameMap._new_obfuscated_domain)
rrrrrr	r
rrr
)�__name__�
__module__�__qualname__�__doc__rNrMr;Zignore_short_itemsZmatch_full_words_onlyr,r.rrr!r$rr6r=rLrErFrQ�
__classcell__rr)r&r rs.	= r)rOZsos.cleaner.mappingsrrrrrr �<module>s