U
    -_g	                     @   s.   d dl mZmZmZmZ G dd deeZdS )    )PluginIndependentPluginSoSPredicate	PluginOptc                   @   s@   e Zd ZdZdZdZeddddgZdZd	Z	d
d Z
dd ZdS )	LibreswanzLibreswan IPsec	libreswan)ZnetworkZsecurityZ	openshift
ipsec-barfFzcollect ipsec barf output)defaultZdesc)/etc/ipsec.conf)r   Zopenswanc                 C   st   |  dddg | ddddg t| dd	gd
did}| jddg|d | dr^| d | ddddg d S )Nr
   z/etc/ipsec.dz/proc/net/xfrm_statzipsec verifyzipsec whack --statuszipsec whack --listallzcertutil -L -d sql:/etc/ipsec.dZ	xfrm_userZ	xfrm_algokmodsall)r   Zrequiredzip xfrm policyzip xfrm state)Zpredr   z
ipsec barfz/etc/ipsec.secretsz/etc/ipsec.secrets.dz/etc/ipsec.d/*.dbz/etc/ipsec.d/*.secrets)Zadd_copy_specZadd_cmd_outputr   
get_optionZadd_forbidden_path)selfZ	xfrm_pred r   >/usr/lib/python3/dist-packages/sos/report/plugins/libreswan.pysetup   s8    


zLibreswan.setupc                 C   s.   d}|  d|d | dr*|  d|d d S )Nz/(aead|auth|auth-trunc|enc)(\s.*\s)(0x[0-9a-f]+)statez\1\2********r   Zbarf)Zdo_cmd_output_subr   )r   Zxfrm_state_regexpr   r   r   postproc@   s    
zLibreswan.postprocN)__name__
__module____qualname__Z
short_descZplugin_nameZprofilesr   Zoption_listfilesZpackagesr   r   r   r   r   r   r      s   "r   N)Zsos.report.pluginsr   r   r   r   r   r   r   r   r   <module>   s   