Your IP : 216.73.217.13


Current Path : /usr/lib/python3/dist-packages/sos/cleaner/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/sos/cleaner/__pycache__/__init__.cpython-38.pyc

U

���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sHeZdZdZdZdggdgdddddgd	�ZdH�fd
d�	ZdIdd
�ZdJdd�ZdKdd�Z	dLdd�Z
dd�Zedd��Z
dd�Zdd�Zedd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdMd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�ZdNd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dOdDdE�Z$dFdG�Z%�Z&S)P�
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�|s tt|��|||�d|_n�|d|_|d|_|d|_|d|_|d|_d|_t	|jd�sld	|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]h}|j&D]Z}|j(�)��*d�d�+�}|�)��+�|k�r4|�,d|�|j�-d|�|j&�.|��q4�q*t/t0t1t2t3t4t5g|_6d|_7|�,d|j�dS)NTZoptions�tmpdir�sys_tmp�policy�manifestFrrr�sosZsos_uiZcleaner��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�loggingZ	getLogger�soslog�ui_log�os�makedirs�path�join�
load_map_fileZcleaner_mapping�umask�in_placeZget_preferred_hash_name�	hash_nameZ
components�add_section�
cleaner_mdr	rrrr
rrrr$�parsersr�name�lower�split�strip�log_info�warn�remover
rrrrrr�
archive_types�nested_archive)	�selfr-�argsZcmdliner<Zhook_commons�_parserZ_loadedZ_loaded_name��	__class__��6/usr/lib/python3/dist-packages/sos/cleaner/__init__.pyr/Ysf






��	
���
�zSoSCleaner.__init__cCsd|rd|nd|fS)Nz[cleaner%s] %sz:%srrO�rJ�msg�callerrOrOrP�_fmt_log_msg�szSoSCleaner._fmt_log_msgcCs|j�|�||��dS�N)r4�debugrTrQrOrOrP�	log_debug�szSoSCleaner.log_debugcCs|j�|�||��dSrU)r4�inforTrQrOrOrPrE�szSoSCleaner.log_infocCs|j�|�||��dSrU)r4�errorrTrQrOrOrP�	log_error�szSoSCleaner.log_errorcCs0d}d}|��D]}|t||dd�d}q|S)N�PrF)Zreplace_whitespace�
)�
splitlinesr)rJrR�widthZ_fmt�linerOrOrP�_fmt_msg�s
zSoSCleaner._fmt_msgcCs|�d�|�|j�dS)NzSoS Cleaner Detailed Help)Z	set_titleZadd_text�__doc__)�clsZsectionrOrOrP�display_help�s
zSoSCleaner.display_helpcCs�i}d}tj�|jj�r(td|jj��tj�|jj�sX|jj|kr�|�d|jj�n�t|jjd��l}zt	�
|�}WnVt	jk
r�|�d�Yn8tk
r�}z|�d|jj|f�W5d}~XYnXW5QRX|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)r6r8�isdirr1r �	Exception�existsrZ�open�json�loadZJSONDecodeError)rJZ_confZdefault_map�mf�errrOrOrPr:�s.���
�"zSoSCleaner.load_map_filec
Cs�|�d�}|j�dt�|j�|�|jjs�ztd�WnVtk
rd|j�d�|�d�Yn.t	k
r�}z|�d|�W5d}~XYnXdS)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)
r`r5rXrr1Zbatch�input�KeyboardInterrupt�_exitrf)rJrR�erOrOrP�print_disclaimer�s
zSoSCleaner.print_disclaimerc	Cs�d|_|�dd�}|jdddd�|jdd	d	d
ddd
dgdd�|jddgdd�|jddgddd�|jdddtdd�|jddgdd d�|jd!dd"d#d$�|jd%d&d'd(d)�|jd*d+d,d-d.d/�|jd0d,d-d1d2d3�|jd4d5gdd6d/�dS)7Nzsos clean|mask TARGET [options]zCleaner/Masking Optionsz7These options control how data obfuscation is performedr#ZTARGETz%The directory or archive to obfuscate)�metavar�helpz--archive-typer�reportZcollectZinsightszdata-dir�tarballz8Specify what kind of archive the target was generated as)�default�choicesruz	--domains�extendz!List of domain names to obfuscate)�actionrxruz--disable-parsersrzCDisable specific parsers, so that those elements are not obfuscated)r{rx�destruz-jz--jobsrz&Number of concurrent archives to clean)rx�typeruz
--keywordsrzList of keywords to obfuscatez--keyword-filerz&Provide a file a keywords to obfuscate)rxr|ruz
--map-filer rz;Provide a previously generated mapping file for obfuscation)r|rxruz--no-updater!F�
store_truez<Do not update the --map-file with new mappings from this run)r|rxr{ruz--keep-binary-filesr"zGKeep unprocessable binary files in the archive instead of removing them)rxr{r|ruz--usernamesr$zList of usernames to obfuscate)ZusageZadd_argument_group�add_argument�int)rbr-Z	clean_grprOrOrP�add_parser_options�sh����
���
���
��
�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)r1r#)rJr8rOrOrP�set_target_pathszSoSCleaner.set_target_pathcCs�d}|jjdkrH|jj�dd�}|jD]}|j|kr&||jj|j�}q&n.|jD]&}|�|jj�rN||jj|j�}qvqN|s~dS|j�	|�|j
r�|j�|���|j�
|�||_|jr�|jj|j_dS)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�-�_)r1r�replacerHZ	type_namer#r%Z
check_is_type�report_paths�append�	is_nestedrzZget_nested_archivesrGrIZdescriptionZui_name)rJ�_arcZ
check_type�archive�arcrOrOrP�inspect_target_archive"s&


z!SoSCleaner.inspect_target_archivec	Cs@|jj�d�d�d�d|_|jr,|��g|_tj�	|jj�s`|j
�d|jj�|�d�|�
�|js�|j
�d�|�d�g|_|��|��|��|js�|jr�dS|j
�d	�|�d�|j
�d
t|j��|��}|�|�}|�|�|��|j�r"dd�|jD�}||fSd}t|j�dk�r@|��}nx|jd}|j}|�|j�}|dk	�r�|�d
|�d�d|jf�}ttj�|j |�d��}	|	�!|�W5QRX|�"�|�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 %srnz'No valid archives or directories found
Nz#No reports obfuscated, aborting...
z&
Successfully obfuscated %s report(s)
cSsg|]
}|j�qSrO)�final_archive_path)�.0�arOrOrP�
<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)-r1r#rC�arc_namer0rsr�r6r8rgr5rYrqr��completed_reports�preload_all_archives_into_maps�generate_parser_item_regexes�obfuscate_report_pathsr<rX�len�compile_mapping_dict�write_map_for_archive�write_map_for_config�write_stats_to_manifest�rebuild_nested_archiver��get_new_checksum�obfuscate_stringr=rhr9r&�write�write_cleaner_log�shutil�move�stat�printr�st_sizer�st_uidZpw_nameZcleanup)rJ�_map�map_pathZ	arc_pathsZ
final_path�arc_pathr��checksumZchksum_nameZcfZarcstatrOrOrP�execute?st�


