+
    Û1j^  ã                   óx   € ^ 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
HtHt R t ! R R4      tR# )é    N)ÚProcessPoolExecutor)Úfile_is_binaryÚsos_get_command_outputÚfile_is_certificatec           	      ó   € \         P                  ! V 4      ;_uu_ 4       p\        P                  P	                  VR 4      p\        \         RR 4      Vn        VP                  4        F²  p\        P                  P	                  W4P                  4      p\        P                  P                  V4      p\        P                  P                  V4      p\        P                  P                  Wg.4      pW†8w  d   \        RV RV 24      hVP                  WC4       K´  	  \        P                  P	                  W2P                  P                  R4      R,          P                  R4      ^ ,          4      uuRRR4       #   + '       g   i     R# ; i)	ÚcleanerÚfully_trusted_filterc                 ó   € V # ©N© )ÚmemberÚpaths   &&Ú?/usr/lib/python3/dist-packages/sos/cleaner/archives/__init__.pyÚ<lambda>Ú!extract_archive.<locals>.<lambda>#   s   € Á&ó    z"Attempted path traversal in tarflez != Ú/ú.tarNéÿÿÿÿ)ÚtarfileÚopenÚosr   ÚjoinÚgetattrÚextraction_filterÚ
getmembersÚnameÚabspathÚcommonprefixÚ	ExceptionÚextractÚsplit)	Úarchive_pathÚtmpdirÚarchiver   r   Úmember_pathÚabs_directoryÚ
abs_targetÚprefixs	   &&       r   Úextract_archiver*      s  € Ü	�Š�l×	#Ô	# wÜ�w‰w�|‰|˜F IÓ.ˆô
 %,¬GÐ5KÙ-Hó%KˆÔ!ð
 ×(Ñ(Ö*ˆFÜŸ'™'Ÿ,™, t¯[©[Ó9ˆKÜŸG™GŸO™O¨DÓ1ˆMÜŸ™Ÿ™¨Ó5ˆJÜ—W‘W×)Ñ)¨=Ð*EÓFˆFØÔ&ÜÐ"DØ#) (¨$¨}¨oð!?ó @ð @à�O‰O˜FÖ)ñ +ô �w‰w�|‰|˜D§,¡,×"4Ñ"4°SÓ"9¸"Õ"=×"CÑ"CÀFÓ"KÈAÕ"NÓO÷) 
$×	#×	#Ó	#ús   ŸEE<Å<F	c                   ód  a € ] tR t^3t o Rt^ t^ t^ tRtRt	Rt
/ tR tR tR tR tR tR,R
 ltR t]R 4       t]R 4       t]R 4       tR tR tR tR tR,R ltR,R ltR,R ltR,R ltR t ]R 4       t!R t"R t#R t$R t%R-R lt&R t'R t(R  t)R! t*R" t+R# t,R$ t-R% t.R& t/R' t0R( t1R) t2R* t3R+t4V t5R	# ).ÚSoSObfuscationArchivezÿA representation of an extracted archive or an sos archive build
directory which is used by SoSCleaner.

