Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sos/report/plugins/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/gcp.cpython-310.pyc
o

i��d��@sbddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZGdd�de
e�Z
dS)	�N)�HTTPResponse)�Any)�request)�URLError)�Plugin�IndependentPlugin�	PluginOptc@s�eZdZdZdZdZedddd�gZdZd	Z	d
Z
dZdd
�Zdd�Z
dd�Zdefdd�Zededefdd��Zdd�Zededefdd��ZdS)�GCPzGoogle Cloud Platform�gcp)�virt�keep-piiFzyStop the plugin from removing PIIs like project name or organization ID from the metadata retrieved from Metadata server.)�default�descz3http://metadata.google.internal/computeMetadata/v1/zBhttp://metadata.google.internal/computeMetadata/v1/?recursive=truez[--REDACTED--]zDDMI: Google Google Compute Engine/Google Compute Engine, BIOS GooglecCs(|�d�}|ddkr
dS|j|dvS)z�
        Checks if this plugin should be executed at all. In this case, it
        will check the `dmesg` command output to see if the system is
        running on a Google Cloud Compute instance.
        �dmesg�statusrF�output)�exec_cmd�
GOOGLE_DMI)�selfr�r�8/usr/lib/python3/dist-packages/sos/report/plugins/gcp.py�
check_enabled(s
zGCP.check_enabledcCs$|jddgd�|jddgd�dS)z�
        Collect the following info:
         * Metadata from the Metadata server
         * `gcloud auth list` output
         * Any google services output from journal
        zgcloud auth listr
��tagszgoogle*)�unitsrN)�add_cmd_output�add_journal�rrrr�setup3s	z	GCP.setupcCs�|jddgd��A}z|��|_|��|�tj|jdd��Wnty8}z
|�t|��WYd}~n
d}~wwWd�dSWd�dS1sLwYdS)Nz
metadata.jsonr
r�)�indent)	�collection_file�get_metadata�metadata�scrub_metadata�write�json�dumps�RuntimeError�str)r�mfile�errrrr�collectAs
����"�zGCP.collect�returncCs"|�|j�}|����}t�|�S)zq
        Retrieves metadata from the Metadata Server and transforms it into a
        dictionary object.
        )�_query_address�METADATA_QUERY�read�decoder&�loads)r�response�
response_bodyrrrr"Ks
zGCP.get_metadata�urlc
Csvztj|ddid�}t�|�}Wnty$}ztdt|���d}~ww|jdkr9td|j�d�|������|S)	zf
        Query the given url address with headers required by Google Metadata
        Server.
        zMetadata-Flavor�Google)�headersz,Failed to communicate with Metadata Server: N��z2Failed to communicate with Metadata Server (code: z): )	r�Request�urlopenrr(r)�coder0r1)r5�reqr3r+rrrr.Ts$
���
�
��zGCP._query_addresscs���d�rdS�jdd��jdd�t���dtdtf�����fdd	����j��_���jdd
d����jdd
d�dS)
a"
        Remove all PII information from metadata, unless a keep-pii option
        is specified.

        Note: PII information collected by this plugin, like
        project number, account names etc. might be required by Google
        Cloud Support for faster issue resolution.
        rN�project�	projectId�numericProjectId�datar-cs�t|t�rd|vr�j|d<�fdd�|��D�St|t�r'�fdd�|D�St|t�r8|���j����j�St|t�rF|�krD�jS|S|S)N�tokencsi|]\}}�|��|��qSrr)�.0�k�v��scrubrr�
<dictcomp>|sz5GCP.scrub_metadata.<locals>.scrub.<locals>.<dictcomp>csg|]}�|��qSrr)rB�valuerErr�
<listcomp>~sz5GCP.scrub_metadata.<locals>.scrub.<locals>.<listcomp>)�
isinstance�dict�REDACTED�items�listr)�replace�int)r@��
project_id�project_number�project_number_intrFrrrrFvs




�
z!GCP.scrub_metadata.<locals>.scrub�
attributeszssh-keys�sshKeys)�
get_optionr#r)r�safe_redact_keyrrrQrr$fs
	��zGCP.scrub_metadata�dict_obj�keycCs||vr|j||<dSdS)N)rL)�clsrYrZrrrrX�s�zGCP.safe_redact_keyN)�__name__�
__module__�__qualname__�
short_desc�plugin_name�profilesr�option_list�
METADATA_ROOTr/rLrrrr,rKr"�staticmethodr)rr.r$�classmethodrXrrrrr	s*��
	'r	)r&�http.clientr�typingr�urllibr�urllib.errorr�sos.report.pluginsrrrr	rrrr�<module>s

Spamworldpro Mini