�




��
�zSoSCleaner.executecCs�|jd}|j|d�|jD]F}|j�d�d}|�|j�}|dk	rd||jf}|jj||d�qt	�
|jj�D]X\}}}|D]H}	t	j
�||	�}
|
�|jj�d}|�d�}|jj|
|d�t	�|
�q�qr|jdd	�|j�|jj�S)
z�Handles repacking the nested tarball, now containing only obfuscated
        copies of the reports, log files, manifest, etc...
        z-obfuscated)rAr�r�Nzchecksums/%s.%s�r|T)r�)r�Z
setup_archiver�r�rCr�r=r�Z
add_stringr6�walkrI�extracted_pathr8r9�lstrip�add_filerGr��finalizer1Zcompression_type)rJr�r�Zarc_destr�ZdnameZdirn�dirs�files�filename�fnamerOrOrPr��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
        )r@Zmap_file_key�update�mapping�dataset)rJr�r-rOrOrPr��s


zSoSCleaner.compile_mapping_dictc	Cs.t|d��}|�tj|dd��W5QRX|S)zjWrite the mapping to a file on disk that is in the same location as
        the final archive(s).
        r�r)�indent)rhr�ri�dumps)rJr�r8rkrOrOrP�write_map_to_file�szSoSCleaner.write_map_to_filec
