U
    i©¹d  ã                   @   s&   d dl mZmZ G dd„ deeƒZdS )é    )ÚPluginÚUbuntuPluginc                   @   s4   e Zd ZdZdZdZdZdZdZdd„ Z	dd	„ Z
d
S )ÚVaultz£The Vault plugin collects the current status of the vault
    snap on a Ubuntu machine.

    It will collect logs from journal, vault status and configuration
    z3Manage access to secrets and protect sensitive dataÚvault)ZsysmgmtZsecurity)r   c              
   C   s´   d}|   |¡ zlt|dƒX}| ¡  ¡ D ]D}|s2q(| d¡}|d  ¡ dkr(|d  d¡}| jdd	|id
 q(W 5 Q R X W n4 tk
r® } z|  d||f ¡ W 5 d }~X Y nX d S )Nú /var/snap/vault/common/vault.hclÚrú=r   Úapi_addré   z" zvault statusZ
VAULT_ADDR)ÚenvzCould not open conf file %s: %s)	Zadd_copy_specÚopenÚreadÚ
splitlinesÚsplitÚstripZadd_cmd_outputÚIOErrorZ
_log_error)ÚselfZ	vault_cfgZcfÚlineZwordsr	   Úerror© r   ú:/usr/lib/python3/dist-packages/sos/report/plugins/vault.pyÚsetup   s"    

ÿÿzVault.setupc                 C   s   |   ddd¡ d S )Nr   z(password\s?=\s?).*z\1******)Zdo_file_sub)r   r   r   r   Úpostproc0   s
    ýzVault.postprocN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z
short_descZplugin_nameZprofilesÚservicesÚpackager   r   r   r   r   r   r      s   r   N)Zsos.report.pluginsr   r   r   r   r   r   r   Ú<module>   s   