HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sos/cleaner/mappings/__pycache__/__init__.cpython-310.pyc
o

([Qh
�@s&ddlZddlmZGdd�d�ZdS)�N)�Lockc@sdeZdZdZgZgZdZdZdZdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�ZdS)�SoSMapz�Standardized way to store items with their obfuscated counterparts.

    Each type of sanitization that SoSCleaner supports should have a
    corresponding SoSMap() object, to allow for easy retrieval of obfuscated
    items.
    TFcCs i|_t�|_g|_t�|_dS)N)�dataset�set�
_regexes_made�compiled_regexesr�lock)�self�r
�?/usr/lib/python3/dist-packages/sos/cleaner/mappings/__init__.py�__init__szSoSMap.__init__cCsX|r||jvs||j��vs|jrt|�dkrdS|jD]
}t�||tj�r)dSqdS)z�Some items need to be completely ignored, for example link-local or
        loopback addresses should not be obfuscated
        �TF)	�	skip_keysr�values�ignore_short_items�len�ignore_matches�re�match�I)r	�item�skipr
r
r�ignore_item%s�
�zSoSMap.ignore_itemcCsb|�|�r|S|j�|�|�|j|<|jr|�|�|j|Wd�S1s*wYdS)z�Add a particular item to the map, generating an obfuscated pair
        for it.

        Positional arguments:

            :param item:        The plaintext object to obfuscate
        N)rr�
sanitize_itemr�compile_regexes�add_regex_item�r	rr
r
r�add1s

$�z
SoSMap.addcCsV|�|�rdS||jvr)|j�|�|j�||�|�f�|jjdd�dd�dSdS)z�Add an item to the regexes dict and then re-sort the list that the
        parsers will use during parse_line()

        :param item:    The unobfuscated item to generate a regex for
        :type item:     ``str``
        NcSst|d�S)Nr)r)�xr
r
r�<lambda>Vsz'SoSMap.add_regex_item.<locals>.<lambda>T)�key�reverse)rrrr�append�get_regex_result�sortrr
r
rrAs

�zSoSMap.add_regex_itemcCs2|jr
dt�|��d�}nt�|�}t�|tj�S)a9Generate the object/value that is used by the parser when iterating
        over pre-generated regexes during parse_line(). For most parsers this
        will simply be a ``re.Pattern()`` object, but for more complex parsers
        this can be overridden to provide a different object, e.g. a tuple,
        for that parer's specific iteration needs.

        :param item:    The unobfuscated string to generate the regex for
        :type item:     ``str``

        :returns:       A compiled regex pattern for the item
        :rtype:         ``re.Pattern``
        z
(?<![a-z0-9])z
(?=\b|_|-))�match_full_words_onlyr�escape�compilerrr
r
rr#Xs

zSoSMap.get_regex_resultcCs|S)z�Perform the obfuscation relevant to the item being added to the map.

        This should be overridden by each type of map that subclasses SoSMap

        Positional arguments:

            :param item:        The plaintext object to obfuscate
        r
rr
r
rrks	zSoSMap.sanitize_itemcCs,|�|�r|S||jvr|�|�S|j|S)z�Retrieve an item's obfuscated counterpart from the map. If the item
        does not yet exist in the map, add it by generating one on the fly
        )rrrrr
r
r�getvs




z
SoSMap.getcCs|j�|�dS)a%Update the map using information from a previous run to ensure that
        we have consistent obfuscation between reports

        Positional arguments:

            :param config:    A dict of mappings with the form of
                              {clean_entry: 'obfuscated_entry'}
        N)r�update)r	�configr
r
r�conf_update�s	zSoSMap.conf_updateN)�__name__�
__module__�__qualname__�__doc__rrrrr%rrrrr#rr(r+r
r
r
rrs
r)r�	threadingrrr
r
r
r�<module>s