Csfz*tj�|j|�d|j��}|�||�WStk
r`}z|�d|�WY�dSd}~XYnXdS)Nz%s-private_mapz$Could not write private map file: %s)	r6r8r9r&r�r�r�rfrZ)rJr�r�rlrOrOrPr��s�z SoSCleaner.write_map_for_archivec
Cs�|jjr�|jjs�tj�|jj�}z4tj|dd�|�||jj�|�d|jj�Wn0t	k
r�}z|�
d|�W5d}~XYnXdS)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)r1r r!r6r8�dirnamer7r�rWrfrZ)rJr�Zcleaner_dirrlrOrOrPr��s�zSoSCleaner.write_map_for_configc	Csttj�|jd|j�}t|d��,}|j�d�|j��D]}|�	|�q8W5QRX|rp|�
|�|jj|dd�dS)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�rzsos_logs/cleaner.logr�N)
r6r8r9r&r�rhZsos_log_file�seek�	readlinesr��obfuscate_filer�r�)rJr�Zlog_nameZlogfiler_rOrOrPr��s�
zSoSCleaner.write_cleaner_logc
Cs�zLd}t|d�}t�|j�}|�|�}|s,q8|�|�q|��|��dWStk
r|}z|�	d|�W5d}~XYnXdS)zvCalculate a new checksum for the obfuscated archive, as the previous
        checksum will no longer be valid
        i�rbr\z#Could not generate new checksum: %sN)
rh�hashlib�newr=�readr��closeZ	hexdigestrfrW)rJ�archive_pathZ	hash_sizeZ
archive_fpZdigestZhashdatarlrOrOrPr��s

 zSoSCleaner.get_new_checksumcCs�z�dt|j�|jjf}|j�|�|jjr8|j�d�t|jj�}|j	|j
|jdd�|jdd�|jr~|�
�|�
|j�Wn*tk
r�|j�d�t�d�YnXd	S)
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
rn)Z	chunksizeT)�waitzExiting on user cancelrmN)r�r�r1rr5rXr"Zwarningr�map�obfuscate_reportZshutdownrI�_replace_obfuscated_archivesrpr6rq)rJrRZpoolrOrOrPr�s&���z!SoSCleaner.obfuscate_report_pathscCsV|jD]J}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�r6rGr�rIr�r�rCr8r9r�r�)rJr�r|rwZ	dest_namerOrOrPr�s
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)r@Zgenerate_item_regexes)rJr-rOrOrPr�*s
z'SoSCleaner.generate_parser_item_regexesc
CsR|�d�|jD�]:}|jD�],}z$|j|j����d}|sDWqWnttfk
rbYqYnXt	|t
�rt|g}|D]�}|�d|�z~|�|�}|s�Wqxt	|t
�r�|�|�nRt	|t�r�d|kr�|�|��d�nd|kr�|�|�n|��D]}|�|�q�Wqxtk
�rF}z|�d|j||j|f�W5d}~XYqxXqxqqdS)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 %sZhostnamez	etc/hostsz.Could not prepare %s from %s (archive: %s): %sN)rEr�r@Z
prep_filesrArBrC�
IndexError�KeyError�
isinstance�strrWZget_file_contentrZload_usernames_into_mapr	Zload_hostname_into_mapr]Zload_hostname_from_etc_hosts�obfuscate_linerf�archive_name)rJr�rLZpfileZ
parse_fileZcontentr_rlrOrOrPr�2sL






��
���z)SoSCleaner.preload_all_archives_into_mapscCs��z||j�|j�}t��}|�d|�|js4|��|�d�|�	�D]�}|�
|jd�d}|�|�rjqF|jj
s�|�|�r�|�|�qFz$|�|||j�}|r�|�||�WqFtk
r�}z|�d||f�W5d}~XYqFXqFz|�|�Wn8tk
�r*}z|jd||jd�W5d}~XYnXz|�|�Wn8tk
�rr}z|jd	||jd�W5d}~XYnX|j�s|��}|�r|�d
�z |�|�|j��|�|�WnNtk
�r}z.|�d|j|f�|�d|�WY�WdSd}~XYnX|j�|�t��}	|�d
|	�|�d|	|�|�dt|j��|�d|j �d}
|j!�rnd}
|
|j!}
|�d|
�Wn:tk
�r�}z|j"�#d|j|f�W5d}~XYnXdS)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�rnzUnable to parse file %s: %sNz#Failed to obfuscate directories: %s�rSz Failed to obfuscate symlinks: %szRe-compressing...z!Archive %s failed to compress: %sz!Failed to re-compress archive: %s�end_timeZrun_timeZfiles_obfuscatedZtotal_substitutionsrz! [removed %s unprocessable files]zObfuscation completed%sz!Exception while processing %s: %s)$r?r>r�rZnow�	add_fieldZis_extracted�extractZ
report_msgZ
get_file_listrCZshould_skip_filer1r"Zshould_remove_fileZremove_filer�Zupdate_sub_countrfrW�obfuscate_directory_namesrE�obfuscate_symlinksr�Zget_compressionZrename_top_dirr��compressr�r�r�Z
file_sub_listZtotal_sub_countZremoved_file_countr5rX)rJr�Zarc_mdr�r��
short_name�countrl�methodr�ZrmsgrOrOrPr�^s�

�
��
�
�

���
�zSoSCleaner.obfuscate_reportcs�|sdSd}�s|�d�d�tj�|��s|jd�p:||d�tjd|jd�}�fd	d
�|jD�}t	|d��p}|D]d}z&|�
||�\}}	||	7}|�|�Wqvtk
r�}
z|jd�|
f|d�W5d}
~
XYqvXqvW5QRX|�
d�|�rt�|j|�|��|���d�d�}����d�d|�}|�k�r�|���d}
tj�|
|�}tj�|��sxt�||�n&|�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 %sr�r�)�mode�dircs(g|] }t�fdd�|jD��s|�qS)c3s|]}|���VqdSrU)�match)r�Z_skip�r�rOrP�	<genexpr>�sz7SoSCleaner.obfuscate_file.<locals>.<listcomp>.<genexpr>)�anyZ
skip_patterns)r�Z_pr�rOrPr��s
��z-SoSCleaner.obfuscate_file.<locals>.<listcomp>rdzUnable to obfuscate %s: %s)rCr6r8�islinkrW�tempfileZNamedTemporaryFiler%r@rhr�r�rfr�r��copyrAr�r�r�r9�rename�readlinkrG�symlink)rJr�r�r�ZsubsZtfileZ_parsersr�r_r�rlZ_ob_short_nameZ_ob_filenamer�Z_ob_pathZ
_target_obrOr�rPr��sT�
���$
�

zSoSCleaner.obfuscate_filecCs�|jd|jd�|��D]�}z~|�|j�d�d�}|jd||jd�t�|�}tj	�
|j|�|��}|�|�}||ks�||kr�t�|�t�
||�Wqtk
r�}z|�d||f�W5d}~XYqXqdS)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 namesr�rnr�zObfuscating symlink %sz"Error obfuscating symlink '%s': %sN)rEr�Zget_symlinksrCr�r�rWr6r�r8r9r�rGr�rf)rJr�r�Z_symZ_targetZ_ob_sym_nameZ
_ob_targetrlrOrOrPr��s&

�

�

�zSoSCleaner.obfuscate_symlinkscCs�|�d|j�t|��dd�D]~}t�|�D]n}tj�||�}|�|j	�d}tj�
|�r.|�|�}||kr.|�|�}tj�|j	|�
d�|�}t�||�q.q dS)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)rEr��sortedZget_directory_listr6�listdirr8r9rCr�rer��rstripr�r�)rJr��dirpath�_nameZ_dirnameZ_arc_dirZ_ob_dirnameZ_ob_arc_dirrOrOrPr�s"�

�z$SoSCleaner.obfuscate_directory_namescCsP|jD]D}z|�|�}Wqtk
rH}z|�d|�W5d}~XYqXq|S)Nz!Error obfuscating string data: %s)r@Zparse_string_for_keysrfrE)rJZstring_datar-rlrOrOrPr�+s
"zSoSCleaner.obfuscate_stringcCs�d}|��s||fS|dkr"|j}|D]T}z|�|�\}}||7}Wq&tk
rx}z|�d||j�W5d}~XYq&Xq&||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)rDr@Z
parse_linerfrWrA)rJr_r@r�r-�_countrlrOrOrPr�3s&zSoSCleaner.obfuscate_linecCsL|j�d�}|jD]4}|�|j�dd����}|�dt|jj	�
���qdS)zLWrite some cleaner-level, non-report-specific stats to the manifest
        r@� r��entriesN)r?r>r@rAr�rBr�r�r�r��keys)rJZ	parse_secr-Z_secrOrOrPr�Os
z"SoSCleaner.write_stats_to_manifest)NNNFN)N)N)N)N)F)NN)N)'�__name__�
__module__�__qualname__raZdescZarg_defaultsr/rTrWrErZr`�classmethodrcr:rsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rOrOrMrPr%sb#��D





,T


,O
F#
r)(r�rir3r6r�r�Zconcurrent.futuresrr�pwdrr)rZ
sos.componentrZsos.cleaner.parsers.ip_parserrZsos.cleaner.parsers.mac_parserrZ#sos.cleaner.parsers.hostname_parserr	Z"sos.cleaner.parsers.keyword_parserr
Z#sos.cleaner.parsers.username_parserrZsos.cleaner.archives.sosrr
rrZsos.cleaner.archives.genericrrZsos.cleaner.archives.insightsrZ
sos.utilitiesr�textwraprrrOrOrOrP�<module>s*