HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/__pycache__/codecommit.cpython-36.pyc
3

�T_?�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZejd�Zdd	�Zd
d�ZGdd
�d
e
�ZGdd�de
�ZGdd�de
�ZGdd�de
�ZdS)�N)�	SigV4Auth)�
AWSRequest)�urlsplit)�BasicCommand)�NonTranslatedStdoutzbotocore.credentialscCs|jdt�dS)z3
    The entry point for the credential helper
    z!building-command-table.codecommitN)�register�inject_commands)Zcli�r	� /usr/lib/python3.6/codecommit.py�
initializesrcKst|�|d<dS)z>
    Injects new commands into the codecommit subcommand.
    zcredential-helperN)�CodeCommitCommand)Z
command_table�session�kwargsr	r	r
r%src@s(eZdZdZdZdZdZdZdd�ZdS)	�CodeCommitNoOpStoreCommand�storezAThis operation does nothing, credentials are calculated each timez&aws codecommit credential-helper store�TcCsdS)Nrr	)�self�args�parsed_globalsr	r	r
�	_run_main4sz$CodeCommitNoOpStoreCommand._run_mainN)	�__name__�
__module__�__qualname__�NAME�DESCRIPTION�SYNOPSIS�EXAMPLES�
_UNDOCUMENTEDrr	r	r	r
r,src@s(eZdZdZdZdZdZdZdd�ZdS)	�CodeCommitNoOpEraseCommand�erasez;This operation does nothing, no credentials are ever storedz&aws codecommit credential-helper eraserTcCsdS)Nrr	)rrrr	r	r
r@sz$CodeCommitNoOpEraseCommand._run_mainN)	rrrrrrrrrr	r	r	r
r8srcsneZdZdZdZdZdZdddddd	�gZ�fd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Z�ZS)�CodeCommitGetCommand�getz�get a username SigV4 credential pair based on protocol, host and path provided from standard in. This is primarily called by git to generate credentials to authenticate against AWS CodeCommitz$aws codecommit credential-helper getz�echo -e "protocol=https\\npath=/v1/repos/myrepo\\nhost=git-codecommit.us-east-1.amazonaws.com" | aws codecommit credential-helper getzignore-host-check�
store_trueFzTOptional. Generate credentials regardless of whether the domain is an Amazon domain.)�name�action�defaultZ
group_nameZ	help_textcstt|�j|�dS)N)�superr �__init__)rr
)�	__class__r	r
r']szCodeCommitGetCommand.__init__cCsV|j�}d|dks&d|dks&|jrR|j|�}|j||�}|j||�}|j|�dS)Nz
amazon.com�hostz
amazonaws.comr)�read_git_parametersZignore_host_check�extract_url�extract_region�sign_request�write_git_parameters)rrrZgit_parametersZtheUrl�region�	signaturer	r	r
r`s

zCodeCommitGetCommand._run_mainc
Cs�|jj�j}|jj�jdk	r0|d|jj�j7}t��F}|jdj|��tjd|�|jdj|��|j	�tjd|�WdQRXdS)N�%z
username={0}
zusername
%sz
password={0}
zsignature
%s)
�_session�get_credentialsZ
access_key�tokenr�write�format�logger�debug�flush)rr0ZusernameZ
binary_stdoutr	r	r
r.ksz)CodeCommitGetCommand.write_git_parameterscCs<i}x2tjD](}|j�}|r|jdd�\}}|||<qW|S)N�=�)�sys�stdin�strip�split)rZparsed�line�key�valuer	r	r
r*zsz(CodeCommitGetCommand.read_git_parameterscCsdj|d|d|d�}|S)Nz
{0}://{1}/{2}Zprotocolr)�path)r6)r�
parameters�urlr	r	r
r+�s

z CodeCommitGetCommand.extract_urlcCsBtjd|d�}|dk	r"|jd�S|jdk	r2|jS|jjd�SdS)NzD(vpce-.+\.)?git-codecommit(-fips)?\.([^.]+)\.(vpce\.)?amazonaws\.comr)�r/)�re�match�groupr/r2Zget_config_variable)rrDrrHr	r	r
r,�s


z#CodeCommitGetCommand.extract_regioncCs�|jj�}t|d|�}t�}||_d|_tjj�}|jd�|j	d<t
|j�}|jjd�d}dj
|j|j|�}	tjd�tjd	|	�|j||	�}
tjd
|
�|j|
|�}tjd|�dj
|j	d|�S)
NZ
codecommitZGITz
%Y%m%dT%H%M%SZ	timestamp�:rz{0}
{1}

host:{2}

host
z$Calculating signature using v4 auth.zCanonicalRequest:
%szStringToSign:
%sz
Signature:
%sz{0}Z{1})r2r3rrrE�method�datetimeZutcnowZstrftime�contextrZnetlocr?r6rCr7r8�string_to_signr0)rr/Zurl_to_signZcredentialsZsignerZrequestZnowr?ZhostnameZcanonical_requestrNr0r	r	r
r-�s(



z!CodeCommitGetCommand.sign_request)rrrrrrrZ	ARG_TABLEr'rr.r*r+r,r-�
__classcell__r	r	)r(r
r Ds 
	
r c@s@eZdZdZdZdZded�ded�ded�gZ	dZ
d	d
�ZdS)rzcredential-helperz aws codecommit credential-helperrr!)r#Z
command_classrra#Provide a SigV4 compatible user name and password for git smart HTTP  These commands are consumed by git and should not used directly. Erase and Store are no-ops. Get is operation to generate credentials to authenticate AWS CodeCommit. Run "aws codecommit credential-helper help" for detailscCstd��dS)Nziusage: aws [options] codecommit credential-helper <subcommand> [parameters]
aws: error: too few arguments)�
ValueError)rrrr	r	r
r�szCodeCommitCommand._run_mainN)rrrrrrr rrZSUBCOMMANDSrrr	r	r	r
r�s	r)�osrGr<ZloggingZ	fileinputrLZ
botocore.authrZbotocore.awsrequestrZbotocore.compatrZawscli.customizations.commandsrZ
awscli.compatrZ	getLoggerr7rrrrr rr	r	r	r
�<module>s"
g