+
    Û1j÷/  ã                   ó>   € ^ RI t ^ RIt^ RIt^ RIHt  ! R R4      tR# )é    N)ÚPathc                   óê   a € ] tR t^t o Rt. t. tRtRtRt	Rt
]P                  ! R4      t]P                  ! R4      3R ltR tR tR	 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V tR# )ÚSoSMapzÖStandardized 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.
TFz
[^a-z0-9]+ú(?!)c                óø  € R V n         / V n        \        4       V n        . V n        \
        P                  ! R4      V n        \        4       V n        . V n	        / V n
        W n        V P                  P                  P                  4       V n        Wn        \"        P$                  P'                  V P                   RV P                  4      V n        ^ V n        V P-                  4        RV n         V P/                  4        R# )Tr   Úcleaner_cacheFN)ÚinitializingÚdatasetÚsetÚ_regexes_madeÚcompiled_regexesÚreÚcompileÚcompiled_searchÚ_simple_tokensÚ_complex_itemsÚ_regex_dictÚ_static_regexÚ	__class__Ú__name__ÚlowerÚcnameÚworkdirÚosÚpathÚjoinÚ	cache_dirÚcache_counterÚload_entriesÚgenerate_compiled_regexes)Úselfr   r   s   &&&Ú?/usr/lib/python3/dist-packages/sos/cleaner/mappings/__init__.pyÚ__init__ÚSoSMap.__init__&   sÀ   € Ø ˆÔØˆŒÜ ›UˆÔØ "ˆÔÜ!Ÿzšz¨&Ó1ˆÔÜ!›eˆÔØ ˆÔØˆÔØ*ÔØ—^‘^×,Ñ,×2Ñ2Ó4ˆŒ
ð ŒÜŸ™Ÿ™ d§l¡l°OØ&*§j¡jó2ˆŒàˆÔØ×ÑÔØ!ˆÔØ×&Ñ&Ö(ó    c                ór   € \        V P                  4      P                  RRR7       V P                  4        R# )a   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)ÚparentsÚexist_okN)r   r   ÚmkdirÚload_new_entries_from_dir)r!   s   &r"   r   ÚSoSMap.load_entries;   s,   € ô 	ˆT�^‰^Ó×"Ñ"¨4¸$Ð"Ô?Ø×&Ñ&Ö(r%   c                ó<  € V'       dQ   WP                   9   gA   WP                  P                  4       9   g#   V P                  '       d   \	        V4      ^8:  d   R# V P
                   F1  p\        P                  ! W!\        P                  4      '       g   K0   R# 	  R# )zpSome items need to be completely ignored, for example link-local or
loopback addresses should not be obfuscated
TF)	Ú	skip_keysr
   ÚvaluesÚignore_short_itemsÚlenÚignore_matchesr   ÚmatchÚI)r!   ÚitemÚskips   && r"   Úignore_itemÚSoSMap.ignore_itemK   sh   € ÷ �tŸ~™~Ô-°¿¹×9LÑ9LÓ9NÔ1NØ×+×+Ð+´°D³	¸Q´ÙØ×'Ô'ˆDÜ�xŠx˜¤B§D¡D×)Ô)Úñ (ñ r%   c                ó"   € W P                   V&   R # ©N)r
   )r!   r4   Úvalues   &&&r"   Úinsert_to_datasetÚSoSMap.insert_to_datasetW   s   € Ø"�‰�TÓr%   c                óÖ   €  V P                  WP                  V4      4       V P                  '       d   V P	                  V4       R # R #   \         d    T P                  Y4        LEi ; ir9   )r;   Úsanitize_itemÚ	ExceptionÚcompile_regexesÚadd_regex_item©r!   r4   s   &&r"   Úadd_sanitised_item_to_datasetÚ$SoSMap.add_sanitised_item_to_datasetZ   sb   € ð	/Ø×"Ñ" 4×);Ñ);¸DÓ)AÔBð ××ÐØ×Ñ Ö%ñ  øô ô 	/ð ×"Ñ" 4Ö.ð		/ús   ‚ A	 Á	A(Á'A(c                ó   € \         P                  ! V P                  4      ;_uu_ 4       pV Uu. uFW  pVP                  P	                  4       '       g   K%  \        VP                  4      V P                  8¼  g   KK  VP                  NKY  	  ppR R R 4       XP                  \
        R7       V F‘  p\         P                  P                  V P                  V4      p\        VRRR7      ;_uu_ 4       pVP                  4       pR R R 4       V P                  P                  XR4      '       d   K€  V P                  V4       K“  	  V'       d   \        VR,          4      V n        R # R # u upi   + '       g   i     Lå; i  + '       g   i     L„; i)N)ÚkeyÚrúutf-8©ÚencodingFéÿÿÿÿ)r   Úscandirr   ÚnameÚisdigitÚintr   Úsortr   r   ÚopenÚreadr
   ÚgetrC   )r!   ÚitÚfÚ	num_filesÚ	file_nameÚfnamer4   s   &      r"   r*   Ú SoSMap.load_new_entries_from_dire   s  € ô
 �ZŠZ˜Ÿ™×'Ô'¨2ñ óá�AØ—6‘6—>‘>×#ô ä(+¨A¯F©F«°t×7IÑ7IÑ(Iô �—”Ùð ð ÷ (ð 	�‰œ3ˆÔÛ"ˆIÜ—G‘G—L‘L §¡°Ó;ˆEÜ�e˜S¨7×3Õ3°qØ—v‘v“x�÷ 4à—<‘<×#Ñ# D¨%×0Ô0Ø×2Ñ2°4Ö8ñ #÷ Ü!$ Y¨r¥]Ó!3ˆDÖñ ùò÷ (×'ú÷ 4×3ús4   ©E*®"E%Á!E%Á;E%ÂE*Ã0E=Å%E*Å*E:	Å=Fc                óØ  € V P                  V4      '       d   V# RpV P                  P                  VR4      '       gæ   V'       g\   \        P                  ! V P
                  R7      p\        VP                  RRR7      ;_uu_ 4       pVP                  V4       RRR4        V ;P                  ^,          un	        \        P                  ! VP                  \        P                  P                  V P
                  V P                   4      4       V P                  V4       EK  V P                  V,          #   + '       g   i     L¥; i  \         d    T P!                  4         EKL  i ; i)zšAdd a particular item to the map, generating an obfuscated pair
