AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/sos/cleaner/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/sos/cleaner/__pycache__/__init__.cpython-310.pyc
o

���b���@sddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZmZmZdd
lmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&Gdd�de�Z'dS)�N)�ThreadPoolExecutor)�datetime)�getpwuid)�__version__)�SoSComponent)�SoSIPParser)�SoSMacParser)�SoSHostnameParser)�SoSKeywordParser)�SoSUsernameParser)�SoSReportArchive�SoSReportDirectory�SoSCollectorArchive�SoSCollectorDirectory)�DataDirArchive�TarballArchive)�InsightsArchive)�get_human_readable)�fillcsLeZdZdZdZdggdgdddddgd	�Z		dH�fd
d�	ZdIdd
�ZdIdd�ZdIdd�Z	dIdd�Z
dd�Zedd��Z
dd�Zdd�Zedd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdJd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�ZdKd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dIdDdE�Z$dFdG�Z%�Z&S)L�
SoSCleanera�
    This function is designed to obfuscate potentially sensitive information
    from an sos report archive in a consistent and reproducible manner.

    It may either be invoked during the creation of a report by using the
    --clean option in the report command, or may be used on an already existing
    archive by way of 'sos clean'.

    The target of obfuscation are items such as IP addresses, MAC addresses,
    hostnames, usernames, and also keywords provided by users via the
    --keywords and/or --keyword-file options.

    For every collection made in a report the collection is parsed for such
    items, and when items are found SoS will generate an obfuscated replacement
    for it, and in all places that item is found replace the text with the
    obfuscated replacement mapped to it. These mappings are saved locally so
    that future iterations will maintain the same consistent obfuscation
    pairing.

    In the case of IP addresses, support is for IPv4 and efforts are made to
    keep network topology intact so that later analysis is as accurate and
    easily understandable as possible. If an IP address is encountered that we
    cannot determine the netmask for, a random IP address is used instead.

    For hostnames, domains are obfuscated as whole units, leaving the TLD in
    place.

    For instance, 'example.com' may be obfuscated to 'obfuscateddomain0.com'
    and 'foo.example.com' may end up being 'obfuscateddomain1.com'.

    Users will be notified of a 'mapping' file that records all items and the
    obfuscated counterpart mapped to them for ease of reference later on. This
    file should be kept private.
    z6Obfuscate sensitive networking information in a report�auto�N� /etc/sos/cleaner/default_mappingF�)�archive_type�domains�disable_parsers�jobs�keywords�keyword_file�map_file�	no_update�keep_binary_files�target�	usernamesc	s�|stt|��|||�d|_nC|d|_|d|_|d|_|d|_|d|_d|_t	|jd�s6d	|j_
d
|j_t�
d�|_t�
d�|_tjtj�|jd
�dd�|��|_t�d�||_|j��|_|jj�d
�|_t|j|jj�t|j�t |j�t!|j|jj"|jj#�t$|j|jj%�g|_&|jj'D]1}|j&D]+}|j(�)��*d�d�+�}|�)��+�|kr�|�,d|�|j�-d|�|j&�.|�q�q�t/t0t1t2t3t4t5g|_6d|_7|�,d|j�dS)NT�options�tmpdir�sys_tmp�policy�manifestFrrr�sos�sos_ui�cleaner��exist_ok�?�parserrzDisabling parser: %szaDisabling the '%s' parser. Be aware that this may leave sensitive plain-text data in the archive.z%Cleaner initialized. From cmdline: %s)8�superr�__init__�from_cmdline�optsr&r'r(r)�hasattrrr�logging�	getLogger�soslog�ui_log�os�makedirs�path�join�
load_map_file�cleaner_mapping�umask�in_place�get_preferred_hash_name�	hash_name�
components�add_section�
cleaner_mdr	rrrr
rrrr$�parsersr�name�lower�split�strip�log_info�warn�remover
rrrrrr�
archive_types�nested_archive)	�selfr0�args�cmdlinerA�hook_commons�_parser�_loaded�_loaded_name��	__class__��6/usr/lib/python3/dist-packages/sos/cleaner/__init__.pyr2Ysj






��	
�����

