
    ~ g                     6    S SK r S SKrS SKJr   " S S\5      rg)    N)SoSMapc                   V   ^  \ rS rSrSrSS/rSrSrSrSr	U 4S	 jr
U 4S
 jrS rSrU =r$ )	SoSMacMap   af  Mapping store for MAC addresses

MAC addresses added to this map will be broken into two halves, vendor and
device like how MAC addresses are normally crafted. For the vendor hextets,
obfuscation will take the form of 53:4f:53, or 'SOS' in hex. The following
device hextets will be randomized, for example a MAC address of
'60:55:cb:4b:c9:27' may be obfuscated into '53:4f:53:79:ac:29' or similar

This map supports both 48-bit and 64-bit MAC addresses.

48-bit address may take the form of either:

        MM:MM:MM:SS:SS:SS
        MM-MM-MM-SS-SS-SS

For 64-bit addresses, the identifier injected by IPv6 standards is
used in obfuscated returns. These addresses may take either of these forms:

    MM:MM:MM:FF:FE:SS:SS:SS
    MMMM:MMFF:FESS:SSSS

All mapped mac addresses are converted to lower case.
Dash delimited styles will be converted to colon-delimited style.
zff:ff:ff:ff:ff:ffz00:00:00:00:00:00z53:4f:53:%s:%s:%sz53:4f:53:ff:fe:%s:%s:%sz534f:53ff:fe%s:%s%sFc                    > UR                  SS5      R                  5       R                  S5      R                  5       n[        TU ]  U5      $ N-:z=.,)replacelowerstripsuperaddselfitem	__class__s     >/usr/lib/python3/dist-packages/sos/cleaner/mappings/mac_map.pyr   SoSMacMap.add5   ?    ||C%++-33E:@@Bw{4      c                    > UR                  SS5      R                  5       R                  S5      R                  5       n[        TU ]  U5      $ r   )r   r   r   r   getr   s     r   r   SoSMacMap.get9   r   r   c           	        ^ Sm/ n[        SS5       H6  nUR                  SR                  U4S j[        S5       5       5      5        M8     [        U5      n[        R
                  " SU5      (       a  U R                  U-  $ [        R
                  " SU5      (       a  U R                  U-  $ [        R
                  " S	U5      (       a  U R                  U-  $ g
)zFRandomize the device hextets, and append those to our 'vendor'
hextet
0123456789abdcefr       c              3   P   >#    U  H  n[         R                  " T5      v   M     g 7f)N)randomchoice).0x	hexdigitss     r   	<genexpr>*SoSMacMap.sanitize_item.<locals>.<genexpr>D   s     "NX6==#;#;Xs   #&   z$(([0-9a-fA-F]{2}:){7}[0-9a-fA-F]{2})z&(([0-9a-fA-F]{4}:){3}([0-9a-fA-F]){4})z([0-9a-fA-F][:_]?){12}N)	rangeappendjointuplerematchmac6_templatemac6_quad_templatemac_template)r   r   hextets_r$   s       @r   sanitize_itemSoSMacMap.sanitize_item=   s     '	q!ANN277"NU1X"NNO  .88:DAA%%//88<dCC**W4488,d33$$w..r    )__name__
__module____qualname____firstlineno____doc__ignore_matchesr0   r.   r/   compile_regexesr   r   r3   __static_attributes____classcell__)r   s   @r   r   r      sB    4 	N
 'L-M.O!! r   r   )r    r,   sos.cleaner.mappingsr   r   r5   r   r   <module>r@      s     	 '? ?r   