for it.

Positional arguments:

    :param item:        The plaintext object to obfuscate
NF)ÚdirÚwrH   rI   )r6   r
   rS   ÚtempfileÚNamedTemporaryFiler   rQ   rM   Úwriter   r   Úlinkr   r   rC   ÚFileExistsErrorr*   )r!   r4   ÚtmpfilerU   s   &&  r"   ÚaddÚ
SoSMap.addz   s  € ð ×Ñ˜D×!Ò!ØˆKàˆØ—,‘,×"Ñ" 4¨×/Ò/ßä"×5Ò5¸$¿.¹.ÔI�Ü˜'Ÿ,™,¨°g×>Õ>À!Ø—G‘G˜D”M÷ ?ð1Ø×"Ò" aÕ'Õ"Ü—’˜Ÿ™ÜŸ™Ÿ™ T§^¡^Ø(,×(:Ñ(:Ð';ó>ô?ð ×2Ñ2°4×8ð �|‰|˜DÕ!Ð!÷ ?×>ûô #ô 1Ø×.Ñ.×0Ð0ð1ús   ÂD6Â"A>E	 Ä6E	Å	E)Å(E)c                ó¾  € V P                  V4      '       d   R# WP                  9  Ed3   V P                  P                  V4      '       Eg   VP	                  4       pV P                  P                  V4       V P                  '       d   R# V P                  V4      pV P                  '       d_   W P                  V&   VP                  4       '       d   V P                  P                  V4       R# V P                  P                  V4       R# V P                  P                  W34       V P                  P                  R RR7       V P!                  RR7       R# R# R# )z¿Add an item to the regexes dict and then re-sort the list that the
parsers will use during parse_line()

:param item:    The unobfuscated item to generate a regex for
:type item:     ``str``
Nc                 ó&   € \        V ^ ,          4      # ©r   ©r0   ©Úxs   &r"   Ú<lambda>Ú'SoSMap.add_regex_item.<locals>.<lambda>¿   s   € ¤# a¨¥d¤)r%   T©rF   Úreverse)Úonly_search)r6   r   r   Ú	fullmatchr   rc   r	   Úget_regex_resultÚuse_token_lookupr   Úisalnumr   r   Úappendr   rP   r    )r!   r4   Ú_regs   && r"   rA   ÚSoSMap.add_regex_item—   s  € ð ×Ñ˜D×!Ò!Ùð ×*Ñ*Õ*Ø×&Ñ&×0Ñ0°×6Ó6à—:‘:“<ˆDð
 ×Ñ×"Ñ" 4Ô(ð × × Ð Ùð ×(Ñ(¨Ó.ˆDØ×$×$Ð$Ø)-× Ñ  Ñ&Ø—<‘<—>’>Ø×'Ñ'×+Ñ+¨DÖ1à×'Ñ'×.Ñ.¨tÖ4à×%Ñ%×,Ñ,¨d¨\Ô:Ø×%Ñ%×*Ñ*Ù+°Tð +ô ;à×.Ñ.¸4Ð.Ö@ñ; 7ñ +r%   c                ó  € \        V P                  \        R R7      pV P                  '       d¡   V'       g'   V Uu/ uF  q3V P	                  V4      bK  	  upV n        V P                   Uu0 uF  q3P                  4       '       g   K  VkK  	  upV n        V P                   Uu. uF  q3P                  4       '       d   K  VNK  	  upV n        R# V'       g(   V Uu. uF  q3V P	                  V4      3NK  	  upV n	        RP                  V Uu. uF  q@P                  V4       NK  	  up4      p\        P                  ! V P                  V4      \        P                  R7      V n        R# u upi u upi u upi u upi u upi )Trm   Ú|)ÚflagsN)Úsortedr   r0   rr   rq   r   rs   r   r   r   r   Úget_regex_escaper   r   Úget_regex_fullwordr3   r   )r!   ro   Úkeysr4   ÚkÚpatterns   &&    r"   r    Ú SoSMap.generate_compiled_regexesÂ   sF  € Ü�d×(Ñ(¬c¸4Ô@ˆØ× × Ð ßáBFó$ÙBF¸$˜$×/Ñ/°Ó5Ò5Á$ñ$�Ô ð "&×!3Ò!3ó#Ù!3˜·|±|·~—�Ñ!3ñ#ˆDÔð "&×!3Ò!3ó#Ù!3˜¿<¹<¿>—�Ñ!3ñ#ˆDÖ÷ áDHó)ÙDH¸D˜4×0Ñ0°Ó6Ó7ÁDñ)�Ô%ð —h‘hÁtÓLÁtÀ!×#8Ñ#8¸Ó#;Ð"<Ò =ÁtÑLÓMˆGÜ#%§:¢:Ø×'Ñ'¨Ó0Ü—d‘dô$ˆDÖ ùò$ùò#ùò#ùò
)ùò  Ms)   »E*Á+E/ÂE/Â#E4Â?E4ÃE9ÄE>c                óR  € V P                   '       dè   VP                  4       p\        V P                  P	                  V4      4      pVP                  R4       . pW0P                  ,           F&  pVP                  WPP                  V,          34       K(  	  V P                   F.  pWR9   g   K  VP                  WPP                  V,          34       K0  	  \        V4      ^8”  d   VP                  R RR7       V# V P                  P                  V4      '       d   V P                  # . # )aH  Return (item, regex) pairs for items that match in the line.

For token-lookup maps, returns only the specific items found via
set intersection / substring matching, rather than the full
compiled_regexes list.

For regex-based maps, falls back to returning all compiled_regexes
when compiled_search matches (original behavior).
Ú c                 ó&   € \        V ^ ,          4      # rg   rh   ri   s   &r"   rk   Ú*SoSMap.get_matched_items.<locals>.<lambda>ñ   s   € ¬#¨a°­d¬)r%   Trm   )rr   r   r   Ú_token_split_reÚsplitÚdiscardr   rt   r   r   r0   rP   r   Úsearchr   )r!   ÚlineÚ
line_lowerÚtokensÚresultr4   s   &&    r"   Úget_matched_itemsÚSoSMap.get_matched_itemsÚ   sò   € ð × × Ð ØŸ™›ˆJÜ˜×-Ñ-×3Ñ3°JÓ?Ó@ˆFØ�N‰N˜2ÔàˆFØ×!4Ñ!4×4Ð4�Ø—‘˜t×%5Ñ%5°dÕ%;Ð<Ö=ñ 5à×+Ô+�ØÖ%Ø—M‘M 4×)9Ñ)9¸$Õ)?Ð"@ÖAñ ,ô �6‹{˜QŒØ—‘Ñ 3¸T�ÔBØˆMØ×Ñ×&Ñ& t×,Ò,Ø×(Ñ(Ð(Øˆ	r%   c                ó0   € \         P                  ! V4       # r9   )r   ÚescaperB   s   &&r"   r{   ÚSoSMap.get_regex_escape÷   s   € Ü—9’9˜T“?Ð#Ð$r%   c                óB   € R V R2pV P                   '       d   RV R2# V# )z(?:Ú)ú(?<![a-z0-9])ú
(?=\b|_|-))Úmatch_full_words_onlyrB   s   &&r"   r|   ÚSoSMap.get_regex_fullwordú   s/   € Ø�d�V˜1ˆ~ˆØ×%×%Ð%Ø# D 6¨Ð4Ð4Øˆr%   c                óÒ   € V P                   '       d   R\        P                  ! V4       R2pM\        P                  ! V4      p\        P                  ! V\        P                  4      # )aò  Generate the object/value that is used by the parser when iterating
over pre-generated regexes during parse_line(). For most parsers this
will simply be a ``re.Pattern()`` object, but for more complex parsers
this can be overridden to provide a different object, e.g. a tuple,
for that parser's specific iteration needs.

:param item:    The unobfuscated string to generate the regex for
:type item:     ``str``

:returns:       A compiled regex pattern for the item
:rtype:         ``re.Pattern``
r”   r•   )r–   r   r�   r   r3   rB   s   &&r"   rq   ÚSoSMap.get_regex_result   sI   € ð ×%×%Ð%Ø#¤B§I¢I¨d£OÐ#4°JÐ?‰Dä—9’9˜T“?ˆDÜ�zŠz˜$¤§¡Ó%Ð%r%   c                ó   € V# )zÝPerform the obfuscation relevant to the item being added to the map.

This should be overridden by each type of map that subclasses SoSMap

Positional arguments:

    :param item:        The plaintext object to obfuscate
© rB   s   &&r"   r>   ÚSoSMap.sanitize_item  s	   € ð ˆr%   c                óœ   € V P                  V4      '       d   V# WP                  9  d   V P                  V4      # V P                  V,          # )z‡Retrieve an item's obfuscated counterpart from the map. If the item
does not yet exist in the map, add it by generating one on the fly
)r6   r
   rc   rB   s   &&r"   rS   Ú
SoSMap.get  sA   € ð ×Ñ˜D×!Ò!ØˆKØ—|‘|Ô#Ø—8‘8˜D“>Ð!Ø�|‰|˜DÕ!Ð!r%   c                ó<   € V P                   P                  V4       R# )zýUpdate the map using information from a previous run to ensure that
we have consistent obfuscation between reports

Positional arguments:

    :param config:    A dict of mappings with the form of
                      {clean_entry: 'obfuscated_entry'}
N)r
   Úupdate)r!   Úconfigs   &&r"   Úconf_updateÚSoSMap.conf_update(  s   € ð 	�‰×Ñ˜FÖ#r%   )r   r   r   r   r   r   r   r   r   r   r
   r	   r   N)F) r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r1   r-   r@   r/   r–   rr   r   r   r…   r#   r   r6   r;   rC   r*   rc   rA   r    r�   r{   r|   rq   r>   rS   r¢   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r"   r   r      s    ø‡ € ñð €Nà€IØ€OØÐØ!Ðð Ðà—j’j Ó/€Oà.0¯jªj¸Ó.Aô )ò*)ò 
ò#ò	&ò4ò*"ò:)AôVò0ò:%òò&ò&	ò"÷	$ð 	$r%   r   )r   r   r]   Úpathlibr   r   r›   r%   r"   Ú<module>r¬      s   ðó 
Û 	Û Ý ÷`$ó `$r%   