Each archive that needs to be obfuscated is loaded into an instance of this
class. All report-level operations should be contained within this class.
ÚundeterminedFc                ó*  € Wn         V P                   V n        W n        V P                   P                  R 4      R	,          P                  R4      ^ ,          V n        V P                  V n        \        P                  ! R4      V n        \        P                  ! R4      V n	        V P                  4       V n        RV n        V P                  4        RV n        W0n        W@n        R
V n        V P%                  RV P                    RV P&                   24       R# )r   r   ÚsosÚsos_uiFÚ zLoaded z	 as type Nr   r   )r#   Úfinal_archive_pathr$   r"   Úarchive_nameÚui_nameÚloggingÚ	getLoggerÚsoslogÚui_logÚ_load_skip_listÚ	skip_listÚis_extractedÚ
_load_selfÚarchive_rootÚkeep_binary_filesÚtreat_certificatesÚparsersÚlog_infoÚdescription)Úselfr#   r$   r>   r?   s   &&&&&r   Ú__init__ÚSoSObfuscationArchive.__init__C   sá   € à(ÔØ"&×"3Ñ"3ˆÔØŒØ ×-Ñ-×3Ñ3°CÓ8¸Õ<×BÑBÀ6ÓJÈ1ÕMˆÔØ×(Ñ(ˆŒÜ×'Ò'¨Ó.ˆŒÜ×'Ò'¨Ó1ˆŒØ×-Ñ-Ó/ˆŒØ!ˆÔØ�‰ÔØˆÔØ!2ÔØ"4ÔØˆŒØ�‰Ø�d×'Ñ'Ð(¨	°$×2BÑ2BÐ1CÐDö	
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)r@   Úparse_string_for_keysr    rA   )rC   Ústring_dataÚparserÚerrs   &&  r   Úobfuscate_stringÚ&SoSObfuscationArchive.obfuscate_stringW   sY   € Ø—l”lˆFðGØ$×:Ñ:¸;ÓG’ñ #ð
 Ðøô ô GØ—‘Ð ?À¸uÐE×FÒFûðGús   ‘(¨A³AÁAc                ó>  € V P                  VP                  R 4      R,          4      pVP                  VP                  R 4      R,          V4      pWA8w  dÈ   VP                  V4      ^ ,          p\        P                  P                  WT4      p\        P                  P                  V4      '       g   \        P                  ! W&4       R# V P                  \        P                  ! V4      4      p\        P                  ! V4       \        P                  ! Wv4       R# R# )r   Nr   )rK   r"   Úreplacer   r   r   ÚislinkÚrenameÚreadlinkÚremoveÚsymlink)rC   Ú
short_nameÚfilenameÚ_ob_short_nameÚ_ob_filenameÚarc_pathÚ_ob_pathÚ
_target_obs   &&&     r   Úobfuscate_filenameÚ(SoSObfuscationArchive.obfuscate_filenamea   sÑ   € Ø×.Ñ.¨z×/?Ñ/?ÀÓ/DÀRÕ/HÓIˆØ!×)Ñ)¨*×*:Ñ*:¸3Ó*?ÀÕ*CØ*8ó:ˆð Ô%Ø—~‘~ jÓ1°!Õ4ˆHÜ—w‘w—|‘| HÓ;ˆHô —7‘7—>‘> (×+Ò+Ü—	’	˜(Ö-ð "×2Ñ2´2·;²;¸xÓ3HÓI�
ô —	’	˜(Ô#ô —
’
˜:Ö0ñ! &r   c                ó   € Wn         R # r   )r@   )rC   r@   s   &&r   Úset_parsersÚ!SoSObfuscationArchive.set_parsersx   s   € ØŽr   c                óL   € V P                    F  pVP                  4        K  	  R # r   )r@   Úload_map_entries)rC   rI   s   & r   Úload_parser_entriesÚ)SoSObfuscationArchive.load_parser_entries{   s   € Ø—l”lˆFØ×#Ñ#Ö%ó #r   Nc                ó  € ^ pVP                  4       '       g   W3# Vf   V P                  pV F  p VP                  V4      w  rW5,          pK!  	  W3#   \         d+   pT P	                  RT 2TP
                  4        Rp?KV  Rp?ii ; i)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
Nzfailed to parse line: )Ústripr@   Ú
parse_liner    Ú	log_debugr   )rC   Úliner@   ÚcountrI   Ú_countrJ   s   &&&    r   Úobfuscate_lineÚ$SoSObfuscationArchive.obfuscate_line   sŽ   € ð ˆØ�z‰z�|Š|Ø�;ÐØŠ?Ø—l‘lˆGÛˆFðLØ%×0Ñ0°Ó6‘�Ø•’ñ ð ˆ{Ðøô ô LØ—‘Ð!7¸°uÐ=¸v¿{¹{×KÒKûðLús   ²AÁB	ÁBÂB	c                ó  a€ V P                  R \        P                  ! 4        RV 24        \        P                  P	                  WP
                  R7      oV P                  S4      '       d   R# V P                  '       g+   V P                  S4      '       d   V P                  S4       R# V P                  '       d+   \        V4      '       g   V P                  S4      '       d   R# \        P                  P                  V4      '       d   R# \        V4      pV'       dŸ   VR8X  d   V P                  S4       R# V P                  R8X  d   R# V P                  R8X  d   V P                  S4       R# V P                  R8X  d=   V P                  V4      p\        P                  P	                  VV P
                  R7      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"   T P                  RS;'       g    T R24       R# T P                  RS;'       g    T 24       ^ p\$        P&                  ! RV P(                  R7      ;_uu_ 4       p\+        VRRRR7      ;_uu_ 4       pV F0  p V P-                  W„4      w  r‰WY,          pVP/                  V4       K2  	  RRR4       VP3                  ^ 4       V'       d3   \4        P6                  ! VP8                  V4       V P;                  V4       RRR4       V P=                  SV4       R# u upi   \0         d#   p
T P                  RS RT
 24        Rp
?
KÐ  Rp
?
ii ; i  + '       g   i     L¬; i  + '       g   i     Ll; i  \0         d9   p
T P                  R \        P                  ! 4        RT RT
 24        Rp
?
R# Rp
?
ii ; i)z    pid=z: obfuscating )ÚstartNÚcertificatekeyÚkeeprR   Ú	obfuscatec              3   óD   <"  € T F  qP                  S4      x € K  	  R # 5ir   )Úmatch)Ú.0Ú_skipÚrel_names   & €r   Ú	<genexpr>Ú;SoSObfuscationArchive.obfuscate_arc_file.<locals>.<genexpr>Å   s   øé € ð Ù7G¨e—K‘K ×)Ð)Ó7Gùs   ƒ TFzSkipping obfuscation of z" due to matching file skip patternzObfuscating Úw)ÚmodeÚdirÚrúutf-8rN   )ÚencodingÚerrorszUnable to obfuscate ú: z': caught exception on obfuscating file )rg   r   Úgetpidr   ÚrelpathÚextracted_pathÚshould_skip_filer>   Úshould_remove_fileÚremove_filer   rO   r   r?   Úcertificate_to_textr@   ÚanyÚskip_patternsÚtempfileÚNamedTemporaryFiler$   r   rk   Úwriter    ÚseekÚshutilÚcopyfiler   Úupdate_sub_countr[   )rC   rU   Úis_certificateÚ_pÚ_parsersÚsubsÚtfileÚfnamerh   ÚcntrJ   rv   s   &&         @r   Úobfuscate_arc_fileÚ(SoSObfuscationArchive.obfuscate_arc_file›   sg  ø€ Ø�‰˜¤"§)¢)£+ ¨n¸X¸JÐGÔHðI	BÜ—w‘w—‘ x×7JÑ7J�ÓKˆHØ×$Ñ$ X×.Ò.ÙØ×*×*Ð*Ø×+Ñ+¨H×5Ò5ð × Ñ  Ô*ÙØ×&×&Ð&Ü# H×-Ò-Ø×,Ñ,¨X×6Ò6ñ Ü�w‰w�~‰~˜h×'Ò'ñ Ü0°Ó:ˆNßØ!Ð%5Ô5à×$Ñ$ XÔ.ÙØ×*Ñ*¨fÔ4ÙØ×*Ñ*¨hÔ6Ø×$Ñ$ XÔ.ÙØ×*Ñ*¨kÔ9ð  $×7Ñ7¸ÓA�HÜ!Ÿw™wŸ™¨xØ59×5HÑ5Hð  /ó  J�Hð "Ÿ\š\óÙ)�rß“ô Ø79×7GÒ7Gó——’ô Ø79×7GÒ7Gó÷ ÷ �™\ð ð ÷ Ø—‘Ø.¨x×/CÐ/C¸8Ð.Dð E8ð 9ôñ Ø�N‰N˜\¨(×*>Ð*>°hÐ)?Ð@ÔAØˆDÜ×,Ò,°#¸4¿;¹;×GÕGØÜ˜( C°'Ø!*÷,õ ,Ø/4Û %˜ðAØ(,×(;Ñ(;¸DÓ(K™I˜DØ �K˜DØ!ŸK™K¨Ö-ñ	 !&÷,ð —
‘
˜1”ßÜ—O’O E§J¡J°Ô9Ø×)Ñ)¨$Ô/÷ Hð" ×#Ñ# H¨hÖ7ùò?øô.  )ô AØ ŸN™NÐ-AØ.6¨Z°r¸#¸ð,@÷ Aò AûðAú÷,÷ ,ú÷ H×Gûô& ô 	BØ�N‰N˜X¤b§i¢i£k ]ð 3/Ø/7¨j¸¸3¸%ðA÷ Bò Bûð	Búsë   ­A N= Á0N= ÂN= ÂN= Â,N= Â>'N= Ã($N= Ä+N= Ä<N= Å"N= Å3AN= ÇM"ÇM"Ç?%M"È)M"È/N= É
N= ÉN= É/5N= Ê$N*Ê<N	Ë,M'
Ë/N	Ë3 N*Ì2N*ÍN= Í"N= Í'NÍ2NÎ	N	ÎNÎN	ÎN'Î"N*Î*N:	Î5N= Î=P Ï-O;Ï;P c                ó   € \         h)z=Check if the archive is a well-known type we directly support)ÚNotImplementedError)ÚclsrX   s   &&r   Úcheck_is_typeÚ#SoSObfuscationArchive.check_is_typeè   s
   € ô "Ð!r   c                óP   € R V P                   P                  P                  4       9   # )r/   )Ú	__class__Ú__name__Úlower©rC   s   &r   Úis_sosÚSoSObfuscationArchive.is_sosí   s    € à˜Ÿ™×/Ñ/×5Ñ5Ó7Ñ7Ð7r   c                ó    € R V P                   9   # )Úinsights)Ú	type_namer£   s   &r   Úis_insightsÚ!SoSObfuscationArchive.is_insightsñ   s   € à˜TŸ^™^Ñ+Ð+r   c                óx   € V P                   '       d(   \        P                  ! V P                  4      V n        R # R # r   )Ú
