3
ܓi! @ s6 d dl Z d dlZd dlZd dlmZ G dd dZdS ) N)Pathc @ s e Zd ZdZg Zg ZdZdZdZdd Z dd Z
dd Zd
d Zdd
Z
dd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )SoSMapzStandardized 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.
TFc C sJ i | _ t | _g | _| jjj | _|| _t j
j| jd| j| _| j
d S )NZ
cleaner_cache)datasetset
_regexes_madecompiled_regexes __class____name__lowerZcnameworkdirospathjoin cache_dirload_entries)selfr r /usr/lib/python3.6/__init__.py__init__ s
zSoSMap.__init__c C s" t | jjddd | jd dS )ai Load cached entries from the disk. This method must be called when
we initialize a Map instance and whenever we want to retrieve
self.dataset (e.g. to store default_mapping file). The later is
essential since a concurrent Map can add more objects to the cache,
so we need to update self.dataset up to date.
Keep in mind that size of self.dataset is usually bigger than number
of files in the corresponding cleaner's directory: directory contains
just whole items (e.g. IP addresses) while dataset contains more
derived objects (e.g. subnets).
T)parentsexist_ok N)r r mkdirload_new_entries_from_dir)r r r r r , s
zSoSMap.load_entriesc C s\ | s0|| j ks0|| jj ks0| jr4t|dkr4dS x"| jD ]}tj||tjr