HEX
Server: LiteSpeed
System: Linux node612.namehero.net 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: dfwparty (1186)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/sos/cleaner/mappings/__pycache__/hostname_map.cpython-36.opt-1.pyc
3

ܓ�i�!�@s(ddlZddlmZGdd�de�ZdS)�N)�SoSMapc
s�eZdZdZdddgZddgZd#ZdZdZdZ	dZ
iZiZ�fdd�Z
dd�Zdd�Z�fdd�Zdd�Zdd�Zdd �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�.cfgTrcs 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.
        �.z(\.|_))�replace�super�get_regex_result)�self�item)�	__class__��"/usr/lib/python3.6/hostname_map.pyr5s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�host��domainrN)	�sorted�hosts�values�split�int�
host_count�
IndexError�_domains�domain_count)r�h�drrr�set_initial_counts>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>F���)r"r�join�lenr�any)rrrr)r)r�domain_name_in_loaded_domainsRs

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)rr1)rr1r+r+r+)�
startswithr'�datasetr/�lowerr,�
strip_extsrrr�keysr-rr�get�	Exception)rr�prefix�suffix�finalZextZ	_existingZ_host_substrZ_testZ_hZitm)rrrr8bsR




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)r(r$rrrr*�sz/SoSHostnameMap.sanitize_item.<locals>.<genexpr>�unknowncss|]}|j�VqdS)N)r>)r(r$rrrr*�s)	rr-�sanitize_short_namer5�sanitize_domain�all�upperr4r,)	rrr�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
        rr)�	skip_keysr4r rZadd_regex_item)rrEZob_hostrrrr@�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.
        rrrr+r+)�ignore_matches�re�matchr,r5�_new_obfuscated_domainr4)rrZ_skipZ
top_domainrDrFrrrrA�s
zSoSHostnameMap.sanitize_domaincCs4||jkr*d|j��|j|<|jd7_|j|S)zDGenerate an obfuscated domain for each subdomain name given
        Zobfuscateddomainr)r"r#)rrDrrrrL�s
z%SoSHostnameMap._new_obfuscated_domain)
rrrrrr	r
rrr
)�__name__�
__module__�__qualname__�__doc__rIrHr6Zignore_short_itemsZmatch_full_words_onlyr r#r"rrr&r/r8rGr@rArL�
__classcell__rr)rrrs,	= r)rJZsos.cleaner.mappingsrrrrrr�<module>s