is_tarfiler   r   r#   Útarobjr£   s   &r   r<   Ú SoSObfuscationArchive._load_selfõ   s&   € Ø�?�?ˆ?ä!Ÿ,š, t×'8Ñ'8Ó9ˆDŽKñ r   c                ó   € . # )a  Return a list of ObfuscationArchives that represent additional
archives found within the target archive. For example, an archive from
`sos collect` will return a list of ``SoSReportArchive`` objects.

This should be overridden by individual types of ObfuscationArchive's
r   r£   s   &r   Úget_nested_archivesÚ)SoSObfuscationArchive.get_nested_archivesú   s	   € ð ˆ	r   c                ój  € V P                   '       dz   V P                  P                  pVP                  4       '       d   VP                  # \
        P                  P                  VP                  4      ;'       g    \
        P                  # \
        P                  P                  V P                  4      # )zlSet the root path for the archive that should be prepended to any
filenames given to methods in this class.
)r¬   r­   ÚfirstmemberÚisdirr   r   r   ÚdirnameÚsepr   r#   )rC   Útoplevels   & r   Úget_archive_rootÚ&SoSObfuscationArchive.get_archive_root  so   € ð �?�?ˆ?Ø—{‘{×.Ñ.ˆHØ�~‰~×ÒØ—}‘}Ð$Ü—7‘7—?‘? 8§=¡=Ó1×;Ð;´R·V±VÐ;Ü�w‰w�‰˜t×0Ñ0Ó1Ð1r   c                ój   € V P                   P                  V P                  R,           R RV 24       R# )z9Helper to easily format ui messages on a per-report basisz :z<50Ú N)r8   Úinfor4   )rC   Úmsgs   &&r   Ú
report_msgÚ SoSObfuscationArchive.report_msg  s+   € à�‰×Ñ˜DŸL™L¨4Õ/°Ð4°A°c°UÐ;Ö<r   c                óF   € R V'       d   RV 2MR RV P                    RV 2# )z[cleanerÚ:r1   Ú[z]] )r3   ©rC   r½   Úcallers   &&&r   Ú_fmt_log_msgÚ"SoSObfuscationArchive._fmt_log_msg  s2   € Ø¯&˜A˜f˜X™,°bÐ9Ø�4×$Ñ$Ð% S¨¨ð/ð 	/r   c                óZ   € V P                   P                  V P                  W4      4       R # r   )r7   ÚdebugrÅ   rÃ   s   &&&r   rg   ÚSoSObfuscationArchive.log_debug  ó   € Ø�‰×Ñ˜$×+Ñ+¨CÓ8Ö9r   c                óZ   € V P                   P                  V P                  W4      4       R # r   )r7   r¼   rÅ   rÃ   s   &&&r   rA   ÚSoSObfuscationArchive.log_info  s   € Ø�‰×Ñ˜×*Ñ*¨3Ó7Ö8r   c                óZ   € V P                   P                  V P                  W4      4       R # r   )r7   ÚerrorrÅ   rÃ   s   &&&r   Ú	log_errorÚSoSObfuscationArchive.log_error  rÊ   r   c                ó
   € . RO# )ziProvide a list of files and file regexes to skip obfuscation on