�zSoSCleaner.__init__cCsd|r
d||fSd|fS)Nz[cleaner%s] %sz:%srrZ�rQ�msg�callerrZrZr[�_fmt_log_msg�szSoSCleaner._fmt_log_msgcC�|j�|�||��dS�N)r8�debugr_r\rZrZr[�	log_debug��zSoSCleaner.log_debugcCr`ra)r8�infor_r\rZrZr[rL�rdzSoSCleaner.log_infocCr`ra)r8�errorr_r\rZrZr[�	log_error�rdzSoSCleaner.log_errorcCs0d}d}|��D]
}|t||dd�d}q|S)N�PrF)�replace_whitespace�
)�
splitlinesr)rQr]�width�_fmt�linerZrZr[�_fmt_msg�s
zSoSCleaner._fmt_msgcCs|�d�|�|j�dS)NzSoS Cleaner Detailed Help)�	set_title�add_text�__doc__)�cls�sectionrZrZr[�display_help�s
zSoSCleaner.display_helpcCsi}d}tj�|jj�rtd|jj��tj�|jj�s-|jj|kr+|�d|jj�|St|jjd��L}zt	�
|�}Wn+t	jyK|�d�Yn%tyg}z|�d|jj|f�WYd}~nd}~wwWd�|SWd�|SWd�|S1s�wY|S)z�Verifies that the map file exists and has usable content.

        If the provided map file does not exist, or it is empty, we will print
        a warning and continue on with cleaning building a fresh map
        rz$Requested map file %s is a directoryzHERROR: map file %s does not exist, will not load any obfuscation matches�rzOERROR: Unable to parse map file, json is malformed. Will not load any mappings.zERROR: Could not load '%s': %sN)r:r<�isdirr4r �	Exception�existsrg�open�json�load�JSONDecodeError)rQ�_conf�default_map�mf�errrZrZr[r>�sH���
�
����
�	�
�	�
�	�	zSoSCleaner.load_map_filec
Cs�|�d�}|j�dt�|j�|�|jjsLztd�WdSty3|j�d�|�d�YdSt	yK}z
|�d|�WYd}~dSd}~wwdS)z�When we are directly running `sos clean`, rather than hooking into
        SoSCleaner via report or collect, print a disclaimer banner
        a�This command will attempt to obfuscate information that is generally considered to be potentially sensitive. Such information includes IP addresses, MAC addresses, domain names, and any user-provided keywords.

Note that this utility provides a best-effort approach to data obfuscation, but it does not guarantee that such obfuscation provides complete coverage of all such data in the archive, or that any obfuscation is provided to data that does not fit the description above.

Users should review any resulting data and/or archives generated or processed by this utility for remaining sensitive content before being passed to a third party.
z
sos clean (version %s)
z-
Press ENTER to continue, or CTRL-C to quit.
z
Exiting on user cancel��N)
ror9rerr4�batch�input�KeyboardInterrupt�_exitrx)rQr]�erZrZr[�print_disclaimer�s
���zSoSCleaner.print_disclaimercCs�d|_|�dd�}|jdddd�|jdd	gd
�dd�|jd
dgdd�|jddgddd�|jdddtdd�|jddgddd�|jddddd �|jd!d"d#d$d%�|jd&d'd(d)d*d+�|jd,d(d)d-d.d/�|jd0d1gdd2d+�dS)3Nzsos clean|mask TARGET [options]zCleaner/Masking Optionsz7These options control how data obfuscation is performedr#�TARGETz%The directory or archive to obfuscate)�metavar�helpz--archive-typer)r�report�collect�insightszdata-dir�tarballz8Specify what kind of archive the target was generated as)�default�choicesr�z	--domains�extendz!List of domain names to obfuscate)�actionr�r�z--disable-parsersrzCDisable specific parsers, so that those elements are not obfuscated)r�r��destr�z-jz--jobsrz&Number of concurrent archives to clean)r��typer�z
--keywordsrzList of keywords to obfuscatez--keyword-filerz&Provide a file a keywords to obfuscate)r�r�r�z
--map-filer rz;Provide a previously generated mapping file for obfuscation)r�r�r�z--no-updater!F�
store_truez<Do not update the --map-file with new mappings from this run)r�r�r�r�z--keep-binary-filesr"zGKeep unprocessable binary files in the archive instead of removing them)r�r�r�r�z--usernamesr$zList of usernames to obfuscate)�usage�add_argument_group�add_argument�int)rsr0�	clean_grprZrZr[�add_parser_options�s^���
���
���
��

