U
    -Ø_gú  ã                   @   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}|   |¡ zpt|dddX}| ¡  ¡ D ]D}|s6q,| d¡}|d  ¡ dkr,|d  d	¡}| jd
d|id q,W 5 Q R X W n8 tk
r¶ } z|  d|› d|› ¡ W 5 d }~X Y nX d S )Nú /var/snap/vault/common/vault.hclÚrzUTF-8)Úencodingú=r   Úapi_addré   z" zvault statusZ
VAULT_ADDR)ÚenvzCould not open conf file z: )	Zadd_copy_specÚopenÚreadÚ
splitlinesÚsplitÚstripZadd_cmd_outputÚIOErrorZ
_log_error)ÚselfZ	vault_cfgÚcfileÚ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   Úpostproc/   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   