Returns: list of files and file regexes
)zproc/kallsymsz
sosreport-zsys/firmwarezsys/fszsys/kernel/debugz
sys/moduler   r£   s   &r   r9   Ú%SoSObfuscationArchive._load_skip_list  s   € ò

ð 	
r   c                óh   €  \         P                  ! V P                  4      #   \         d     R # i ; i©F)r   r¬   r#   r    r£   s   &r   r¬   Ú SoSObfuscationArchive.is_tarfile-  s0   € ð	Ü×%Ò% d×&7Ñ&7Ó8Ð8øÜô 	Úð	ús   ‚" ¢1°1c                óš   € V R2pV P                  RV R24       \        RV R\        V4       24       \        P                  ! V4       V# )z‹Convert a certificate to text. This is used when cleaner encounters
a certificate file and the option 'treat_certificates' is 'obfuscate'.
z.textzConverting certificate file 'z	' to textz openssl storeutl -r -noout -out z -text -certs )rA   r   Ústrr   rR   )rC   r–   Úout_fns   && r   r‡   Ú)SoSObfuscationArchive.certificate_to_text4  sZ   € ð �7˜%�ˆØ�‰Ð5°e°W¸IÐFÔGÜØ.¨v¨hð 7Ü ›J˜<ð)ô	
ô 	�	Š	�%ÔØˆr   c                óÄ   € V P                  V4      pV'       dG   V P                  RV R24       \        P                  ! V4       V ;P                  ^,          un        R# R# )zxRemove a file from the archive. This is used when cleaner encounters
a binary file, which we cannot reliably obfuscate.
zRemoving binary file 'z' from archiveN)Úget_file_pathrA   r   rR   Úremoved_file_count)rC   r–   Ú
full_fnames   && r   r†   Ú!SoSObfuscationArchive.remove_fileA  sO   € ð ×'Ñ'¨Ó.ˆ
çØ�M‰MÐ2°5°'¸ÐHÔIÜ�IŠI�jÔ!Ø×#Ò# qÕ(×#ñ r   c                ó  € V P                   '       gR   V P                  '       g   V P                  4       V n        \        P                  P                  V P                  V4      # \        P                  P                  V P                  V4      # )z¢Based on the type of archive we're dealing with, do whatever that
archive requires to a provided **relative** filepath to be able to
access it within the archive
)r;   r=   r¸   r   r   r   rƒ   )rC   r–   s   &&r   Úformat_file_nameÚ&SoSObfuscationArchive.format_file_nameL  sc   € ð
 × × Ð Ø×$×$Ð$Ø$(×$9Ñ$9Ó$;�Ô!Ü—7‘7—<‘< × 1Ñ 1°5Ó9Ð9Ü�w‰w�|‰|˜D×/Ñ/°Ó7Ð7r   c                ó2  € V P                   RJ d]   V P                  '       dK   V P                  V4      p V P                  P	                  V4      P                  4       P                  R4      #  \        V P                  V4      RRR7      ;_uu_ 4       pVP                  4       uuRRR4       #   \         d    T P                  RT R24        R# i ; i  + '       g   i     R# ; i  \         d#   pT P                  R	T R