�zSoSCleaner.add_parser_optionscCs||j_dS)z�For use by report and collect to set the TARGET option appropriately
        so that execute() can be called just as if we were running `sos clean`
        directly from the cmdline.
        N)r4r#)rQr<rZrZr[�set_target_pathszSoSCleaner.set_target_pathcCs�d}|jjdkr$|jj�dd�}|jD]}|j|kr"||jj|j�}qn|jD]}|�|jj�r:||jj|j�}nq'|s?dS|j�	|�|j
rY|j�|���|j�
|�||_|jrd|jj|j_dSdS)z�The target path is not a directory, so inspect it for being an
        archive or an archive of archives.

        In the event the target path is not an archive, abort.
        Nr�-�_)r4r�replacerO�	type_namer#r&�
check_is_type�report_paths�append�	is_nestedr��get_nested_archivesrNrP�description�ui_name)rQ�_arc�
check_type�archive�arcrZrZr[�inspect_target_archive"s.

��
��z!SoSCleaner.inspect_target_archivecCsN|jj�d�d�d�d|_|jr|��g|_tj�	|jj�s0|j
�d|jj�|�d�|�
�|jsB|j
�d�|�d�g|_|��|��|��|jsd|jrYdS|j
�d	�|�d�|j
�d
t|j��|��}|�|�}|�|�|��|jr�dd�|jD�}||fSd}t|j�dkr�|��}nE|jd}|j}|�|j�}|dur�|�d
|�d�d|jf�}ttj�|j |�d��
}	|	�!|�Wd�n1s�wY|�"�|�tj�|j |�d�d��}t#�$||�t�%|�}
t&d|�t&d|�t&dt'|
j(��t&dt)|
j*�j+�t&d�|�,�dS)a,SoSCleaner will begin by inspecting the TARGET option to determine
        if it is a directory, archive, or archive of archives.

        In the case of a directory, the default behavior will be to edit the
        data in place. For an archive will we unpack the archive, iterate
        over the contents, and then repack the archive. In the case of an
        archive of archives, such as one from SoSCollector, each archive will
        be unpacked, cleaned, and repacked and the final top-level archive will
        then be repacked as well.
        �/���z.tarrz,Invalid target: no such file or directory %sr�z'No valid archives or directories found
Nz#No reports obfuscated, aborting...
z&
Successfully obfuscated %s report(s)
cSsg|]}|j�qSrZ)�final_archive_path)�.0�arZrZr[�
<listcomp>nsz&SoSCleaner.execute.<locals>.<listcomp>z%s.%s�wz4A mapping of obfuscated elements is available at
	%sz,
The obfuscated archive is available at
	%s
z	Size	%sz
	Owner	%s
zcPlease send the obfuscated archive to your support representative and keep the mapping file private)-r4r#rJ�arc_namer3r�r�r:r<ryr9rfr�r��completed_reports�preload_all_archives_into_maps�generate_parser_item_regexes�obfuscate_report_pathsrAre�len�compile_mapping_dict�write_map_for_archive�write_map_for_config�write_stats_to_manifest�rebuild_nested_archiver��get_new_checksum�obfuscate_stringrCrzr=r'�write�write_cleaner_log�shutil�move�stat�printr�st_sizer�st_uid�pw_name�cleanup)rQ�_map�map_path�	arc_paths�
final_path�arc_pathr��checksum�chksum_name�cf�arcstatrZrZr[�execute?sv�


�



���
�zSoSCleaner.executecCs�|jd}|j|d�|jD]#}|j�d�d}|�|j�}|dur1d||jf}|jj||d�qt	�
|jj�D],\}}}|D]$}	t	j
�||	�}
|
�|jj�d}|�d�}|jj|
|d�t	�|
�q@q9|jdd	�|j�|jj�S)
z�Handles repacking the nested tarball, now containing only obfuscated
        copies of the reports, log files, manifest, etc...
        z-obfuscated)rHr�r�Nzchecksums/%s.%s�r�T)r�)r��
setup_archiver�r�rJr�rCr��
add_stringr:�walkrP�extracted_pathr<r=�lstrip�add_filerNr��finalizer4�compression_type)rQr�r��arc_destr��dname�dirn�dirs�files�filename�fnamerZrZr[r��s&

�
�z!SoSCleaner.rebuild_nested_archivecCs2i}|jD]}i||j<||j�|jj�q|S)aBuild a dict that contains each parser's map as a key, with the
        contents as that key's value. This will then be written to disk in the
        same directory as the obfuscated report so that sysadmins have a way
        to 'decode' the obfuscation locally
        )rG�map_file_key�update�mapping�dataset)rQr�r0rZrZr[r��s


zSoSCleaner.compile_mapping_dictcCsDt|d��}|�tj|dd��Wd�|S1swY|S)zjWrite the mapping to a file on disk that is in the same location as
        the final archive(s).
        r�r)�indentN)rzr�r{�dumps)rQr�r<r�rZrZr[�write_map_to_file�s
��zSoSCleaner.write_map_to_filec
Cs`ztj�|j|�d|j��}|�||�WSty/}z|�d|�WYd}~dSd}~ww)Nz%s-private_mapz$Could not write private map file: %s)	r:r<r=r'r�r�r�rxrg)rQr�r�r�rZrZr[r��s���z SoSCleaner.write_map_for_archivec
Cs�|jjrG|jjsItj�|jj�}	ztj|dd�|�||jj�|�d|jj�WdSt	yF}z|�
d|�WYd}~dSd}~wwdSdS)z}Write the mapping to the config file so that subsequent runs are
        able to provide the same consistent mapping
        Tr-zWrote mapping to %sz(Could not update mapping config file: %sN)r4r r!r:r<�dirnamer;r�rcrxrg)rQr��cleaner_dirr�rZrZr[r��s����zSoSCleaner.write_map_for_configcCs�tj�|jd|j�}t|d��}|j�d�|j��D]}|�	|�qWd�n1s.wY|rD|�
|�|jj|dd�dSdS)z�When invoked via the command line, the logging from SoSCleaner will
        not be added to the archive(s) it processes, so we need to write it
        separately to disk
        z%s-obfuscation.logr�rNzsos_logs/cleaner.logr�)
r:r<r=r'r�rz�sos_log_file�seek�	readlinesr��obfuscate_filer�r�)rQr��log_name�logfilernrZrZr[r��s���
�zSoSCleaner.write_cleaner_logc
Cs�z'd}t|d�}t�|j�}	|�|�}|sn|�|�q|��|��dWStyA}z|�	d|�WYd}~dSd}~ww)zvCalculate a new checksum for the obfuscated archive, as the previous
        checksum will no longer be valid
        i�rbTrjz#Could not generate new checksum: %sN)
rz�hashlib�newrC�readr��close�	hexdigestrxrc)rQ�archive_path�	hash_size�
archive_fp�digest�hashdatar�rZrZr[r��s"


���zSoSCleaner.get_new_checksumcCs�zDdt|j�|jjf}|j�|�|jjr|j�d�t|jj�}|j	|j
|jdd�|jdd�|jrB|�
�|�
|j�Wd	SWd	StyY|j�d�t�d�Yd	Sw)
z�Perform the obfuscation for each archive or sos directory discovered
        during setup.

        Each archive is handled in a separate thread, up to self.opts.jobs will
        be obfuscated concurrently.
        zFFound %s total reports to obfuscate, processing up to %s concurrently
zpWARNING: binary files that potentially contain sensitive information will NOT be removed from the final archive
r�)�	chunksizeT)�waitzExiting on user cancelr�N)r�r�r4rr9rer"�warningr�map�obfuscate_report�shutdownrP�_replace_obfuscated_archivesr�r:r�)rQr]�poolrZrZr[r�s*�����z!SoSCleaner.obfuscate_report_pathscCsV|jD]%}t�|j�|jj}|j�d�d}tj�	||�}t
�|j|�||_qdS)z�When we have a nested archive, we need to rebuild the original
        archive, which entails replacing the existing archives with their
        obfuscated counterparts
        r�r�N)r�r:rNr�rPr�r�rJr<r=r�r�)rQr�r�r��	dest_namerZrZr[rs
�z'SoSCleaner._replace_obfuscated_archivescCs|jD]}|��qdS)z�For the parsers that use prebuilt lists of items, generate those
        regexes now since all the parsers should be preloaded by the archive(s)
        as well as being handed cmdline options and mapping file configuration.
        N)rG�generate_item_regexes)rQr0rZrZr[r�*s

�z'SoSCleaner.generate_parser_item_regexesc
CsF|�d�|jD]�}|jD]�}z|j|j����d}|s Wq
Wnttfy,Yq
wt	|t
�r5|g}|D]g}|�d|�z?|�|�}|sJWq7t	|t
�rU|�|�n)t	|t�rrd|vrh|�|��d�nd|vrq|�|�n|��D]}|�|�qvWq7ty�}z|�d|j||j|f�WYd}~q7d}~wwq
qdS)aBefore doing the actual obfuscation, if we have multiple archives
        to obfuscate then we need to preload each of them into the mappings
        to ensure that node1 is obfuscated in node2 as well as node2 being
        obfuscated in node1's archive.
        z.Pre-loading all archives into obfuscation mapsrzAttempting to load %s�hostnamez	etc/hostsz.Could not prepare %s from %s (archive: %s): %sN)rLr�rG�
prep_filesrHrIrJ�
IndexError�KeyError�
isinstance�strrc�get_file_contentr�load_usernames_into_mapr	�load_hostname_into_maprk�load_hostname_from_etc_hosts�obfuscate_linerx�archive_name)rQr�rU�pfile�
parse_file�contentrnr�rZrZr[r�2s^


��




����
��������z)SoSCleaner.preload_all_archives_into_mapscCs��z<|j�|j�}t��}|�d|�|js|��|�d�|�	�D]N}|�
|jd�d}|�|�r5q#|jj
sD|�|�rD|�|�q#z|�|||j�}|rU|�||�Wq#tyq}z|�d||f�WYd}~q#d}~wwz|�|�Wnty�}z|jd||jd�WYd}~nd}~wwz|�|�Wnty�}z|jd	||jd�WYd}~nd}~ww|j�s|��}|r�|�d
�z|�|�|j��|�|�Wn%ty�}z|�d|j|f�|�d|�WYd}~WdSd}~ww|j�|�t��}	|�d
|	�|�d|	|�|�dt|j��|�d|j �d}
|j!�r4d}
|
|j!}
|�d|
�WdSt�y\}z|j"�#d|j|f�WYd}~dSd}~ww)z�Individually handle each archive or directory we've discovered by
        running through each file therein.

        Positional arguments:

            :param report str:      Filepath to the directory or archive
        �
start_timezBeginning obfuscation...r�r�zUnable to parse file %s: %sNz#Failed to obfuscate directories: %s�r^z Failed to obfuscate symlinks: %szRe-compressing...z!Archive %s failed to compress: %sz!Failed to re-compress archive: %s�end_time�run_time�files_obfuscated�total_substitutionsrz! [removed %s unprocessable files]zObfuscation completed%sz!Exception while processing %s: %s)$rFrErr�now�	add_field�is_extracted�extract�
report_msg�
get_file_listrJ�should_skip_filer4r"�should_remove_file�remove_filer��update_sub_countrxrc�obfuscate_directory_namesrL�obfuscate_symlinksr��get_compression�rename_top_dirr��compressr�r�r��
file_sub_list�total_sub_count�removed_file_countr9re)rQr��arc_mdrr��
short_name�countr��methodr�rmsgrZrZr[r^s�

�
�����
���
���

�����
���zSoSCleaner.obfuscate_reportcs�|sdSd}�s|�d�d�tj�|�s�|jd�p||d�tjd|jd�}�fd	d
�|jD�}t	|d��=}|D]2}z|�
||�\}}	||	7}|�|�Wq:tyl}
z|jd�|
f|d�WYd}
~
q:d}
~
wwWd�n1swwY|�
d�|r�t�|j|�|��|���d�d�}����d�d|�}|�kr�|���d}
tj�|
|�}tj�|�s�t�||�|S|�t�|��}t�|�t�||�|S)
a5Obfuscate and individual file, line by line.

        Lines processed, even if no substitutions occur, are then written to a
        temp file without our own tmpdir. Once the file has been completely
        iterated through, if there have been substitutions then the temp file
        overwrites the original file. If there are no substitutions, then the
        original file is left in place.

        Positional arguments:

            :param filename str:        Filename relative to the extracted
                                        archive root
        Nrr�r�zObfuscating %srr�)�mode�dircs(g|]}t�fdd�|jD��s|�qS)c3s�|]}|���VqdSra)�match)r��_skip�r3rZr[�	<genexpr>�s�

�z7SoSCleaner.obfuscate_file.<locals>.<listcomp>.<genexpr>)�any�
skip_patterns)r��_pr;rZr[r��s���z-SoSCleaner.obfuscate_file.<locals>.<listcomp>rvzUnable to obfuscate %s: %s)rJr:r<�islinkrc�tempfile�NamedTemporaryFiler&rGrzrr�rxr�r��copyrHr�r�r�r=�rename�readlinkrN�symlink)rQr�r3r��subs�tfile�_parsersr�rnr4r��_ob_short_name�_ob_filenamer��_ob_path�
_target_obrZr;r[r��s^�
�������
	��
zSoSCleaner.obfuscate_filecCs�|jd|jd�|��D]\}z?|�|j�d�d�}|jd||jd�t�|�}tj	�
|j|�|��}|�|�}||ksA||krLt�|�t�
||�Wqtyh}z|�d||f�WYd}~qd}~wwdS)a�Iterate over symlinks in the archive and obfuscate their names.
        The content of the link target will have already been cleaned, and this
        second pass over just the names of the links is to ensure we avoid a
        possible race condition dependent on the order in which the link or the
        target get obfuscated.

        :param archive:     The archive being obfuscated
        :type archive:      ``SoSObfuscationArchive``
        zObfuscating symlink namesrr�r�zObfuscating symlink %sz"Error obfuscating symlink '%s': %sN)rLr�get_symlinksrJr�r�rcr:rEr<r=r�rNrFrx)rQr�rF�_sym�_target�_ob_sym_name�
_ob_targetr�rZrZr[r+�s.

�

�

�����zSoSCleaner.obfuscate_symlinkscCs�|�d|j�t|��dd�D]?}t�|�D]7}tj�||�}|�|j	�d}tj�
|�rN|�|�}||krN|�|�}tj�|j	|�
d�|�}t�||�qqdS)z�For all directories that exist within the archive, obfuscate the
        directory name if it contains sensitive strings found during execution
        z)Obfuscating directory names in archive %sT)�reverser�r�N)rLr�sorted�get_directory_listr:�listdirr<r=rJr�rwr��rstripr�rD)rQr��dirpath�_name�_dirname�_arc_dir�_ob_dirname�_ob_arc_dirrZrZr[r*s(�

����z$SoSCleaner.obfuscate_directory_namescCsP|jD]"}z|�|�}Wqty%}z
|�d|�WYd}~qd}~ww|S)Nz!Error obfuscating string data: %s)rG�parse_string_for_keysrxrL)rQ�string_datar0r�rZrZr[r�+s
��zSoSCleaner.obfuscate_stringcCs�d}|��s
||fS|dur|j}|D]*}z
|�|�\}}||7}Wqty=}z|�d||j�WYd}~qd}~ww||fS)a�Run a line through each of the obfuscation parsers, keeping a
        cumulative total of substitutions done on that particular line.

        Positional arguments:

            :param line str:        The raw line as read from the file being
                                    processed
            :param parsers:         A list of parser objects to obfuscate
                                    with. If None, use all.

        Returns the fully obfuscated line and the number of substitutions made
        rNzfailed to parse line: %s)rKrG�
parse_linerxrcrH)rQrnrGr4r0�_countr�rZrZr[r3s��zSoSCleaner.obfuscate_linecCsL|j�d�}|jD]}|�|j�dd����}|�dt|jj	�
���q	dS)zLWrite some cleaner-level, non-report-specific stats to the manifest
        rG� r��entriesN)rFrErGrHr�rIr!r�r�r��keys)rQ�	parse_secr0�_secrZrZr[r�Os

�z"SoSCleaner.write_stats_to_manifest)NNNFNra)F)NN)'�__name__�
__module__�__qualname__rr�desc�arg_defaultsr2r_rcrLrgro�classmethodrur>r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rr�r+r*r�rr��
__classcell__rZrZrXr[r%sd#��
D




,T


,
OF#
r)(r�r{r6r:r�rA�concurrent.futuresrr�pwdrr*r�
sos.componentr�sos.cleaner.parsers.ip_parserr�sos.cleaner.parsers.mac_parserr�#sos.cleaner.parsers.hostname_parserr	�"sos.cleaner.parsers.keyword_parserr
�#sos.cleaner.parsers.username_parserr�sos.cleaner.archives.sosrr
rr�sos.cleaner.archives.genericrr�sos.cleaner.archives.insightsr�
sos.utilitiesr�textwraprrrZrZrZr[�<module>s,


Anon7 - 2022
AnonSec Team