o
    Û1j@  ã                   @   s@   d dl Z d dlmZ d dlmZ dZdZdZG dd„ deƒZdS )	é    N)ÚSoSCleanerParser)Ú	SoSMacMapzq((?<!([0-9a-fA-F\'\"]:)|::)(?:[^:|-])?(?:[0-9a-fA-F]{2}(?:(:|-)){7})[0-9a-fA-F]{2}(?:\'|\")?(?:\/|\,|\-|\.|\s|$))z‘((?<!(?:([.|^|\b]{5}\w|[.|^|\b]fe80:|fe80::)))(?:([0-9a-fA-F]{4}:){3}[0-9a-fA-F]{4})(?!\w))|(?:(?<!\w)(([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{4})(?!\w))z]((?<!([0-9a-fA-F\'\"]:)|::)(?:([^:\-])?(?:([0-9a-fA-F]{2}([:\-\_])){5,6}(?:[0-9a-fA-F]{2}))))c                	       sr   e Zd ZdZdZe d¡Ze de› de	› de
› d�¡ZdZdgZd	Zd
Zg f‡ fdd„	Zdd„ Zdd„ Z‡  ZS )ÚSoSMacParserz!Handles parsing for MAC addressesz
MAC Parserz"[0-9a-fA-F]{2}[:\-_][0-9a-fA-F]{2}z((z)|(z)))z53:4f:53z534f:53zsos_commands/.*/modinfo.*Úmac_mapFc                    s    t || jƒ| _tƒ  ||¡ d S )N)r   Úregex_patternÚmappingÚsuperÚ__init__)ÚselfÚconfigÚworkdirÚskip_cleaning_files©Ú	__class__© ú@/usr/lib/python3/dist-packages/sos/cleaner/parsers/mac_parser.pyr	   :   s   zSoSMacParser.__init__c                 C   sP   |d dvr|dd… }|d dvs|d dvr$|dd… }|d dvs|  ¡ S )z‰Strips away leading and trailing non-alphanum characters from any
        matched string to leave us with just the bare MAC addr
        r   Ú0123456789abcdefABCDEFé   Néÿÿÿÿ)Ústrip)r
   Úmatchr   r   r   Úreduce_mac_match>   s   ÿÿzSoSMacParser.reduce_mac_matchc                 C   s€   d}| j  |¡s||fS dd„ | j |¡D ƒ}|r<|t|ƒ7 }|D ]}|  |¡}| | j¡r/q!| j 	|¡}| 
||¡}q!||fS )Nr   c                 S   s   g | ]}|d  ‘qS )r   r   )Ú.0Úmr   r   r   Ú
<listcomp>M   s    z,SoSMacParser._parse_line.<locals>.<listcomp>)Ú_quick_checkÚsearchr   ÚfindallÚlenr   Ú
startswithÚobfuscated_patternsr   ÚgetÚreplace)r
   ÚlineÚcountÚmatchesr   Ústripped_matchÚ	new_matchr   r   r   Ú_parse_lineI   s   
zSoSMacParser._parse_line)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚreÚcompiler   ÚIPV6_REG_8HEXÚIPV6_REG_4HEXÚIPV4_REGr   r    Úparser_skip_filesÚmap_file_keyÚcompile_regexesr	   r   r(   Ú__classcell__r   r   r   r   r   %   s    
ÿÿr   )	r.   Úsos.cleaner.parsersr   Úsos.cleaner.mappings.mac_mapr   r0   r1   r2   r   r   r   r   r   Ú<module>   s   
ÿÿÿ