CasperSecurity

Current Path : /lib/python3/dist-packages/uaclient/clouds/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/uaclient/clouds/__pycache__/gcp.cpython-310.pyc

o

��Jh(�@s�ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
mZmZm
Z
mZddlmZe�e�e��ZdZdZdZdZd	Zd
Zdgdd
gddgddgddgd�ZGdd�de�ZdS)�N)�Any�Dict�List�Optional)�
exceptions�http�secret_manager�system�util)�PublicCloudAutoAttachInstancez�http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=contracts.canonical.com&format=full&licenses=TRUEzThttp://metadata.google.internal/computeMetadata/v1/instance/licenses/?recursive=truez&wait_for_change=truez&last_etag={etag}z/sys/class/dmi/id/product_namezGoogle Compute Engine�8045211386737108299�6022427724719891830�7427070211152946628�599959289349842382�7818678586103571931�2592866803419978320�160084055690847662�2176054482269786025�4168323874790319525)�xenial�bionic�focal�jammy�noblec@s�eZdZdd�Zeejejgd�d�de	e
effdd���Zede
fdd	��Z
edefd
d��Zdee
fdd
�Zdefdd�Zdedefdd�ZdS)�GCPAutoAttachInstancecCs
d|_dS)N��etag��self�r�5/usr/lib/python3/dist-packages/uaclient/clouds/gcp.py�__init__%s
zGCPAutoAttachInstance.__init__)g�?�r")�retry_sleeps�returncCsttjtddidd�}|jdkrtj�|j�d|jiS|j�	d�}|r1d|�
�vr1tj|j|d	��tj
|j|jd
��)N�Metadata-Flavor�Googler")�headers�timeout���
identityToken�error_descriptionzservice account)�status_code�	error_msg)�code�body)r�readurl�	TOKEN_URLr.r�secrets�
add_secretr/�	json_dict�get�lowerr�GCPServiceAccountError�CloudMetadataError)r�response�
error_descrrr �identity_doc,s
�

��z"GCPAutoAttachInstance.identity_doccCsdS)N�gcprrrrr �
cloud_type?sz GCPAutoAttachInstance.cloud_typecCs*tj�t�rt�t�}t|��krdSdS)z$This machine is a viable GCPInstanceTF)�os�path�exists�DMI_PRODUCT_NAMEr	�	load_file�GCP_PRODUCT_NAME�strip)r�product_namerrr �	is_viableCs

zGCPAutoAttachInstance.is_viablecCsN|jd}t�|�d�dd�}t�|�d��}|�di��di��dg�S)	z�Get a list of licenses from the GCP metadata.

        Instance identity token (jwt) carries a list of licenses
        associated with the instance itself.

        Returns an empty list if licenses are not present in the metadata.
        r*�.r"z===zutf-8�google�compute_engine�
license_id)r;�base64�urlsafe_b64decode�split�json�loads�decoder5)r�token�identity�
identity_dictrrr �get_licenses_from_identityMs

�z0GCPAutoAttachInstance.get_licenses_from_identitycCs$t��j}|tvrt�d�dSdS)Nz0This series isn't supported for GCP auto-attach.FT)r	�get_release_info�series�GCP_LICENSES�LOG�info)rrVrrr �should_poll_for_pro_license^s


z1GCPAutoAttachInstance.should_poll_for_pro_license�wait_for_changecCs�t}|r|t7}|jr|tj|jd�7}tj|ddid�}|jdkrHdd�|jD�}|j	�
d�|_t��j
}t�
|g�D]	}||vrEd	Sq<d
St�|j�|jdkrWt���t���)Nrr%r&)r'r)cSsg|]}|d�qS)�idr)�.0�licenserrr �
<listcomp>osz@GCPAutoAttachInstance.is_pro_license_present.<locals>.<listcomp>rTFi�)�LICENSES_URL�WAIT_FOR_CHANGEr�	LAST_ETAG�formatrr0r.�	json_listr'r5r	rUrVrWrX�errorr/r�CancelProLicensePolling�DelayProLicensePolling)rr[�urlr9�license_idsrV�licrrr �is_pro_license_presentes&

�
z,GCPAutoAttachInstance.is_pro_license_presentN)�__name__�
__module__�__qualname__r!�propertyr
�retryrr8r�strrr;r=�boolrFrrTrZrkrrrr r$s	r)rKrN�loggingr>�typingrrrr�uaclientrrrr	r
�uaclient.cloudsr�	getLogger�replace_top_level_logger_namerlrXr1r`rarbrArCrWrrrrr �<module>s.���	
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY