403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.55
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.7
System : Linux ip-172-31-69-123.ec2.internal 6.1.177-224.371.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 20:28:29 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/awscli/botocore/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/awscli/botocore/__pycache__/monitoring.cpython-39.pyc
a

wA�i�P�@s�ddlZddlZddlZddlZddlmZmZmZddlm	Z	m
Z
mZmZe
e	eefZ
e�e�ZGdd�d�ZGdd�d�ZGdd	�d	�ZGd
d�de�ZGdd
�d
e�ZGdd�d�ZGdd�d�ZdS)�N)�ensure_bytes�ensure_unicode�urlparse)�ConnectionClosedError�ConnectionError�EndpointConnectionError�ReadTimeoutErrorc@s,eZdZgd�Zdd�Zdd�Zdd�ZdS)	�Monitor)zbefore-parameter-buildzrequest-createdzresponse-receivedz
after-callzafter-call-errorcCs||_||_dS)z�Abstraction for monitoring clients API calls

        :param adapter: An adapter that takes event emitter events
            and produces monitor events

        :param publisher: A publisher for generated monitor events
        N)�_adapter�
_publisher)�selfZadapterZ	publisher�r
�>/usr/lib/python3.9/site-packages/awscli/botocore/monitoring.py�__init__.szMonitor.__init__cCs|jD]}|�||j�qdS)z(Register an event emitter to the monitorN)�_EVENTS_TO_REGISTERZ
register_last�capture)rZ
event_emitterZevent_to_registerr
r
r�register9s
zMonitor.registerc
Ks^z"|j�||�}|r |j�|�Wn6tyX}ztjd||dd�WYd}~n
d}~00dS)z�Captures an incoming event from the event emitter

        It will feed an event emitter event to the monitor's adaptor to create
        a monitor event and then publish that event to the monitor's publisher.
        z:Exception %s raised by client monitor in handling event %sT)�exc_infoN)r
�feedr�publish�	Exception�logger�debug)r�
event_nameZpayloadZ
monitor_event�er
r
rr>s�zMonitor.captureN)�__name__�
__module__�__qualname__rrrrr
r
r
rr	%sr	c@sreZdZejfdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�MonitorEventAdaptercCs
||_dS)z�Adapts event emitter events to produce monitor events

        :type time: callable
        :param time: A callable that produces the current time
        N)�_time)r�timer
r
rrRszMonitorEventAdapter.__init__cCs|�|�fi|��S)a�Feed an event emitter event to generate a monitor event

        :type emitter_event_name: str
        :param emitter_event_name: The name of the event emitted

        :type emitter_payload: dict
        :param emitter_payload: The payload to associated to the event
            emitted

        :rtype: BaseMonitorEvent
        :returns: A monitor event based on the event emitter events
            fired
        )�_get_handler)rZemitter_event_nameZemitter_payloadr
r
rrZszMonitorEventAdapter.feedcCs t|d|�d�d�dd��S)NZ_handle_�.r�-�_)�getattr�split�replace)rrr
r
rr!js�z MonitorEventAdapter._get_handlercKs t|jj|j|��d�|d<dS)N��service�	operation�	timestamp�current_api_call_event)�APICallEventZ
service_modelZ
service_idZ	wire_name�_get_current_time)rZmodel�context�kwargsr
r
r�_handle_before_parameter_buildos
�z2MonitorEventAdapter._handle_before_parameter_buildcKs6|j}|dj|��d�}|j|_|j|_||d<dS)Nr,)r+�current_api_call_attempt_event)r/�new_api_call_attemptr.Zheaders�request_headers�url)rZrequestr0r/Znew_attempt_eventr
r
r�_handle_request_createdvs��z+MonitorEventAdapter._handle_request_createdcKsR|�d�}|�|�|_|durH|dd|_|dd|_|�d�|_n||_|S)Nr2�ResponseMetadataZHTTPStatusCodeZHTTPHeaders�Error)�pop�_get_latency�latency�http_status_code�response_headers�get�parsed_error�wire_exception)rZparsed_responser/�	exceptionr0�
attempt_eventr
r
r�_handle_response_receiveds 
����z-MonitorEventAdapter._handle_response_receivedcKs |d�dd�|d_|�|�S)Nr7ZMaxAttemptsReachedFr,)r>�retries_exceeded�_complete_api_call)rr/�parsedr0r
r
r�_handle_after_call�s��
z&MonitorEventAdapter._handle_after_callcKs|�|�|d_|�|�S�Nr,)�_is_retryable_exceptionrDrE)rr/rAr0r
r
r�_handle_after_call_error�s
��z,MonitorEventAdapter._handle_after_call_errorcCs
t|t�S�N)�
isinstance�RETRYABLE_EXCEPTIONS)rrAr
r
rrI�sz+MonitorEventAdapter._is_retryable_exceptioncCs|�d�}|�|�|_|SrH)r9r:r;)rr/Z
call_eventr
r
rrE�s
z&MonitorEventAdapter._complete_api_callcCs|��|jSrK)r.r+�r�eventr
r
rr:�sz MonitorEventAdapter._get_latencycCst|��d�S)Ni�)�intr�rr
r
rr.�sz%MonitorEventAdapter._get_current_timeN)rrrr rrr!r1r6rCrGrJrIrEr:r.r
r
r
rrQs	
rc@s$eZdZdd�Zdd�Zdd�ZdS)�BaseMonitorEventcCs||_||_||_dS)a�Base monitor event

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began
        Nr()rr)r*r+r
r
rr�szBaseMonitorEvent.__init__cCs|jj�d|j�d�S)N�(�))�	__class__r�__dict__rQr
r
r�__repr__�szBaseMonitorEvent.__repr__cCst||j�r|j|jkSdS)NF)rLrUrV)r�otherr
r
r�__eq__�szBaseMonitorEvent.__eq__N)rrrrrWrYr
r
r
rrR�srRcs&eZdZd�fdd�	Zdd�Z�ZS)r-NFcs6t�j|||d�||_||_|dur,g|_||_dS)a�Monitor event for a single API call

        This event corresponds to a single client method call, which includes
        every HTTP requests attempt made in order to complete the client call

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began

        :type latency: int
        :param latency: The time in milliseconds to complete the client call

        :type attempts: list
        :param attempts: The list of APICallAttempts associated to the
            APICall

        :type retries_exceeded: bool
        :param retries_exceeded: True if API call exceeded retries. False
            otherwise
        r(N)�superrr;�attemptsrD)rr)r*r+r;r[rD�rUr
rr�s$�zAPICallEvent.__init__cCs"t|j|j|d�}|j�|�|S)z�Instantiates APICallAttemptEvent associated to the APICallEvent

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds to associate to the
            APICallAttemptEvent
        r()�APICallAttemptEventr)r*r[�append)rr+rBr
r
rr3�s

�z!APICallEvent.new_api_call_attempt)NNF)rrrrr3�
__classcell__r
r
r\rr-�s
�-r-cseZdZd�fdd�	Z�ZS)r]Ncs@t�j|||d�||_||_||_||_||_|	|_|
|_dS)a�Monitor event for a single API call attempt

        This event corresponds to a single HTTP request attempt in completing
        the entire client method call.

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the HTTP request
            started

        :type latency: int
        :param latency: The time in milliseconds to complete the HTTP request
            whether it succeeded or failed

        :type url: str
        :param url: The URL the attempt was sent to

        :type http_status_code: int
        :param http_status_code: The HTTP status code of the HTTP response
            if there was a response

        :type request_headers: dict
        :param request_headers: The HTTP headers sent in making the HTTP
            request

        :type response_headers: dict
        :param response_headers: The HTTP headers returned in the HTTP response
            if there was a response

        :type parsed_error: dict
        :param parsed_error: The error parsed if the service returned an
            error back

        :type wire_exception: Exception
        :param wire_exception: The exception raised in sending the HTTP
            request (i.e. ConnectionError)
        r(N)	rZrr;r5r<r4r=r?r@)rr)r*r+r;r5r<r4r=r?r@r\r
