Current File : //usr/lib/python3/dist-packages/sos/cleaner/__pycache__/__init__.cpython-312.pyc |
�
-�_g� � �2 � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl m Z d dl
mZ d dlm
Z
d dlZd dlmZ d dlmZ d dlmZ d d lmZ d d
lmZ d dlmZ d dlmZ d d
lmZ d dlm Z m!Z!m"Z"m#Z# d dl$m%Z%m&Z& d dl'm(Z( d dl)m*Z*m+Z+m,Z, G d� de� Z-y)� N)�ThreadPoolExecutor)�datetime)�getpwuid)�fill)�__version__)�SoSComponent)�SoSIPParser)�SoSMacParser)�SoSHostnameParser)�SoSKeywordParser)�SoSUsernameParser)�
SoSIPv6Parser)�SoSReportArchive�SoSReportDirectory�SoSCollectorArchive�SoSCollectorDirectory)�DataDirArchive�TarballArchive)�InsightsArchive)�get_human_readable�
import_module�ImporterHelperc
�2 � � e Zd ZdZdZdg g g dg dddddg d �Z d,� fd
� Zd-d�Zd-d�Zd-d
�Z d-d�Z
d� Zed� � Z
d� Zd� Zed� � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd.d�Zd� Zd� Zd � Zd!� Zd"� Zd#� Z d$� Z!d%� Z"d/d&�Z#d'� Z$d(� Z%d)� Z&d-d*�Z'd+� Z(� xZ)S )0�
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 IPv6 - effort is 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 IPv6, note that IPv4-mapped addresses, e.g. ::ffff:10.11.12.13, are
NOT supported currently, and will remain unobfuscated.
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�skip_cleaning_files�jobs�keywords�keyword_file�map_file� no_update�keep_binary_files�target� usernamesc � �� |st �| � |||� d| _ n�|d | _ |d | _ |d | _ |d | _ |d | _ d| _ t | j d� sd | j _ d
| j _
t j d� | _
t j d� | _ t j t j"