+
    Û1j^ª  ã                   ó&  € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
t^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHtHtHtHt ^ RI H!t!H"t" ^ RI#H$t$ ^ RI%H&t&H't'H(t(H)t) R t* ! R R]4      t+R# )é    N)Údatetime)Úgetpwuid)Ú__version__)ÚSoSComponent)ÚSoSIPParser)ÚSoSMacParser)ÚSoSHostnameParser)ÚSoSKeywordParser)ÚSoSUsernameParser)ÚSoSIPv6Parser)ÚSoSReportArchiveÚSoSReportDirectoryÚSoSCollectorArchiveÚSoSCollectorDirectory)ÚDataDirArchiveÚTarballArchive)ÚInsightsArchive)Úget_human_readableÚimport_moduleÚImporterHelperÚis_executablec                 ój  €   VP                  4       pTf6    TP	                  T P
                  T P                  T P                  34       R# T P                  T4       K^    \        \        3 d   p\        RT R24        Rp?R# Rp?ii ; i  \         d   p\        RT R24        Rp?R# Rp?ii ; i)Tz3Child process exception when reading input queue: 'Ú'Nz7Child process exception when writing to output queue: ')	ÚgetÚEOFErrorÚOSErrorÚprintÚputÚfiles_obfuscated_countÚtotal_sub_countÚremoved_file_countÚobfuscate_arc_file)ÚarcÚinput_queueÚoutput_queueÚfileÚes   &&&  Ú6/usr/lib/python3/dist-packages/sos/cleaner/__init__.pyÚ_obfuscate_arc_filesr)   *   sÃ   € Ø
ð	Ø—?‘?Ó$ˆDð Š<ð	Ø× Ñ Ø×.Ñ.Ø×'Ñ'Ø×*Ñ*ð",ô -ñ Ø×Ñ˜tÖ$øô œ'Ð"ô 	ÜÐGÈÀsÈ!ÐLÔMÝûð	ûô ô ÜðØ�s˜!ð÷ð ñ ûðús.   ƒA ˜2B ÁB
Á0BÂB
ÂB2ÂB-Â-B2c                   óX  a a€ ] tR t^@t oRtRtRRR. R. R. R^R	. R
RRRRRRRRRR. RR/tR7V 3R lltR8R ltR8R lt	R8R lt
R8R lt]R 4       tR tR t]R 4       tR tR  tR! tR" tR# tR$ tR% tR& tR' tR9R( ltR) tR* tR+ tR, tR- tR. t R/ t!R0 t"R1 t#R2 t$R3 t%R4 t&R5 t'R6t(Vt)V ;t*# ):Ú
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 private IP address from 172.17.0.0/22
range 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Úarchive_typeÚautoÚdomainsÚdisable_parsersÚskip_cleaning_filesÚjobsÚkeywordsÚkeyword_fileNÚmap_fileú /etc/sos/cleaner/default_mappingÚ	no_updateFÚkeep_binary_filesÚtargetÚ Ú	usernamesÚtreat_certificatesÚ	obfuscatec                óˆ  <€ V'       g   \         SV `  WV4       R V n        EMVR,          V n        VR,          V n        VR,          V n        VR,          V n        VR,          V n        RV n        \        V P                  R4      '       g&   V P                  P                  V P                  n
        RV P                  n        \        P                  ! R	4      V n        \        P                  ! R
4      V n        \         P"                  ! \         P$                  P'                  V P                  R4      R R7       V P)                  4        V P+                  4       V n        \         P.                  ! ^?4       W@n        V P                  P3                  4       V n        V P                  P6                  P9                  R4      V n        V P                  P<                  '       d4   \         P$                  P?                  V P                  P<                  4      MRpV P,                  VV P                  P@                  .p\B        \D        \F        \H        \J        \L        .pV U	u. uF  q™PN                  NK  	  p
p	V P                  PP                   Fµ  pRpV
 F�  pV^R PS                  4       pVPS                  4       PU                  4       V8X  g   K;  V PW                  RV 24       V P                  PY                  RV R24       V
