o
    O6ufú  ã                   @   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)ÚsysmgmtÚsecurity)r   c              
   C   sÖ   d}|   |¡ zEt|ddd��3}| ¡  ¡ D ]"}|sq| d¡}|d  ¡ dkr8|d  d	¡}| jd
d|id� qW d   ƒ W d S 1 sEw   Y  W d S  tyj } z|  d|› d|› �¡ W Y d }~d S d }~ww )Nú /var/snap/vault/common/vault.hclÚrzUTF-8)Úencodingú=r   Úapi_addré   z" zvault statusÚ
VAULT_ADDR)ÚenvzCould not open conf file z: )	Úadd_copy_specÚopenÚreadÚ
splitlinesÚsplitÚstripÚadd_cmd_outputÚIOErrorÚ
_log_error)ÚselfÚ	vault_cfgÚcfileÚlineÚ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******)Údo_file_sub)r   r   r   r    Úpostproc/   s
   ýzVault.postprocN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚservicesÚpackager!   r#   r   r   r   r    r      s    r   N)Úsos.report.pluginsr   r   r   r   r   r   r    Ú<module>   s   