rrs9�zAPICallAttemptEvent.__init__)NNNNNNN)rrrrr_r
r
r\rr]s�r]c@seZdZdZdZdZdZdZdddd�Ze	�
d	�e	�
d
�d�Zgd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?S)@�
CSMSerializer���iZXAmznRequestIdZ
XAmzRequestIdZXAmzId2)zx-amzn-requestidzx-amz-request-idz
x-amz-id-2zSAWS4-HMAC-SHA256 Credential=(?P<access_key>\w+)/\d+/(?P<signing_region>[a-z0-9-]+)/zAWS (?P<access_key>\w+):)�v4Zs3)r)r*r+r[r;rDr5r4r<r=r?r@cCs|�|�||_dS)z�Serializes monitor events to CSM (Client Side Monitoring) format

        :type csm_client_id: str
        :param csm_client_id: The application identifier to associate
            to the serialized events
        N)�_validate_client_id�
csm_client_id�rrfr
r
rros
zCSMSerializer.__init__cCs*t|�|jkr&td|�d|j�d���dS)Nz&The value provided for csm_client_id: z exceeds the maximum length of z characters)�len�_MAX_CLIENT_ID_LENGTH�
ValueErrorrgr
r
rreys��z!CSMSerializer._validate_client_idcCsf|�|�}|�|�}||d<|jD]0}t||d�}|dur"t|d|�|||d�q"ttj|dd��S)z�Serializes a monitor event to the CSM format

        :type event: BaseMonitorEvent
        :param event: The event to serialize to bytes

        :rtype: bytes
        :returns: The CSM serialized form of the event
        �TypeNZ_serialize_)�
event_type)�,�:)Z
separators)�_get_base_event_dict�_get_event_type�_SERIALIZEABLE_EVENT_PROPERTIESr%r�json�dumps)rrO�
event_dictrl�attr�valuer
r
r�	serialize�s	


�zCSMSerializer.serializecCsd|jd�S)N�)ZVersionZClientId)rfrNr
r
rro�s�z"CSMSerializer._get_base_event_dictcKs||d<dS)NZServicer
)rr)rtr0r
r
r�_serialize_service�sz CSMSerializer._serialize_servicecKs||d<dS)NZApir
)rr*rtr0r
r
r�_serialize_operation�sz"CSMSerializer._serialize_operationcKs||d<dS)NZ	Timestampr
)rr+rtr0r
r
r�_serialize_timestamp�sz"CSMSerializer._serialize_timestampcKs$t|�|d<|r |�||d�dS)NZAttemptCount���)rh�_add_fields_from_last_attempt)rr[rtr0r
r
r�_serialize_attempts�sz!CSMSerializer._serialize_attemptscCs~|jr2|�|j�}|dur"||d<|�|j�|d<|jdurF|j|d<|jdur`|�|j|d�|jdurz|�|j|d�dS)N�Region�	UserAgentZFinalHttpStatusCode�ApiCall)r4�_get_region�_get_user_agentr<r?�_serialize_parsed_errorr@�_serialize_wire_exception)rrtZlast_attempt�regionr
r
rr}�s"�


�
�z+CSMSerializer._add_fields_from_last_attemptcCs&|dkr||d<n|dkr"||d<dS)Nr�ZLatency�ApiCallAttemptZAttemptLatencyr
)rr;rtrlr
r
r�_serialize_latency�s
z CSMSerializer._serialize_latencycKs|rdnd|d<dS)NrxrZMaxRetriesExceededr
)rrDrtr0r
r
r�_serialize_retries_exceeded�sz)CSMSerializer._serialize_retries_exceededcKst|�j|d<dS)NZFqdn)r�netloc)rr5rtr0r
r
r�_serialize_url�szCSMSerializer._serialize_urlcKsX|�|�|d<|�|�r&|�|�|d<|�|�}|dur@||d<d|vrT|d|d<dS)Nr�Z	AccessKeyrzX-Amz-Security-TokenZSessionToken)r��
_is_signed�_get_access_keyr�)rr4rtr0r�r
r
r�_serialize_request_headers�s