T 24        Rp?R# Rp?ii ; i)z¨Return the content from the specified fname. Particularly useful for
tarball-type archives so we can retrieve prep file contents prior to
extracting the entire archive
Fr}   zUnable to retrieve z: no such file in archiver1   r|   )r~   NzFailed to get contents of r€   )r;   r¬   rà   r­   ÚextractfileÚreadÚdecodeÚKeyErrorrg   r   r    )rC   r–   rU   Úto_readrJ   s   &&   r   Úget_file_contentÚ&SoSObfuscationArchive.get_file_contentW  sÿ   € ð
 ×Ñ Ó%¨$¯/¯/¨/Ø×,Ñ,¨UÓ3ˆHðØ—{‘{×.Ñ.¨xÓ8×=Ñ=Ó?×FÑFÀwÓOÐOðÜ˜$×/Ñ/°Ó6¸Ø#*÷,õ ,Ø/6Ø"Ÿ<™<›>÷,ò ,øô ô Ø—‘Ø)¨%¨Ð0IÐJôò ð	ú÷,÷ ,ð ,ûô ô Ø—‘Ð!;¸E¸7À"ÀSÀEÐJÔKÝûðúsG   µ7B. Á.%C) ÂCÂ#
C) Â. CÃCÃC&	Ã C) Ã&C) Ã)DÃ4DÄDc                ón  € V P                   '       d>   V'       g   V P                  R 4       V P                  4       V n        RV n        RV n        MV P                  V n        \        P                  ! 4       ^ 8w  Edî   V P                  R4       \        P                  ! V P                  4       EF·  w  r#p V Fm  p\        P                  P                  W%4      p\        P                  ! V4      P                  p\        P                  ! Wg\        P                   ,          4       Ko  	  V EF5  p\        P                  P                  W(4      p	\        P                  P#                  V	4      '       d&   \        P                  P%                  V	4      '       d   Ko  \        P&                  ! V	\        P(                  4      '       d.   \        P&                  ! V	\        P*                  4      '       d   KÇ  V P                  RV	P-                  V P                  4      R,           24       \        P                  ! V	\        P.                  \        P0                  ,          4       EK8  	  EKº  	  V P                  RV P                   24       R#   \2         d!   p
T P                  RT
 24        Rp