P[                  V4       R p M	  V'       d   K–  V P                  PY                  RV R24       K·  	  V
 Uu. uF  p\]        4       V,          ! V!  NK  	  upV n/        \`        \b        \d        \f        \h        \j        \l        .V n7        RV n8        V PW                  RV P                   24       R# u up	i u upi )TÚoptionsÚtmpdirÚsys_tmpÚpolicyÚmanifestFr1   r-   ÚsosÚsos_uiÚcleaner©Úexist_okz/etc/sos/cleanerzDisabling parser: zDisabling the 'zP' parser.
Be aware that this may leave sensitive plain-text data in the archive.z&Failing to disable an unknown parser 'z'.Nz#Cleaner initialized. From cmdline: iúÿÿÿ)9ÚsuperÚ__init__Úfrom_cmdlineÚoptsr?   r@   rA   rB   ÚhasattrÚthreadsr1   r,   ÚloggingÚ	getLoggerÚsoslogÚui_logÚosÚmakedirsÚpathÚjoinÚreview_parser_valuesÚload_map_fileÚcleaner_mappingÚumaskÚin_placeÚget_preferred_hash_nameÚ	hash_nameÚ
componentsÚadd_sectionÚ
cleaner_mdr4   Údirnamer0   r	   r   r   r   r
   r   Ú__name__r/   ÚlowerÚstripÚlog_infoÚwarningÚremoveÚglobalsÚparsersr   r   r   r   r   r   r   Úarchive_typesÚnested_archive)ÚselfÚparserÚargsÚcmdlinerZ   Úhook_commonsÚcleaner_dirÚparser_argsÚparser_classesÚclsÚparser_namesÚ_parserÚfoundÚpnameÚparser_nameÚcls_nameÚ	__class__s   &&&&&&          €r(   rI   ÚSoSCleaner.__init__z   s  ø€ çä‰GÑ˜V¨7Ô3Ø $ˆDÖð
 % YÕ/ˆDŒIØ& xÕ0ˆDŒKØ'¨	Õ2ˆDŒLØ& xÕ0ˆDŒKØ(¨Õ4ˆDŒMØ %ˆDÔä˜4Ÿ9™9 f×-Ò-Ø!%§¡×!2Ñ!2�—	‘	”Ø%+ˆD�I‰IÔ"Ü!×+Ò+¨EÓ2ˆDŒKÜ!×+Ò+¨HÓ5ˆDŒKô �KŠKœŸ™Ÿ™ T§[¡[°)Ó<ÀtÕLà×!Ñ!Ô#à#×1Ñ1Ó3ˆÔÜ
�Š�ŒØ ŒØŸ™×<Ñ<Ó>ˆŒàŸ-™-×2Ñ2×>Ñ>¸yÓIˆŒð �y‰y×!×!Ð!ô —g‘g—o‘o d§i¡i×&8Ñ&8Ô9Ø'9ð 	ð × Ñ ØØ�I‰I×)Ñ)ð
ˆô ÜÜÜÜÜð
ˆñ %3ó
Ù$2˜S�LŒL¡Nð 	ð 
ð —y‘y×0Ô0ˆGØˆEÛ%�Ø# A b˜k×/Ñ/Ó1�Ø—=‘=“?×(Ñ(Ó*¨kÖ9Ø—M‘MÐ$6°{°mÐ"DÔEØ—K‘K×'Ñ'Ø)¨'¨ð 3/ð /ôð
 !×'Ñ'¨Ô.Ø �EÙñ &÷ ‘5Ø—‘×#Ñ#Ø<¸W¸IÀRÐHöñ 1ñ* )ó
á(�ô ‹I�hÖ Ô-Ù(ñ
ˆŒô ÜÜ!ÜÜäÜð	
ˆÔð #ˆÔà�‰Ø1°$×2CÑ2CÐ1DÐEö	GùòQ
ùò.
s   ÉN:ÍN?c                ó,   € R V'       d   RV 2MR RV 2# )z[cleanerÚ:r9   z] © ©rk   ÚmsgÚcallers   &&&r(   Ú_fmt_log_msgÚSoSCleaner._fmt_log_msgØ   s    € Ø¯&˜A˜f˜X™,°bÐ9¸¸C¸5ÐAÐAó    c                óZ   € V P                   P                  V P                  W4      4       R # ©N)rP   Údebugr‚   r   s   &&&r(   Ú	log_debugÚSoSCleaner.log_debugÛ   ó   € Ø�‰×Ñ˜$×+Ñ+¨CÓ8Ö9r„   c                óZ   € V P                   P                  V P                  W4      4       R # r†   )rP   Úinfor‚   r   s   &&&r(   rd   ÚSoSCleaner.log_infoÞ   s   € Ø�‰×Ñ˜×*Ñ*¨3Ó7Ö8r„   c                óZ   € V P                   P                  V P                  W4      4       R # r†   )rP   Úerrorr‚   r   s   &&&r(   Ú	log_errorÚSoSCleaner.log_errorá   rŠ   r„   c                ó^   € VP                  R 4       VP                  V P                  4       R# )zSoS Cleaner Detailed HelpN)Ú	set_titleÚadd_textÚ__doc__)rs   Úsections   &&r(   Údisplay_helpÚSoSCleaner.display_helpä   s#   € à×ÑÐ5Ô6Ø×Ñ˜Ÿ™Ö%r„   c           	     óT  € / pRp\         P                  P                  V P                  P                  4      '       d$   \        RV P                  P                   R24      h\         P                  P                  V P                  P                  4      '       gG   V P                  P                  V8w  d*   V P                  RV P                  P                   R24       V# \        V P                  P                  RRR7      ;_uu_ 4       p \        P                  ! V4      pRRR4       V#   \        P                   d    T P                  R	4        L2\
         d6   pT P                  R
T P                  P                   RT 24        Rp?LlRp?ii ; i  + '       g   i     T# ; i)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
r5   zRequested map file z is a directoryzERROR: map file z6 does not exist, will not load any obfuscation matchesÚrúutf-8©ÚencodingzOERROR: Unable to parse map file, json is malformed. Will not load any mappings.zERROR: Could not load 'ú': N)rR   rT   ÚisdirrK   r4   Ú	ExceptionÚexistsr�   ÚopenÚjsonÚloadÚJSONDecodeError)rk   Ú_confÚdefault_mapÚmfÚerrs   &    r(   rW   ÚSoSCleaner.load_map_fileé   sk  € ð ˆØ8ˆÜ�7‰7�=‰=˜Ÿ™×+Ñ+×,Ò,ÜÐ1°$·)±)×2DÑ2DÐ1Eð F(ð (ó )ð )ä�w‰w�~‰~˜dŸi™i×0Ñ0×1Ò1Ø�y‰y×!Ñ! [Ô0Ø—‘Ø& t§y¡y×'9Ñ'9Ð&:ð ;<ð <ô=ð ˆô �d—i‘i×(Ñ(¨#¸×@Õ@ÀBðEÜ ŸIšI b›M�E÷ Að ˆøô ×+Ñ+ô MØ—N‘Nð $Lö Mä ô EØ—N‘Nð $'Ø'+§y¡y×'9Ñ'9Ð&:¸#¸c¸Uð$D÷ Eñ EûðEú÷ AÖ@ð ˆúsB   Ä
FÄD,Ä,&FÅFÅFÅFÅ+FÆ	FÆFÆFÆF'	c                óÀ  € V P                  R4      pV P                  P                  R\         R24       V P                  P                  V4       V P                  P
                  '       g    \        R4       R# R#   \         d1    T P                  P                  R4       T P                  ^‚4        R# \         d   pT P                  ^T4        Rp?R# Rp?ii ; i)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 z)
z-
Press ENTER to continue, or CTRL-C to quit.
z
Exiting on user cancelN)
Ú_fmt_msgrQ   rŒ   r   rK   ÚbatchÚinputÚKeyboardInterruptÚ_exitr    )rk   r€   r'   s   &  r(   Úprint_disclaimerÚSoSCleaner.print_disclaimer  s°   € ð �m‰mð ó ˆð 	�‰×ÑÐ0´°¸SÐAÔBØ�‰×Ñ˜ÔØ�y‰y��ˆð!ÜÐGÖHñ øô %ô  Ø—‘× Ñ Ð!;Ô<Ø—
‘
˜3—Üô !Ø—
‘
˜1˜a× Ò ûð!ús$   Á-A< Á<7CÂ6CÂ?CÃ CÃCc           	     óz  € R Vn         VP                  RR4      pVP                  RRRR7       VP                  RR. R:OR	R
7       VP                  RR. RR7       VP                  RR. RRR7       VP                  RRR. RRR7       VP                  RR^\        RR7       VP                  RR. RRR7       VP                  RRR R!R"7       VP                  R#R$R%R&R'7       VP                  R(R)R*R+R,R-7       VP                  R.R*R+R/R0R17       VP                  R2R3. RR4R-7       VP                  R5R6. R;OR7R8R97       R# )<zsos clean|mask TARGET [options]zCleaner/Masking Optionsz7These options control how data obfuscation is performedr8   ÚTARGETz%The directory or archive to obfuscate)ÚmetavarÚhelpz--archive-typer-   z8Specify what kind of archive the target was generated as)ÚdefaultÚchoicesr¶   z	--domainsÚextendz!List of domain names to obfuscate)Úactionr·   r¶   z--disable-parsersr/   zCDisable specific parsers, so that those elements are not obfuscated)rº   r·   Údestr¶   z--skip-cleaning-filesz--skip-masking-filesr0   zBList of files to skip/ignore during cleaning. Globs are supported.z-jz--jobsz&Number of concurrent archives to clean)r·   Útyper¶   z
--keywordsr2   zList of keywords to obfuscatez--keyword-fileNr3   z&Provide a file a keywords to obfuscate)r·   r»   r¶   z
--map-filer4   r5   z;Provide a previously generated mapping file for obfuscation)r»   r·   r¶   z--no-updater6   FÚ
store_truez<Do not update the --map-file with new mappings from this run)r»   r·   rº   r¶   z--keep-binary-filesr7   zGKeep unprocessable binary files in the archive instead of removing them)r·   rº   r»   r¶   z--usernamesr:   zList of usernames to obfuscatez--treat-certificatesr<   r;   z”How to treat certificate files [.csr .crt .pem]. Defaults to "obfuscate" after convert the file to text. "Key" certificate files are always removed.)r·   r¸   r»   r¶   )r-   ÚreportÚcollectÚinsightszdata-dirÚtarball)r<   Úkeeprf   )ÚusageÚadd_argument_groupÚadd_argumentÚint)rs   rl   Ú	clean_grps   && r(   Úadd_parser_optionsÚSoSCleaner.add_parser_options"  sá  € à8ˆŒØ×-Ñ-Ø%ØEó
ˆ	ð 	×Ñ˜x°Ø$Kð 	ô 	Mà×ÑÐ/¸ò(Kð&8ð 	ô 	:ð
 	×Ñ˜{°8ÀRØ$Gð 	ô 	Ià×ÑÐ2¸8Ø')Ð0Að&Cð 	ô 	Eð 	×ÑÐ6Ð8NØ&.¸Ø$9ð&Fð 	ô 	Hð
 	×Ñ˜t X°q¼sØ$Lð 	ô 	Nà×Ñ˜|°HÀbØ$.Ø$Cð 	ô 	Eð 	×ÑÐ/¸Ø$2Ø$Lð 	ô 	Nð 	×Ñ˜|°*Ø'Ið&<ð 	ô 	>ð 	×Ñ˜}°;ÈØ&2ð%=ð 	ô 	>ð 	×ÑÐ4¸eØ&2Ø$7ð%Gð 	ô 	Hð
 	×Ñ˜}°;ÈØ&.Ø$Dð 	ô 	Fð 	×ÑÐ5¸{Ú'FØ$8ð$.ð	 	ö 	0r„   c                ó&   € WP                   n        R# )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)rK   r8   )rk   rT   s   &&r(   Úset_target_pathÚSoSCleaner.set_target_path]  s   € ð
  �	‰	Ör„   c                ó  € RpV P                   P                  R8w  dŸ   V P                   P                  P                  RR4      pV P                   Fg  pVP                  V8X  g   K  V! V P                   P
                  V P                  V P                   P                  V P                   P                  4      pKi  	  M‘V P                   F�  pVP                  V P                   P
                  4      '       g   K0  V! V P                   P
                  V P                  V P                   P                  V P                   P                  4      p M	  V'       g   R# Wn
        V P                  P                  V4       VP                  '       dK   V P                  P                  VP                  4       4       V P                  P!                  V4       Wn        V P"                  '       d(   V P"                  P$                  V P"                  n        R# R# )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-   Ú-Ú_)rK   r,   Úreplaceri   Ú	type_namer8   r?   r7   r;   Úcheck_is_typeÚmain_archiveÚreport_pathsÚappendÚ	is_nestedr¹   Úget_nested_archivesrf   rj   ÚdescriptionÚui_name)rk   Ú_arcÚ
check_typeÚarchiver#   s   &    r(   Úinspect_target_archiveÚ!SoSCleaner.inspect_target_archived  sƒ  € ð ˆØ�9‰9×!Ñ! VÔ+ØŸ™×/Ñ/×7Ñ7¸¸SÓAˆJØ×-Ô-�Ø×$Ñ$¨
Ö2Ù" 4§9¡9×#3Ñ#3°T·[±[Ø#'§9¡9×#>Ñ#>Ø#'§9¡9×#?Ñ#?óA’Dò .ð ×)Ô)�Ø×$Ñ$ T§Y¡Y×%5Ñ%5×6Ô6Ù˜tŸy™y×/Ñ/°·±Ø#Ÿy™y×:Ñ:Ø#Ÿy™y×;Ñ;ó=�Dñ ñ *÷ ÙØ ÔØ×Ñ× Ñ  Ô&Ø�>�>ˆ>Ø×Ñ×$Ñ$ T×%=Ñ%=Ó%?Ô@ð ×Ñ×$Ñ$ TÔ*Ø"&ÔØ××ÐØ*.×*=Ñ*=×*IÑ*IˆD×ÑÖ'ñ r„   c                ó8  € V P                   P                   F1  p\        VP                  R4      4      ^8  g   K$  \	        RV R24      h	  V P                   P
                   Uu. uF  p\        P                  ! V4      NK  	  upV P                   n        R# u upi )zÔCheck any values passed to the parsers via the commandline:
- For the --domains option, ensure that they are valid for the parser
  in question.
- Convert --skip-cleaning-files from globs to regular expressions.
Ú.zInvalid value 'z0' given: --domains values must be actual domainsN)rK   r.   ÚlenÚsplitr    r0   ÚfnmatchÚ	translate)rk   Ú_domÚps   &  r(   rV   ÚSoSCleaner.review_parser_values†  s�   € ð —I‘I×%Ô%ˆDÜ�4—:‘:˜c“?Ó# aÖ'ÜØ% d Vð ,%ð %óð ñ &ð *.¯©×)FÒ)Fó)HÙ)Fð CD¬×):Ò):¸1Ö)=Ù)Fñ)Hˆ�	‰	Ö%ùò )Hs   Á$Bc                ó²
  € V P                   P                  P                  R4      V P                   n        V P                   P                  P                  R4      R,          P                  R4      ^ ,          V n        V P
                  '       d   V P                  4        . V n        \        P                  P                  V P                   P                  4      '       gD   V P                  P                  RV P                   P                   24       V P                  ^4       V P                  4        V P                  '       g-   V P                  P                  R4       V P                  ^4       . V n        V P                    F0  pVP"                  R8X  g   K  VP$                  P'                  4        K2  	  V P)                  4        V P+                  4        V P-                  4        V P                  '       gA   V P.                  '       d   R# V P                  P1                  R4       V P                  ^4       V P                  P1                  R\3        V P                  4       R	24       V P5                  4       pV P7                  V4      pV P9                  V4       V P;                  4        V P.                  '       d(   V P                   Uu. uF  qDP<                  NK  	  ppW53# Rp\3        V P                  4      ^8”  d   V P?                  4       pMÜV P                  ^ ,          pVP<                  pV PA                  VP<                  4      p	V	e�   V PC                  VP                  R4      R,           R
V PD                   24      p
\G        \        P                  PI                  V PJ                  V
4      RRR7      ;_uu_ 4       pVPM                  V	4       RRR4       V PO                  4        \        P                  PI                  V PJ                  V PC                  VP                  R4      R,          4      4      p\P        PR                  ! Wv4       \        PT                  ! V4      pV P                  P1                  RV 24       V P                  P1                  RV R24       V P                  P1                  R\W        VPX                  4       24       V P                  P1                  R\[        VP\                  4      P^                   R24       V P                  P1                  R4       V Pa                  4        R# u upi   + '       g   i     ELx; i)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.tarz*Invalid target: no such file or directory z'No valid archives or directories found
zHostname ParserNz#No reports obfuscated, aborting...
z
Successfully obfuscated z report(s)
rà   Úwr›   rœ   z2A mapping of obfuscated elements is available at
	z)
The obfuscated archive is available at
	Ú
z	Size	z	Owner	zdPlease send the obfuscated archive to your support
representative and keep the mapping file private.éÿÿÿÿ)1rK   r8   Úrstriprâ   Úarc_namerJ   r±   rÔ   rR   rT   r¡   rQ   r�   r°   rÝ   Úcompleted_reportsrh   ÚnameÚmappingÚset_initial_countsÚpreload_all_archives_into_mapsÚgenerate_parser_item_regexesÚobfuscate_report_pathsrZ   rŒ   rá   Úcompile_mapping_dictÚwrite_map_for_archiveÚwrite_map_for_configÚwrite_stats_to_manifestÚfinal_archive_pathÚrebuild_nested_archiveÚget_new_checksumÚobfuscate_stringr\   r¢   rU   r@   ÚwriteÚwrite_cleaner_logÚshutilÚmoveÚstatr   Úst_sizer   Úst_uidÚpw_nameÚcleanup)rk   rl   Ú_mapÚmap_pathÚaÚ	arc_pathsÚ
final_pathÚarc_pathr#   ÚchecksumÚchksum_nameÚcfÚarcstats   &            r(   ÚexecuteÚSoSCleaner.execute•  s#  € ð  Ÿ9™9×+Ñ+×2Ñ2°3Ó7ˆ�	‰	ÔØŸ	™	×(Ñ(×.Ñ.¨sÓ3°BÕ7×=Ñ=¸fÓEÀaÕHˆŒØ××ÐØ×!Ñ!Ô#ØˆÔÜ�w‰w�~‰~˜dŸi™i×.Ñ.×/Ò/Ø�K‰K×ÑÐJØ!%§¡×!1Ñ!1Ð 2ð4ô 5à�J‰J�qŒMà×#Ñ#Ô%à× × Ð Ø�K‰K×ÑÐHÔIØ�J‰J�qŒMð "$ˆÔð —l”lˆFØ�{‰{Ð/Ö/Ø—‘×1Ñ1Ö3ñ #ð 	×+Ñ+Ô-Ø×)Ñ)Ô+Ø×#Ñ#Ô%à×%×%Ð%Ø�}�}ˆ}ÙØ�K‰K×ÑÐCÔDØ�J‰J�qŒMà�‰×ÑÐ5Ü × 6Ñ 6Ó7Ð8¸ðFô 	Gð ×(Ñ(Ó*ˆØ×-Ñ-¨dÓ3ˆØ×!Ñ! $Ô'Ø×$Ñ$Ô&à�=�=ˆ=Ø7;×7MÒ7MÓNÑ7M°!×-Ô-Ñ7MˆIÐNØÐ&Ð&àˆ
Üˆt×%Ñ%Ó&¨Ô*Ø×2Ñ2Ó4‰Hà×(Ñ(¨Õ+ˆCØ×-Ñ-ˆHØ×,Ñ,¨S×-CÑ-CÓDˆHØÒ#Ø"×3Ñ3Ø—~‘~ cÓ*¨2Õ.Ð/¨q°·±Ð0@ÐAó�ô œ"Ÿ'™'Ÿ,™, t§|¡|°[ÓAÀ3Ø#*÷,õ ,Ø/1Ø—H‘H˜XÔ&÷,ð ×"Ñ"Ô$ä—W‘W—\‘\Ø�L‰LØ×!Ñ! (§.¡.°Ó"5°bÕ"9Ó:ó
ˆ
ô 	�Š�HÔ)Ü—'’'˜*Ó%ˆð
 	�‰×ÑØBÀ8À*ÐMô	
ð 	�‰×ÑØ:¸:¸,ÀbÐIô	
ð 	�‰×Ñ˜8Ô$6°w·±Ó$GÐ#HÐIÔJØ�‰×Ñ˜9¤X¨g¯n©nÓ%=×%EÑ%EÐ$FÀbÐIÔJØ�‰×Ñð@ô	
ð
 	�‰ŒÙùòY O÷,÷ ,ð ,ús   ËU ÏUÕU	c                ól  € V P                   R,           pV P                  VR7       V P                   Ft  pVP                  P	                  R4      R	,          pV P                  VP                  4      pVf   KF  RV RV P                   2pV P                  P                  WER7       Kv  	  \        P                  ! V P                  P                  4       F�  w  rgpV F‘  p	\        P                  P                  Wi4      p
V
P	                  V P                  P                  4      R	,          pVP                  R4      pV P                  P!                  W¥R7       \        P"                  ! V
4       K“  	  KŸ  	  V P%                  RR7       V P                  P'                  V P(                  P*                  4      # )
zxHandles repacking the nested tarball, now containing only obfuscated
copies of the reports, log files, manifest, etc...
z-obfuscated)rð   ré   z
checksums/rà   ©r»   T)rÜ   rì   )rî   Úsetup_archiverï   rú   râ   rü   r\   rÜ   Ú
add_stringrR   Úwalkrj   Úextracted_pathrT   rU   ÚlstripÚadd_filerf   rÿ   ÚfinalizerK   Úcompression_type)rk   rî   rÜ   Úarc_destr  ÚdnameÚdirnrÏ   ÚfilesÚfilenameÚfnames   &          r(   rû   Ú!SoSCleaner.rebuild_nested_archiveø  sX  € ð
 —=‘= =Õ0ˆØ×Ñ ÐÔ)Ø×-Ô-ˆGØ×1Ñ1×7Ñ7¸Ó<¸RÕ@ˆHØ×,Ñ,¨W×-GÑ-GÓHˆHØÔ#Ø$ X J¨a°·±Ð/?Ð@�Ø—‘×'Ñ'¨Ð'Ö=ñ .ô !Ÿgšg d×&9Ñ&9×&HÑ&HÖI‰NˆD�UÛ!�ÜŸ™Ÿ™ TÓ4�ØŸ™ D×$7Ñ$7×$FÑ$FÓGÈÕK�ØŸ™ SÓ)�Ø—‘×%Ñ% eÐ%Ô8ä—	’	˜%Ö ó "ñ Jð 	×Ñ tÐÔ,Ø�|‰|×$Ñ$ T§Y¡Y×%?Ñ%?Ó@Ð@r„   c                óª   € / pV P                    F@  p/ WP                  &   WP                  ,          P                  VP                  4       4       KB  	  V# )zðBuild 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
)rh   Úmap_file_keyÚupdateÚget_map_contents)rk   r  rl   s   &  r(   rö   ÚSoSCleaner.compile_mapping_dict  sL   € ð ˆØ—l”lˆFØ(*ˆD×$Ñ$Ñ%Ø×$Ñ$Õ%×,Ñ,¨V×-DÑ-DÓ-FÖGñ #ð ˆr„   c           	     óº   € \        VRRR7      ;_uu_ 4       pVP                  \        P                  ! V^R7      4       RRR4       V#   + '       g   i     T# ; i)zZWrite the mapping to a file on disk that is in the same location as
the final archive(s).
rê   r›   rœ   )ÚindentN)r¢   rþ   r£   Údumps)rk   r  rT   r¨   s   &&& r(   Úwrite_map_to_fileÚSoSCleaner.write_map_to_file  sD   € ô �$˜ g×.Õ.°"Ø�H‰H”T—Z’Z ¨QÔ/Ô0÷ /àˆ÷ /Ö.àˆús   —(A	Á	A	c                ó  €  \         P                  P                  V P                  V P	                  V P
                   R 24      4      pV P                  W4      #   \         d    pT P                  RT 24        Rp?R# Rp?ii ; i)z-private_mapz"Could not write private map file: N)	rR   rT   rU   r@   rý   rî   r,  r    r�   )rk   r  r  r©   s   &&  r(   r÷   Ú SoSCleaner.write_map_for_archive%  ss   € ð	Ü—w‘w—|‘|Ø—‘Ø×%Ñ%¨¯©¨°|Ð&DÓEóˆHð ×)Ñ)¨$Ó9Ð9øÜô 	Ø�N‰NÐ?À¸uÐEÔFÝûð	ús   ‚AA ÁBÁ$A>Á>Bc                ó
  € V P                   P                  '       dº   V P                   P                  '       gœ   \        P                  P                  V P                   P                  4      p \        P                  ! VRR7       V P                  WP                   P                  4       V P                  RV P                   P                   24       R# R# R#   \         d    pT P                  RT 24        Rp?R# Rp?ii ; i)zmWrite the mapping to the config file so that subsequent runs are
able to provide the same consistent mapping
TrF   zWrote mapping to z&Could not update mapping config file: N)rK   r4   r6   rR   rT   r`   rS   r,  rˆ   r    r�   )rk   r  rp   r©   s   &&  r(   rø   ÚSoSCleaner.write_map_for_config0  s½   € ð �9‰9××Ð d§i¡i×&9×&9Ð&9ÜŸ'™'Ÿ/™/¨$¯)©)×*<Ñ*<Ó=ˆKðOÜ—’˜K°$Õ7Ø×&Ñ& t¯Y©Y×-?Ñ-?Ô@Ø—‘Ð!2°4·9±9×3EÑ3EÐ2FÐGÖHñ ':Ñøô ô OØ—‘Ð!GÈÀuÐM×NÒNûðOús   Á-A%C ÃDÃ#C=Ã=Dc                óâ  € \         P                  P                  V P                  V P                   R24      p\        VRRR7      ;_uu_ 4       pV P                  P                  ^ 4       V P                  P                  4        F  pVP                  V4       K  	  RRR4       V'       d1   V P                  V4       V P                  P                  VRR7       R# R#   + '       g   i     LJ; i)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-obfuscation.logrê   r›   rœ   Nzsos_logs/cleaner.logr  )rR   rT   rU   r@   rî   r¢   Úsos_log_fileÚseekÚ	readlinesrþ   Úobfuscate_filerÜ   r  )rk   rÜ   Úlog_nameÚlogfileÚlines   &&   r(   rÿ   ÚSoSCleaner.write_cleaner_log?  sµ   € ô
 —7‘7—<‘<Ø�L‰L˜TŸ]™]˜OÐ+;Ð<ó