�z(CSMSerializer._serialize_request_headerscKs||d<dS)NZHttpStatusCoder
)rr<rtr0r
r
r�_serialize_http_status_code�sz)CSMSerializer._serialize_http_status_codecKs,|j��D]\}}||vr
||||<q
dSrK)�"_RESPONSE_HEADERS_TO_EVENT_ENTRIES�items)rr=rtr0�header�entryr
r
r�_serialize_response_headers�sz)CSMSerializer._serialize_response_headerscKsH|dkrdnd}|�|d|j�||d<|�|d|j�||d<dS)Nr��Final�ZCodeZAwsExceptionZMessageZAwsExceptionMessage)�	_truncate�_MAX_ERROR_CODE_LENGTH�_MAX_MESSAGE_LENGTH)rr?rtrlr0�field_prefixr
r
rr��s
�
�z%CSMSerializer._serialize_parsed_errorcKsH|dkrdnd}|�|jj|j�||d<|�t|�|j�||d<dS)Nr�r�r�ZSdkExceptionZSdkExceptionMessage)r�rUr�_MAX_EXCEPTION_CLASS_LENGTH�strr�)rr@rtrlr0r�r
r
rr��s
�
�z'CSMSerializer._serialize_wire_exceptioncCs t|t�rdSt|t�rdSdS)Nr�r�)rLr-r]rNr
r
rrp�s

zCSMSerializer._get_event_typecCs"|�|�}|�|�\}}|�d�S)NZ
access_key)�_get_auth_value�_get_auth_match�group)rr4�auth_valr$�
auth_matchr
r
rr�s
zCSMSerializer._get_access_keycCs<|�|�sdS|�|�}|�|�\}}|dkr2dS|�d�S)NrdZsigning_region)r�r�r�r�)rr4r��signature_versionr�r
r
rr�s

zCSMSerializer._get_regioncCs|�t|�dd��|j�S)Nz
User-Agentr�)r�rr>�_MAX_USER_AGENT_LENGTH�rr4r
r
rr�s�zCSMSerializer._get_user_agentcCsd|vS�NZ
Authorizationr
r�r
r
rr�szCSMSerializer._is_signedcCst|d�Sr�)rr�r
r
rr�szCSMSerializer._get_auth_valuecCs2|j��D]"\}}|�|�}|r
||fSq
dS)N)NN)�_AUTH_REGEXSr��match)rr�r�Zregexr�r
r
rr�s

zCSMSerializer._get_auth_matchcCs*t|�|kr&t�d||�|d|�S|S)Nz6Truncating following value to maximum length of %s: %s)rhrr)r�textZ
max_lengthr
r
rr�"s�zCSMSerializer._truncateN)&rrrrir�r�r�r�r��re�compiler�rqrrerwroryrzr{r~r}r�r�r�r�r�r�r�r�rpr�r�r�r�r�r�r�r
r
r
rr`MsP���
	r`c@s eZdZdZdd�Zdd�ZdS)�SocketPublisheri cCs||_||f|_||_dS)a)Publishes monitor events to a socket

        :type socket: socket.socket
        :param socket: The socket object to use to publish events

        :type host: string
        :param host: The host to send events to

        :type port: integer
        :param port: The port on the host to send events to

        :param serializer: The serializer to use to serialize the event
            to a form that can be published to the socket. This must
            have a `serialize()` method that accepts a monitor event
            and return bytes
        N)�_socket�_address�_serializer)rZsocket�host�portZ
serializerr
r
rr0s
zSocketPublisher.__init__cCsF|j�|�}t|�|jkr2t�dt|�|j�dS|j�||j�dS)z�Publishes a specified monitor event

        :type event: BaseMonitorEvent
        :param event: The monitor event to be sent
            over the publisher's socket to the desired address.
        z`Serialized event of size %s exceeds the maximum length allowed: %s. Not sending event to socket.N)	r�rwrh�_MAX_MONITOR_EVENT_LENGTHrrr�Zsendtor�)rrOZserialized_eventr
r
rrEs�zSocketPublisher.publishN)rrrr�rrr
r
r
rr�-sr�)rrZloggingr�r Zbotocore.compatrrrZbotocore.exceptionsrrrrrMZ	getLoggerrrr	rrRr-r]r`r�r
r
r
r�<module>
s&�
,^<Fa

Youez - 2016 - github.com/yon3zu
LinuXploit