0x1949 Team - FAZEMRX - MANAGER
Edit File: aws.cpython-310.pyc
o �ϴf� � @ s� d dl Z d dlmZmZ d dlmZmZmZmZm Z d dl mZ dZdZ ee fZdZdZd Zd ZdZdZd Zed Ze �e �e��ZG dd� de�ZdS )� N)�Any�Dict)� exceptions�http�secret_manager�system�util)�AutoAttachCloudInstancez169.254.169.254z[fd00:ec2::254]zhttp://{}/latest/api/tokenz0http://{}/latest/dynamic/instance-identity/pkcs7z/sys/hypervisor/uuidz /sys/class/dmi/id/product_serialz/sys/class/dmi/id/product_uuid�21600zX-aws-ec2-metadata-tokenz-ttl-secondsc @ s� e Zd ZdZdZdd� Zeeje j g d�d�deee f fdd���Zd d � Zeje j g d�d�dd � �Zedefdd��Zedefdd��Zdefdd�Zdedefdd�ZdS )�UAAutoAttachAWSInstanceNc C sB | � � }tjt�| j�|dd�}|jdkr|jS tj |j|jd��)N� )�headers�timeout�� ��code�body) �_request_imds_v2_token_headersr �readurl�IMDS_URL�format�_ip_addressr r r �CloudMetadataError)�selfr �response� r �5/usr/lib/python3/dist-packages/uaclient/clouds/aws.py�_get_imds_url_response s � �z.UAAutoAttachAWSInstance._get_imds_url_response)g �?r r )�retry_sleeps�returnc C s | � � }tj�|� d|iS )N�pkcs7)r r �secrets� add_secret)r �imds_url_responser r r �identity_doc+ s z$UAAutoAttachAWSInstance.identity_docc C s| t D ]+}z| j|d�}W n ty) } zt�d|t|dd�� W Y d }~qd }~ww || _ | jd u r<tjd� t �d��|S )N)� ip_addressz*Could not reach AWS IMDS at http://%s: %s �reason� z, )� addresses) �IMDS_IP_ADDRESS�_get_imds_v2_token_headers� Exception�LOG�warning�getattrr r �AWSNoValidIMDS�join)r �addressr �er r r r 2 s$ ��� �z6UAAutoAttachAWSInstance._request_imds_v2_token_headers)r � � c C s� | j dkrd S | j rt| j iS tjt�|�dttidd�}|jdkr2|j | _ t j�| j � t| j iS |jdkr<d| _ d S t j|j|j d��)N�IMDSv1�PUTr )�methodr r r i� r )� _api_token�AWS_TOKEN_PUT_HEADERr r �IMDS_V2_TOKEN_URLr �AWS_TOKEN_REQ_HEADER�AWS_TOKEN_TTL_SECONDSr r r r! r"