?
EK  Rp
?
ii ; i)zExtracting...TNz)Verifying permissions of archive contentszAdding owner rw permissions to z!Error while trying to set perms: zExtracted path is r   )r¬   r¾   Úextract_selfrƒ   r;   r­   r#   r   Úgetuidrg   Úwalkr   r   ÚstatÚst_modeÚchmodÚS_IRWXUÚexistsrO   ÚaccessÚR_OKÚW_OKr"   ÚS_IRUSRÚS_IWUSRr    )rC   Úquietrµ   ÚdirsÚfilesÚ_dirÚ_dirnameÚ
_dir_permsrU   r–   rJ   s   &&         r   r!   ÚSoSObfuscationArchive.extractn  sÓ  € Ø�?�?ˆ?ßØ—‘ Ô0Ø"&×"3Ñ"3Ó"5ˆDÔØ $ˆDÔØˆD�Kà"&×"3Ñ"3ˆDÔô �9Š9‹;˜!ÕØ�N‰NÐFÔGÜ(*¯ª°×0CÑ0C×(DÑ$�˜uðNÛ $˜Ü#%§7¡7§<¡<°Ó#>˜Ü%'§W¢W¨XÓ%6×%>Ñ%>˜
ÜŸš ¼¿¹Õ+DÖEñ !%ô %*˜Ü "§¡§¡¨WÓ ?˜ä!Ÿw™wŸ~™~¨e×4Ò4¼¿¹¿¹Àu×8MÒ8MÙ$Ü "§	¢	¨%´·±× 9Ò 9Ü "§	¢	¨%´·±× 9Ô 9Ø ŸN™NØ AØ#(§;¡;¨t×/@Ñ/@Ó#AÀ"Õ#EÐ"Fð!Hôô ŸHšH U¬D¯L©L¼4¿<¹<Õ,G×Hô %*ñ )Eð( 	�‰Ð+¨D×,?Ñ,?Ð+@ÐAÖBøô !ô NØ—N‘NÐ%FÀsÀeÐ#L×MÓMûðNús,   Â5C!J	Æ,J	Ç(J	Ç1A3J	Ê	J4ÊJ/Ê/J4c                ó¬   € V P                   P                  V P                  V4      pWn        \        P                  ! V P                   V4       W n         R# )z¸Rename the top-level directory to new_name, which should be an
obfuscated string that scrubs the hostname from the top-level dir
which would be named after the unobfuscated sos report
N)rƒ   rN   r3   r   rP   )rC   Únew_nameÚ_paths   && r   Úrename_top_dirÚ$SoSObfuscationArchive.rename_top_dir”  sB   € ð
 ×#Ñ#×+Ñ+¨D×,=Ñ,=¸xÓHˆØ$ÔÜ
�	Š	�$×%Ñ% uÔ-Ø#Ör   c                ót   € V P                   '       d&   V P                  P                  R4      '       d   R# R# R# )z Return the compression type used by the archive, if any. This is
then used by SoSCleaner to generate a policy-derived compression
command to repack the archive
ÚxzÚgzN)r¬   r#   Úendswithr£   s   &r   Úget_compressionÚ%SoSObfuscationArchive.get_compressionž  s-   € ð
 �?�?ˆ?Ø× Ñ ×)Ñ)¨$×/Ò/ÙÙÙr   c                óÎ  € RpV P                   R,           p/ pV'       d)   VRV 2,          pVRV 2,          pVR8X  d   R^/pMR^/pV P                  RV 24       \        P                  ! V3R	V/VB ;_uu_ 4       pVP	                  V P                   \
        P                  P                  V P                  4      ^,          R
7       RRR4       V#   + '       g   i     T# ; i)zIPack the extracted archive as a tarfile to then be re-compressed
        ry   z-obfuscated.tarrÁ   Ú.r  ÚpresetÚcompresslevelzBuilding tar file rz   )ÚarcnameN)	rƒ   rg   r   r   Úaddr   r   r"   r3   )rC   Úmethodrz   ÚtarpathÚ
compr_argsÚtars   &&    r   Úbuild_tar_fileÚ$SoSObfuscationArchive.build_tar_file©  sÜ   € ð ˆØ×%Ñ%Ð(9Õ9ˆØˆ
ßØ�a˜�x�LÕ ˆDØ˜˜6˜(�|Õ#ˆGØ˜Œ~Ø&¨˜]‘
à-¨qÐ1�
Ø�‰Ð+¨G¨9Ð5Ô6Ü�\Š\˜'Ñ;¨Ð;°
×;Ò;¸sØ�G‰G�D×'Ñ'ÜŸG™GŸM™M¨$×*;Ñ*;Ó<¸QÕ?ð ô A÷ <ð ˆ÷ <Ö;ð ˆús   Á=ACÃC$	c                ó^  €  V P                  V4      V n        T P                  RT P                   24        T P	                  4        R#   \         d   pT P                  RT 24       h Rp?ii ; i  \         d1   pT P                  RT 24       T P                  R4        Rp?R# Rp?ii ; i)z…Execute the compression command, and set the appropriate final
archive path for later reference by SoSCleaner on a per-archive basis
z(Exception while re-compressing archive: NzCompressed to z'Failed to remove extraction directory: z/Failed to remove temporary extraction directory)r  r2   r    rg   Úremove_extracted_pathr¾   )rC   r  rJ   s   && r   ÚcompressÚSoSObfuscationArchive.compress¼  s¨   € ð	Ø&*×&9Ñ&9¸&Ó&AˆDÔ#ð 	�‰˜¨×(?Ñ(?Ð'@ÐAÔBð	OØ×&Ñ&Ö(øô ô 	Ø�N‰NÐEÀcÀUÐKÔLØûð	ûô ô 	OØ�N‰NÐDÀSÀEÐJÔKØ�O‰OÐM×NÒNûð	Oús.   ‚A	 ·A1 Á	A.ÁA)Á)A.Á1B,Á<%B'Â'B,c                óê  €  V P                  RV P                   24       \        P                  ! V P                  4       R#   \         d¦    \
        P                  ! T P                  \        P                  4       \
        P                  P                  T P                  4      '       d$   \
        P                  ! T P                  4        R# \        P                  ! T P                  4        R# i ; i)zŽAfter the tarball has been re-compressed, remove the extracted path
so that we don't take up that duplicate space any longer during
execution
z	Removing N)rg   rƒ   rŽ   ÚrmtreeÚOSErrorr   rð   rî   r÷   r   ÚisfilerR   r£   s   &r   r  Ú+SoSObfuscationArchive.remove_extracted_pathÌ  s—   € ð
	3Ø�N‰N˜Y t×':Ñ':Ð&;Ð<Ô=Ü�MŠM˜$×-Ñ-Ö.øÜô 	3Ü�HŠH�T×(Ñ(¬$¯,©,Ô7Ü�w‰w�~‰~˜d×1Ñ1×2Ò2Ü—	’	˜$×-Ñ-×.ä—’˜d×1Ñ1×2ð	3ús   ‚>A ÁA(C2Â+ C2Ã C2Ã1C2c                óà   € \        ^4      ;_uu_ 4       pVP                  \        V P                  V P                  4      pVP                  4       pVuuRRR4       #   + '       g   i     R# ; i)zmExtract an archive into our tmpdir so that we may inspect it or
iterate through its contents for obfuscation
N)r   Úsubmitr*   r#   r$   Úresult)rC   Ú_poolÚ_path_futurer   s   &   r   rë   Ú"SoSObfuscationArchive.extract_selfÛ  sQ   € ô
 ! ×#Ô# uØ Ÿ<™<¬Ø(,×(9Ñ(9¸4¿;¹;óHˆLà×&Ñ&Ó(ˆDØ÷	 $×#×#Ó#ús   ”=AÁA-	c              #  ó®  "  € \         P                  ! V P                  4       F¬  w  rpV FM  p\         P                  P	                  W4      p\         P                  P                  V4      '       g   KI  Vx € KO  	  V FM  p\         P                  P	                  W4      p\         P                  P                  V4      '       g   KI  Vx € KO  	  K®  	  R# 5i)z.Iterator for a list of symlinks in the archiveN)r   rí   rƒ   r   r   rO   )rC   rµ   rù   rú   rû   Ú_dirpathrU   Ú_fnames   &       r   Úget_symlinksÚ"SoSObfuscationArchive.get_symlinksæ  sŽ   é € ä$&§G¢G¨D×,?Ñ,?Ö$@Ñ ˆG˜5Û�ÜŸ7™7Ÿ<™<¨Ó6�Ü—7‘7—>‘> (×+Ô+Ø"”Nñ ó "�ÜŸ™Ÿ™ gÓ8�Ü—7‘7—>‘> &×)Ô)Ø ”Ló "ó %Aùs   ‚A-CÁ4ACÃCc              #  ó&  "  € \         P                  ! V P                  4       Fh  w  rpV F\  p\         P                  P	                  WP                  R4      4      p\         P                  P                  V4      '       d   KX  Vx € K^  	  Kj  	  R# 5i)z‰Iterator for a list of files in the archive, to allow clean to
iterate over.

Will not include symlinks, as those are handled separately
r   N)r   rí   rƒ   r   r   ÚlstriprO   )rC   rµ   Ú_rú   rU   r'  s   &     r   Ú	get_filesÚSoSObfuscationArchive.get_filesò  sb   é € ô "$§¢¨×)<Ñ)<Ö!=ÑˆG˜Û!�ÜŸ™Ÿ™ g¯©¸sÓ/CÓD�Ü—w‘w—~‘~ f×-Ô-Ø ”Ló "ó ">ùs   ‚A<BÂBc                ó‚   € . p\         P                  ! V P                  4       F  w  p pVP                  V4       K  	  V# )z3Return a list of all directories within the archive)r   rí   rƒ   Úappend)rC   Údir_listrµ   r,  s   &   r   Úget_directory_listÚ(SoSObfuscationArchive.get_directory_listþ  s7   € àˆÜŸWšW T×%8Ñ%8Ö9‰MˆG�Q˜Ø�O‰O˜GÖ$ñ :àˆr   c                ój   € V ;P                   ^,          un         V ;P                  V,          un        R# )z‚Called when a file has finished being parsed and used to track
total substitutions made and number of files that had changes made
N)Úfiles_obfuscated_countÚtotal_sub_count)rC   ri   s   &&r   r�   Ú&SoSObfuscationArchive.update_sub_count  s&   € ð 	×#Ò# qÕ(Õ#Ø×Ò Õ%×r   c                óÆ   € \         P                  P                  V P                  VP	                  R4      4      p\         P                  P                  V4      '       d   V# R# )zoReturn the filepath of a specific file within the archive so that
it may be selectively inspected if it exists
r   r1   )r   r   r   rƒ   r+  rò   )rC   r–   r  s   && r   rÛ   Ú#SoSObfuscationArchive.get_file_path  sD   € ô —‘—‘˜T×0Ñ0°%·,±,¸sÓ2CÓDˆÜŸ™Ÿ™ u×-Ò-ˆuÐ5°2Ð5r   c                ó¼  € \         P                  P                  V P                  V4      4      '       gK   \         P                  P	                  V P                  V4      4      '       g   V P                  V R24       R# V P                   FM  pVP                  V4      '       g   \        P                  ! W!4      '       g   K8  V P                  V R24        R# 	  R# )zýChecks the provided filename against a list of filepaths to not
perform obfuscation on, as defined in self.skip_list