ˆô �(˜C¨'×2Õ2°gØ×Ñ×"Ñ" 1Ô%Ø×)Ñ)×3Ñ3Ö5�Ø—‘˜dÖ#ñ 6÷ 3÷
 Ø×Ñ Ô)Ø�L‰L×!Ñ! (Ð1GÐ!ÖHñ ÷ 3×2ús   ÁACÃC.	c                ó’  €  Rp\        VR4      ;_uu_ 4       p\        P                  ! V P                  4      p VP	                  V4      pV'       g   MVP                  V4       K.  VP                  4       R,           uuRRR4       #   + '       g   i     R# ; i  \         d    pT P                  RT 24        Rp?R# Rp?ii ; i)zfCalculate a new checksum for the obfuscated archive, as the previous
checksum will no longer be valid
Úrbrë   Nz!Could not generate new checksum: i   )	r¢   ÚhashlibÚnewr\   Úreadr&  Ú	hexdigestr    rˆ   )rk   Úarchive_pathÚ	hash_sizeÚ
archive_fpÚdigestÚhashdatar©   s   &&     r(   rü   ÚSoSCleaner.get_new_checksumP  s£   € ð	FØˆIÜ�l D×)Ô)¨ZÜ Ÿš T§^¡^Ó4�ØØ)Ÿ™¨yÓ9�Hß#ØØ—M‘M (Ö+Ø×'Ñ'Ó)¨DÕ0÷ *×)×)Ñ)ñ ûô ô 	FØ�N‰NÐ>¸s¸eÐD×EÐEÙûð	Fús:   ‚B ˜:BÁ*BÁ=
B ÂB	ÂB ÂB ÂCÂ'CÃCc                ó   €  R\        V P                  4       RV P                  P                   R2pV P                  P                  V4       V P                  P                  '       d   V P                  P                  R4       V P                  P                  R8X  d>   \        R4      '       g-   RV P                  n        V P                  P                  R4       V P                  P                  R8X  d   V P                  P                  R	4       MmV P                  P                  R
8X  d   V P                  P                  R4       M6V P                  P                  R8X  d   V P                  P                  R4       V P                   F<  pV P                  P                  RVP                   24       V P                  V4       K>  	  V P                  '       d.   V P                  4        V P                  V P                  4       R# R#   \         d6    T P                  P                  R4       \        P                   ! ^‚4        R# i ; i)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.
zFound z. total reports to obfuscate, processing up to z" concurrently within one
archive.
zqWARNING: binary files that potentially contain sensitive information will NOT be
removed from the final archive.
r<   Úopensslrf   zgWARNING: No `openssl` command available. Replacing
`--treat-certificates` from `obfuscate` to `remove`.zˆWARNING: certificate files that potentially contain sensitive information will
be CONVERTED to text and OBFUSCATED in the finalarchive.
rÂ   zsWARNING: certificate files that potentially contain sensitive information will
be KEPT in the final archive as is.
zpWARNING: certificate files that potentially contain sensitive information will
be REMOVED in the final archive.
zObfuscating zExiting on user cancelN)rá   rÔ   rK   r1   rQ   rŒ   r7   re   r;   r   rA  Úobfuscate_reportrj   Ú_replace_obfuscated_archivesr¯   rR   r°   )rk   r€   Úreport_paths   &  r(   rõ   Ú!SoSCleaner.obfuscate_report_pathsb  sÝ  € ð0	àœ˜T×.Ñ.Ó/Ð0ð 1$Ø$(§I¡I§N¡NÐ#3ð 4ðð ð
 �K‰K×Ñ˜SÔ!Ø�y‰y×*×*Ð*Ø—‘×#Ñ#ð8ôð
 —	‘	×,Ñ,°Ô;Ü)¨)×4Ò4Ø/7�—	‘	Ô,Ø—‘×#Ñ#ðKôð �y‰y×+Ñ+¨{Ô:Ø—‘×#Ñ#ð!õð —‘×-Ñ-°Ô7Ø—‘×#Ñ#ð<õð
 —‘×-Ñ-°Ô9Ø—‘×#Ñ#ð9ôð
  $×0Ô0�Ø—‘× Ñ  <°×0HÑ0HÐ/IÐ!JÔKØ×%Ñ% kÖ2ñ  1ð ×"×"Ð"Ø×1Ñ1Ô3Ø×%Ñ% d×&9Ñ&9Ö:ñ #øô !ô 	Ø�K‰K×ÑÐ5Ô6Ü�HŠH�S�Mð	ús   ‚GH Ç+H È<IÉIc                óh  € V P                    F¡  p\        P                  ! VP                  4       V P                  P
                  pVP                  P                  R4      R,          p\        P                  P                  W#4      p\        P                  ! VP                  V4       WAn        K£  	  R# )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é   Nrì   )rï   rR   rf   rA  rj   r  rú   râ   rT   rU   r   r  )rk   rÜ   r»   rÁ   Ú	dest_names   &    r(   rJ  Ú'SoSCleaner._replace_obfuscated_archives›  s~   € ð
 ×-Ô-ˆGÜ�IŠI�g×*Ñ*Ô+Ø×&Ñ&×5Ñ5ˆDØ×0Ñ0×6Ñ6°sÓ;¸BÕ?ˆGÜŸ™Ÿ™ TÓ3ˆIÜ�KŠK˜×2Ñ2°DÔ9Ø)2Ö&ó .r„   c                óL   € V P                    F  pVP                  4        K  	  R# )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)rh   Úgenerate_item_regexes)rk   rl   s   & r(   rô   Ú'SoSCleaner.generate_parser_item_regexes¨  s   € ð
 —l”lˆFØ×(Ñ(Ö*ó #r„   c                óæ  € V P                    EF�  pRVP                  n        VP                  P	                  4       P                  4       ^ ,          P                  4       pVP                  WA4       Fk  pVP                  V4      pV'       g   K  V P                  RV RV RVP                   24       VP                  4        F  p VP                  V4       K  	  Km  	  VP                  WA4      p	V	'       dF   V P                  RV R	VP                   24       V	 F  p
VP                  P                  V
4       K   	  VP                   V,           F  pVP                  P#                  V4       K   	  R
VP                  n        VP                  P%                  4        EK“  	  VP'                  V P                   4       R#   \         d'   pT P                  RT RT RT 24        Rp?EK)  Rp?ii ; i)aÂ  
For each archive we've determined we need to operate on, pass it to
each prepper so that we can extract necessary files and/or items for
direct regex replacement. Preppers define these methods per parser,
so it is possible that a single prepper will read the same file for
different parsers/mappings. This is preferable to the alternative of
building up monolithic lists of file paths, as we'd still need to
manipulate these on a per-archive basis.

