%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/sos/cleaner/mappings/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/sos/cleaner/mappings/__pycache__/__init__.cpython-312.pyc

�

i��d���,�ddlZddlmZGd�d�Zy)�N)�Lockc�L�eZdZdZgZgZdZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zy)�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.
    Tc�\�i|_t�|_g|_t	�|_y)N)�dataset�set�
_regexes_made�compiled_regexesr�lock)�selfs �?/usr/lib/python3/dist-packages/sos/cleaner/mappings/__init__.py�__init__zSoSMap.__init__s$����� �U��� "����F��	�c���|r*||jvs||jj�vry|jD])}t	j
||tj�s�)yy)z�Some items need to be completely ignored, for example link-local or
        loopback addresses should not be obfuscated
        TN)�	skip_keysr�values�ignore_matches�re�match�I)r�item�skips   r
�ignore_itemzSoSMap.ignore_item#sU���t�t�~�~�-�����9L�9L�9N�1N���'�'�	�D��x�x��d�B�D�D�)��	rc��|j|�r|S|j5|j|�|j|<|jr|j|�|j|cddd�S#1swYyxYw)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rs  r
�addz
SoSMap.add-so�����D�!��K�
�Y�Y�	&�!%�!3�!3�D�!9�D�L�L����#�#��#�#�D�)��<�<��%�		&�	&�	&�s�A
A4�4A=c��|j|�ry||jvrf|jj|�|jj	||j|�f�|jj
d�d��yy)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``
        Nc��t|d�S)Nr)�len)�xs r
�<lambda>z'SoSMap.add_regex_item.<locals>.<lambda>Rs��S��1��Y�rT)�key�reverse)rr	rr
�append�get_regex_result�sortrs  r
rzSoSMap.add_regex_item=s~�����D�!���t�)�)�)�

���"�"�4�(�
�!�!�(�(�$��0E�0E�d�0K�)L�M��!�!�&�&�+>��&�M�*rc�p�tjtj|�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``
        )r�compile�escaperrs  r
r(zSoSMap.get_regex_resultTs!���z�z�"�)�)�D�/�2�4�4�0�0rc��|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
        �rs  r
rzSoSMap.sanitize_itemcs	���rc��|j|�r|S||jvr|j|�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
        )rrrrs  r
�getz
SoSMap.getns@�����D�!��K��t�|�|�#��8�8�D�>�!��|�|�D�!�!rc�:�|jj|�y)a)Update the map using information from a previous run to ensure that
        we have consistent obfuscation between reports

        Positional arguments:

            :param map_dict:    A dict of mappings with the form of
                                {clean_entry: 'obfuscated_entry'}
        N)r�update)r�map_dicts  r
�conf_updatezSoSMap.conf_updatexs��	
�����H�%rN)�__name__�
__module__�__qualname__�__doc__rrrrrrrr(rr0r4r.rr
rrsA����N��I��O���&� N�.
1�	�"�	&rr)r�	threadingrrr.rr
�<module>r:s��
��q&�q&r

Zerion Mini Shell 1.0