Positional arguments:

    :param filename str:        Filename relative to the extracted
                                archive root
z, isn't a file or link, skipping obfuscation.Tz' is in skip list, skipping obfuscation.F)
r   r   r  rÛ   rO   rg   r:   Ú
startswithÚrers   )rC   rU   ru   s   && r   r„   Ú&SoSObfuscationArchive.should_skip_file  sª   € ô —‘—‘˜t×1Ñ1°(Ó;×<Ò<Ü—‘—‘˜t×1Ñ1°(Ó;×<Ò<Ø�N‰NØ�*ÐHÐIôñ à—^”^ˆEØ×"Ñ" 5×)Ò)¬R¯XªX°e×-FÔ-FØ—‘Ø�jÐ GÐHôò ñ $ñ r   c                óà   € . ROpV F"  p\         P                  ! W14      '       g   K!   R# 	  V P                  V4      p\        P                  P                  V4      '       d   \        V4      # R# )a1  Determine if the file should be removed or not, due to an inability
to reliably obfuscate that file based on the filename.

:param fname:       Filename relative to the extracted archive root
:type fname:        ``str``

:returns:   ``True`` if the file cannot be reliably obfuscated
:rtype:     ``bool``
TF)	z.*\.gz$z.*\.xz$z
.*\.bzip2$z.*\.tar\..*z.*\.txz$z.*\.tgz$z.*\.bin$z.*\.journal$z.*\~$)r<  rs   rÛ   r   r   r  r   )rC   r–   Úobvious_removesÚ_arc_regÚ
_full_paths   &&   r   r…   Ú(SoSObfuscationArchive.should_remove_file,  sZ   € ò

ˆó (ˆHÜ�xŠx˜×(Ô(Úñ (ð ×'Ñ'¨Ó.ˆ
Ü�7‰7�>‰>˜*×%Ò%Ü! *Ó-Ð-ár   )r3   r#   r=   rƒ   r2   r;   r>   r@   r:   r7   r­   r$   r?   r8   r4   r   rÔ   )6r¡   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r5  r6  rÜ   r¨   rB   Ú	is_nestedÚ
prep_filesrD   rK   r[   r^   rb   rk   r˜   Úclassmethodr�   Úpropertyr¤   r©   r<   r°   r¸   r¾   rÅ   rg   rA   rÏ   r9   r¬   r‡   r†   rà   rè   r!   r  r  r  r  r  rë   r(  r-  r2  r�   rÛ   r„   r…   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r,   r,   3   s6  ø‡ € ñð ÐØ€OØÐØ€IØ €KØ€IØ€Jò
ò(ò1ò.ò&ôò8KBðZ ñ"ó ð"ð ñ8ó ð8ð ñ,ó ð,ò:ò
ò	2ò=ô/ô:ô9ô:ò
ð ñó ðòò	)ò	8òô.$CòL$ò	òò&Oò 3ò	ò
!ò
!òò&ò6ò÷2 ð  r   r,   )r5   r   rŽ   rî   r   rŠ   r<  Úconcurrent.futuresr   Úsos.utilitiesr   r   r   r*   r,   r   r   r   Ú<module>rP     s;   ðó Û 	Û Û Û Û Û 	å 2÷0ñ 0òP÷0Yó Yr   