:param archive: The archive we are currently using to prepare our
                mappings with
:type archive:  ``SoSObfuscationArchive`` subclass

:param prepper: The individual prepper we're using to source items
:type prepper:  ``SoSPrepper`` subclass
Tz	Prepping z parser with file z from zFailed to prep z
 map from ú: Nz mapping with items from F)rh   rñ   Úinitializingrð   rb   râ   rc   Úget_parser_file_listÚget_file_contentrˆ   rÙ   Ú
splitlinesÚ
parse_liner    Úget_items_for_mapÚaddÚregex_itemsÚadd_regex_itemÚgenerate_compiled_regexesÚset_parsers)rk   rÜ   Úprepperru   rw   Ú_fileÚcontentr9  r©   Ú	map_itemsÚitemÚritems   &&&         r(   Ú_prepare_archive_with_prepperÚ(SoSCleaner._prepare_archive_with_prepper°  s±  € ð" —|•|ˆGØ+/ˆG�O‰OÔ(Ø—L‘L×&Ñ&Ó(×.Ñ.Ó0°Õ3×9Ñ9Ó;ˆEØ ×5Ñ5°eÖE�Ø!×2Ñ2°5Ó9�ßÙØ—‘ ¨5¨'Ð1CÀEÀ7ð K'Ø'.§¡Ð&7ð 9ô :à#×.Ñ.Ö0�DðØ×*Ñ*¨4Ö0ó 1ñ Fð  ×1Ñ1°%ÓAˆIßØ—‘ ¨5¨'Ð1JØ")§/¡/Ð!2ð 4ô 5ã%�DØ—O‘O×'Ñ'¨Ö-ñ &ð !×,Ñ,¨U×3Ð3�Ø—‘×.Ñ.¨uÖ5ñ 4à+0ˆG�O‰OÔ(Ø�O‰O×5Ñ5×7ñ5 $ð8 	×Ñ˜DŸL™LÖ)øô! %ô ØŸ™Ø-¨e¨W°J¸u¸gÀRÈÀuÐM÷ó ûðús   ÃF?Æ?G0	Ç
G+	Ç+G0	c              #  ó  "  € \        \        P                  P                  4      p. pVP	                  4        F   pVP                  \        RV 24      4       K"  	  \        VR R7       F  pV! V P                  R7      x € K  	  R# 5i)zß
Discover all locally available preppers so that we can prepare the
mappings with obfuscation matches in a controlled manner

:returns: All preppers that can be leveraged locally
:rtype:   A generator of `SoSPrepper` items
zsos.cleaner.preppers.c                 ó   € V P                   # r†   )Úpriority©Úxs   &r(   Ú<lambda>Ú)SoSCleaner.get_preppers.<locals>.<lambda>ë  s   € °1·:²:r„   )Úkey)r>   N)	r   rC   rE   ÚpreppersÚget_modulesr¹   r   ÚsortedrK   )rk   ÚhelperÚprepsÚ_prepr`  s   &    r(   Úget_preppersÚSoSCleaner.get_preppersß  sm   é € ô  ¤§¡× 4Ñ 4Ó5ˆØˆØ×'Ñ'Ö)ˆEØ�L‰LœÐ)>¸u¸gÐ'FÓGÖHñ *ä˜eÑ)=×>ˆGÙ $§)¡)Ô,Ô,ó ?ùs   ‚BBc                óè   € V P                  R4       V P                  4        F'  pV P                   F  pV P                  W!4       K  	  K)  	  V P                  P                  V P                  4       R# )zèBefore 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 mapsN)rd   rv  rÔ   rf  rÓ   r_  rh   )rk   r`  rÜ   s   &  r(   ró   Ú)SoSCleaner.preload_all_archives_into_mapsî  s\   € ð 	�‰ÐFÔGØ×(Ñ(Ö*ˆGØ×,Ô,�Ø×2Ñ2°7ÖDó -ñ +ð 	×Ñ×%Ñ% d§l¡lÖ3r„   c                óh	  € R p V P                   P                  VP                  4      p\        P                  ! 4       pVP                  RV4       VP                  '       g   VP                  4        VP                  R4       ^ ;p;rg\        P                  ! 4       p\        P                  ! 4       p	. p
\        V P                  P                  4       FB  p\        P                  ! \        WV	3R7      pVP!                  4        V
P#                  V4       KD  	  V! \%        VP'                  4       4      \(        P*                  P-                  \(        P*                  P/                  VP0                  4      4      4       F  pVP3                  V4       K  	  \        V P                  P                  4       F  pVP3                  R4       K  	  V
 F  pVP5                  4        K  	  V	P7                  4       '       g2    V	P9                  4       w  rïpVX,          pVX,          pVX,          pKG  VP?                  4         V PA                  V4        V PE                  V4       VPF                  '       g�   VPI                  4       pV'       dN   VP                  R4        VPK                  V PM                  VP                  4      4       VPO                  V4       V PR                  P#                  V4       \        P                  ! 4       pVP                  RV4       VP                  RVV,
          4       VP                  RV4       VP                  RV4       RpV'       d   RpVV,          pVP                  RV 24       R#   \:         d!   pT P=                  RT R24        Rp?EL˜Rp?ii ; i  \B         d,   pT P=                  RT 2TP                  R	7        Rp?EL’Rp?ii ; i  \B         d,   pT P=                  R
T 2TP                  R	7        Rp?EL¹Rp?ii ; i  \B         dA   pT PQ                  RTP                   RT 24       TP                  RT 24        Rp?R# Rp?ii ; i  \B         d7   pT PT                  PW                  RTP                   RT 24        Rp?R# Rp?ii ; i)z¿Individually handle each archive or directory we've discovered by
running through each file therein.

Positional arguments:

    :param archive str:      Filepath to the directory or archive
c           
     óü   € V  Uu. uFA  pV\         P                  P                  \         P                  P                  W4      4      3NKC  	  pp\	        VR RR7      pV UUu. uF  w  rVVNK	  	  upp# u upi u uppi )zJOrder files per their sizes, if they are provided relatively
to base_path
c                 ó   € V ^,          # )é   r~   rk  s   &r(   rm  ÚKSoSCleaner.obfuscate_report.<locals>._order_files_by_size.<locals>.<lambda>  s   € ÈÈ!Îr„   T)ro  Úreverse)rR   rT   ÚgetsizerU   rr  )Ú	file_listÚ	base_pathÚfÚfiles_with_sizesÚfiles_sizes_sortedr&   rÏ   s   &&     r(   Ú_order_files_by_sizeÚ9SoSCleaner.obfuscate_report.<locals>._order_files_by_size  s{   € ñ #ó á"�Að ”B—G‘G—O‘O¤B§G¡G§L¡L°Ó$>Ó?Ó@Ù"ð ð  ô "(Ð(8¹nØ04ô"6Ðá(:Ô;Ñ(:™W˜T“DÑ(:Ò;Ð;ùò ùó <s   …AA3Á"A8Ú
start_timezBeginning obfuscation...)r8   rm   NzXFailed to receive obfuscation stats from child; statistics might be incomplete. Error: 'r   z!Failed to obfuscate directories: ©r�   zFailed to obfuscate symlinks: zRe-compressing...zArchive z failed to compress: zFailed to re-compress archive: Úend_timeÚrun_timeÚfiles_obfuscatedÚtotal_substitutionsr9   z! [removed %s unprocessable files]zObfuscation completedzException while processing rT  ),r_   r^   Úarchive_namer   ÚnowÚ	add_fieldÚis_extractedÚextractÚ
report_msgÚmultiprocessingÚQueueÚrangerK   r1   ÚProcessr)   ÚstartrÕ   ÚlistÚ	get_filesrR   rT   r`   Úabspathr  r   rU   Úemptyr   r   rd   Úload_parser_entriesÚobfuscate_directory_namesr    Úobfuscate_symlinksrÖ   Úget_compressionÚrename_top_dirrý   Úcompressrˆ   rï   rQ   rŒ   )rk   rÜ   r†  Úarc_mdrˆ  r   r    r!   r$   r%   Ú	processesrÏ   ræ   r&   ÚfocÚtscÚrfcr'   r©   ÚmethodrŠ  Úrmsgs   &&                    r(   rI  ÚSoSCleaner.obfuscate_reportú  s1  € ò
	<ðj	?Ø—_‘_×0Ñ0°×1EÑ1EÓFˆFÜ!Ÿš›ˆJØ×Ñ˜\¨:Ô6à×'×'Ð'Ø—‘Ô!Ø×ÑÐ9Ô:ð MNÐMÐ"ÐM _Ü)×/Ò/Ó1ˆKÜ*×0Ò0Ó2ˆLð ˆIÜ˜4Ÿ9™9Ÿ>™>Ö*�Ü#×+Ò+Ü/Ø!°Ð=ô�ð —‘”	Ø× Ñ  Ö#ñ +ñ -Ü�W×&Ñ&Ó(Ó)Ü—‘—‘¤§¡§¡°×0FÑ0FÓ GÓHö�ð —‘ Ö%ñ	ô ˜4Ÿ9™9Ÿ>™>Ö*�Ø—‘ Ö%ñ +ó �Ø—‘–ñ ð #×(Ñ(×*Ò*ðØ&2×&6Ñ&6Ó&8‘O�S˜sð '¨#Õ-Ð&Ø 3Õ&�Ø" cÕ)Ò"ð ×'Ñ'Ô)ð;Ø×.Ñ.¨wÔ7ð
;Ø×'Ñ'¨Ô0ð ×$×$Ð$Ø ×0Ñ0Ó2�ßØ×&Ñ&Ð':Ô;ð
Ø×.Ñ.Ø ×1Ñ1°'×2FÑ2FÓGôð  ×(Ñ(¨Ô0ð ×&Ñ&×-Ñ-¨gÔ6ä—|’|“~ˆHØ×Ñ˜Z¨Ô2Ø×Ñ˜Z¨°JÕ)>Ô?Ø×ÑÐ/Ð1GÔHØ×ÑÐ2°OÔDØˆDß!Ø:�ØÐ0Õ0�Ø×ÑÐ!6°t°fÐ=Ö>øôq ô Ø—M‘MðCØCDÀ#ÀQðH÷ò ûðûô& ô ;Ø—‘Ð AÀ#ÀÐGØ%,×%9Ñ%9ð ÷ ;ò ;ûð;ûô ô ;Ø—‘Ð >¸s¸eÐDØ%,×%9Ñ%9ð ÷ ;ò ;ûð;ûô %ô ØŸ™¨°'×2FÑ2FÐ1Gð H8Ø8;°uð(>ô ?à×*Ñ*Ø=¸c¸UÐCôEåûðûô& ô 	?Ø�K‰K×ÑÐ:Ø '× 4Ñ 4Ð5°R¸°uð>÷ ?ò ?ûð	?úsÔ   …AQ0 Á#FQ0 Ç=N È-Q0 È>N0 ÉO) É!Q0 É3Q0 ÊQ0 Ê;P" ËBQ0 Í!Q0 ÎN-ÎN(Î"Q0 Î(N-Î-Q0 Î0O&Î; O!ÏQ0 Ï!O&Ï&Q0 Ï)PÏ4 PÐQ0 ÐPÐQ0 Ð"Q-Ð-5Q(Ñ"Q0 Ñ(Q-Ñ-Q0 Ñ0R1Ñ;+R,Ò,R1c                ó<   € V P                   P                  V4       R # r†   )rÓ   r"   )rk   r!  s   &&r(   r6  ÚSoSCleaner.obfuscate_file{  s   € Ø×Ñ×,Ñ,¨XÖ6r„   c                óÚ  a	€ V P                  RVP                  R7       VP                  4        EF�  p VP                  VP                  4      ^,          P                  R4      o	V P                   Uu. uF[  p\        ;QJ d)    V	3R lVP                   4       F  '       g   K   RM	  RM! V	3R lVP                   4       4      '       d   KY  VNK]  	  ppV'       g   V P                  RS	 R24       KÆ  V P                  R	S	 2VP                  R7       \        P                  ! V4      p\        P                  P                  VP                  V P                  S	4      4      pV P                  V4      pWb8w  g   Wu8w  d0   \        P                  ! V4       \        P                   ! Wv4       EK�  EK„  	  R# u upi   \"         d$   pT P                  R
T RT 24        Rp?EK¶  Rp?ii ; i)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``
zObfuscating symlink namesr‰  ré   c              3   óD   <"  € T F  qP                  S4      x € K  	  R # 5ir†   )Úmatch)Ú.0Ú_skipÚ_syms   & €r(   Ú	<genexpr>Ú0SoSCleaner.obfuscate_symlinks.<locals>.<genexpr>‘  s   øé € ÐHÑ7G¨eŸ™ D×)Ð)Ó7Gùs   ƒ TFz Skipping obfuscation of symlink z due to skip pattern matchzObfuscating symlink zError obfuscating symlink 'rž   N)rd   rŽ  Úget_symlinksrâ   r  r  rh   ÚanyÚskip_patternsrˆ   rR   ÚreadlinkrT   rU   rý   rf   Úsymlinkr    )
rk   rÜ   r¹  Ú_pÚ_parsersÚ_targetÚ_ob_sym_nameÚ
_ob_targetr©   r²  s
   &&       @r(   rŸ  ÚSoSCleaner.obfuscate_symlinks~  s¤  ø€ ð 	�‰Ð1¸'×:NÑ:NˆÔOØ×+Ñ+×-ˆGð Oà—}‘} W×%;Ñ%;Ó<¸QÕ?×FÑFÀsÓK�ð "&§¢óÙ!-˜2ß“CÔH°r×7GÒ7GÓH—C—C’CÔH°r×7GÒ7GÓH×H÷ �B¡ð ð ÷  Ø—N‘NØ:¸4¸&ð A(ð )ôñ Ø—‘Ð!5°d°VÐ<Ø&-×&:Ñ&:ð ô <ô Ÿ+š+ gÓ.�ô  "Ÿw™wŸ|™|¨G×,BÑ,BØ,0×,AÑ,AÀ$Ó,Gó I�ð "×2Ñ2°7Ó;�
ð !Ô+°Ô1FÜ—I’I˜gÔ&Ü—J’J˜z×8ò 2Gó; .ùòøô4 ô OØ—‘Ð ;¸G¸9ÀCÈÀuÐM×NÓNûðOúsB   ´?F<Á3F7ÂF7Â$%F7ÃF7ÃF<Ã5B8F<Æ7F<Æ<G*ÇG%Ç%G*c                óˆ  € V P                  RVP                   24       \        VP                  4       RR7       EF  p\        P
                  ! V4       Få  p\        P                  P                  W#4      pVP                  VP                  4      R,          p\        P                  P                  V4      '       g   Kk  V P                  V4      pWc8w  g   K„  VP                  V4      p\        P                  P                  VP                  VP                  R4      V4      p\        P                  ! WG4       Kç  	  EK  	  R# )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 T)r  ré   Nrì   )rd   rŽ  rr  Úget_directory_listrR   ÚlistdirrT   rU   râ   r  rŸ   rý   rí   r  Úrename)rk   rÜ   ÚdirpathÚ_nameÚ_dirnameÚ_arc_dirÚ_ob_dirnameÚ_ob_arc_dirs   &&      r(   rž  Ú$SoSCleaner.obfuscate_directory_names¬  sñ   € ð 	�‰Ð?Ø ×-Ñ-Ð.ð0ô 	1ä˜g×8Ñ8Ó:ÀD×IÐIˆGÜŸš GÖ,�ÜŸ7™7Ÿ<™<¨Ó7�Ø#Ÿ>™>¨'×*@Ñ*@ÓAÀ"ÕE�Ü—7‘7—=‘= ×*Ô*Ø"&×"7Ñ"7¸Ó">�KØ"Ö+Ø&.§o¡o°eÓ&<˜Ü&(§g¡g§l¡lØ#×2Ñ2Ø'×.Ñ.¨sÓ3Ø'ó'˜ô
 Ÿ	š	 (Ö8ô -ó Jr„   c                óª   € V P                    F  p VP                  V4      pK  	  V#   \         d    pT P                  R T 24        Rp?K@  Rp?ii ; i)zError obfuscating string data: N)rh   Úparse_string_for_keysr    rd   )rk   Ústring_datarl   r©   s   &&  r(   rý   ÚSoSCleaner.obfuscate_stringÃ  sY   € Ø—l”lˆFðGØ$×:Ñ:¸;ÓG’ñ #ð
 Ðøô ô GØ—‘Ð ?À¸uÐE×FÒFûðGús   ‘(¨A³AÁAc                óN  € V P                   P                  R4      pV P                   Fy  pVP                  VP                  P	                  RR4      P                  4       4      pVP                  R\        VP                  P                  P                  4       4      4       K{  	  R# )zLWrite some cleaner-level, non-report-specific stats to the manifest
        rh   Ú rÏ   ÚentriesN)r_   r^   rh   rð   rÐ   rb   r�  rá   rñ   ÚdatasetÚkeys)rk   Ú	parse_secrl   Ú_secs   &   r(   rù   Ú"SoSCleaner.write_stats_to_manifestË  sv   € ð —O‘O×/Ñ/°	Ó:ˆ	Ø—l”lˆFØ×(Ñ(¨¯©×)<Ñ)<¸SÀ#Ó)F×)LÑ)LÓ)NÓOˆDØ�N‰N˜9¤c¨&¯.©.×*@Ñ*@×*EÑ*EÓ*GÓ&HÖIó #r„   )rî   ri   rX   r_   rï   rJ   r\   rZ   rÓ   rB   rj   rK   rh   rA   rÔ   rP   r@   r?   rQ   )NNNFNr†   )F)+ra   Ú
__module__Ú__qualname__Ú__firstlineno__r•   ÚdescÚarg_defaultsrI   r‚   rˆ   rd   r�   Úclassmethodr—   rW   r±   rÈ   rË   rÝ   rV   r  rû   rö   r,  r÷   rø   rÿ   rü   rõ   rJ  rô   rf  rv  ró   rI  r6  rŸ  rž  rý   rù   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rz   Ú__classdict__s   @@r(   r+   r+   @   s6  ù‡ € ñ%ðN D€Dð 	˜Ø�2Ø˜2Ø˜rØ�Ø�BØ˜ØÐ6Ø�UØ˜UØ�"Ø�RØ˜kð€L÷ \Gô|Bô:ô9ô:ð ñ&ó ð&òò8!ð: ñ80ó ð80òt ò JòDHòaòFAò0òò	òOôIò"ò$7òr3ò+ò-*ò^-ò
4ò?òB7ò,Oò\9ò.÷Jò Jr„   r+   ),r=  r£   rN   rR   r   rã   r”  r   Úpwdr   Úsos.cleaner.preppersrC   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.parsers.ipv6_parserr   Úsos.cleaner.archives.sosr   r   r   r   Úsos.cleaner.archives.genericr   r   Úsos.cleaner.archives.insightsr   Úsos.utilitiesr   r   r   r   r)   r+   r~   r„   r(   Ú<module>rî     so   ðó Û Û Û 	Û Û Û å Ý ã å Ý &Ý 5Ý 7Ý AÝ ?Ý AÝ 9÷=ó =÷ HÝ 9÷:ó :ò
%ô,QJ�ö QJr„   