403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_kms.cpython-310.pyc
o

;j*E�	@s�dZddlZddlmZddlZddlZddlZe�e	�Z
zddlZddlZe�d��
ej�dZWn
eefy?dZYnwdd�Zd	d
�Z	d9dd�Z								d:d
d�Z							d;dd�Z						d<dd�Zd9dd�Zd9dd�Zd9dd�Zd9dd�Zd9dd�Zd9dd�Zd9dd �Z						d<d!d"�Z								d:d#d$�Z 								d:d%d&�Z!	d=d'd(�Z"	d9d)d*�Z#d9d+d,�Z$	d<d-d.�Z%	d<d/d0�Z&	d9d1d2�Z'							d;d3d4�Z(d9d5d6�Z)	d9d7d8�Z*dS)>ar
Connection module for Amazon KMS

.. versionadded:: 2015.8.0

:configuration: This module accepts explicit kms credentials but can also utilize
    IAM roles assigned to the instance through Instance Profiles. Dynamic
    credentials are then automatically obtained from AWS API and no further
    configuration is necessary. More Information available at::

       http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

    If IAM roles are not used you need to specify them either in a pillar or
    in the minion's config file::

        kms.keyid: GKTADJGHEIQSXMKKRBJ08H
        kms.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    A region may also be specified in the configuration::

        kms.region: us-east-1

    If a region is not specified, the default is us-east-1.

    It's also possible to specify key, keyid and region via a profile, either
    as a passed in dict, or as a string to pull from pillars or minion config:

        myprofile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            region: us-east-1

:depends: boto
�N)�OrderedDict�botoTFcCstjjjddd�S)z,
    Only load if boto libraries exist.
    z2.38.0F)Zboto_verZcheck_boto3)�salt�utilsZversionsZcheck_boto_reqs�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_kms.py�__virtual__=srcCstr
tdtdtd�dSdS)Nzboto.assign_funcs�kms)�pack)�HAS_BOTO�	__utils__�__name__Z__salt__)�optsrrr�__init__Ds�rc	
C�rt||||d�}i}z
|�||�d|d<W|Stjjy8}zd|d<td|�|d<WYd}~|Sd}~ww)z�
    Create a display name for a key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.create_alias 'alias/mykey' key_id
    ��region�key�keyid�profileT�resultF�boto.get_error�errorN)�	_get_conn�create_aliasr�	exception�BotoServerErrorr)	Z
alias_nameZ
target_key_idrrrr�conn�r�errrrI�
���rc


Cs�t||||	d�}
|�d�rt|�}i}z|
j||||||d�|d<W|Stjjy@}ztd|�|d<WYd}~|Sd}~ww)a
    Adds a grant to a key to specify who can access the key and under what
    conditions.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.create_grant 'alias/mykey' 'arn:aws:iam::1111111:/role/myrole' operations='["Encrypt","Decrypt"]'
    r�alias/)�retiring_principal�
operations�constraints�grant_tokens�grantrrN)r�
startswith�_get_key_id�create_grantrrrr)
�key_idZgrantee_principalr"r#r$r%rrrrrrrrrrr)as&
�
���r)c
Cs�t||||d�}i}tjj�|�}	z|j|	||d�}
|
d|d<W|Stjjy?}zt	d|�|d<WYd}~|Sd}~ww)z�
    Creates a master key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
    r)�description�	key_usage�KeyMetadata�key_metadatarrN)
rr�serializers�json�	serialize�
create_keyrrrr)�policyr+r,rrrrrrZ_policyr.rrrrr2�s����r2c
Csrt||||d�}i}z|j|||d�}	|	d|d<W|Stjjy8}
ztd|
�|d<WYd}
~
|Sd}
~
ww)z�
    Decrypt ciphertext.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.decrypt encrypted_ciphertext
    r��encryption_contextr%�	Plaintext�	plaintextrrN)r�decryptrrrr)�ciphertext_blobr5r%rrrrrrr7rrrrr8�s����r8c
Cs�t||||d�}i}z|�|�}d|d<W|StjjyG}z#t|tjjj�r4d|d<|WYd}~St	d|�|d<WYd}~|Sd}~ww)z�
    Check for the existence of a key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.key_exists 'alias/mykey'
    rTrFNrr)
r�describe_keyrrr�
isinstancer	�
exceptionsZNotFoundExceptionr�r*rrrrrrrrrr�
key_exists�s


���r>cCst|||||�d}|dS)z&
    From an alias, get a key_id.
    r.ZKeyId)r:)�aliasrrrrr.rrrr(�sr(c
Cslt||||d�}i}z|�|�}|d|d<W|Stjjy5}ztd|�|d<WYd}~|Sd}~ww)z�
    Get detailed information about a key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.describe_key 'alias/mykey'
    rr-r.rrN)rr:rrrrr=rrrr:�s

���r:c
C�pt||||d�}i}z|�|�}d|d<W|Stjjy7}zd|d<td|�|d<WYd}~|Sd}~ww)z�
    Mark key as disabled.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.disable_key 'alias/mykey'
    rTrFrrN)r�disable_keyrrrrr=rrrrA�


���rAc
Cr@)z�
    Disable key rotation for specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.disable_key_rotation 'alias/mykey'
    rTrFrrN)r�disable_key_rotationrrrrr=rrrrCrBrCc
Cr@)z�
    Mark key as enabled.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.enable_key 'alias/mykey'
    rTrFrrN)r�
enable_keyrrrrr=rrrrD.rBrDc
Cr@)z�
    Disable key rotation for specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.enable_key_rotation 'alias/mykey'
    rTrFrrN)r�enable_key_rotationrrrrr=rrrrEDrBrEc
Cstt||||d�}i}	z|j||||d�}
|
d|	d<W|	Stjjy9}ztd|�|	d<WYd}~|	Sd}~ww)z�
    Encrypt plaintext into cipher text using specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}'
    rr4ZCiphertextBlob�
ciphertextrrN)r�encryptrrrr)r*r7r5r%rrrrrrrFrrrrrGZs ����rGc	

C�rt||||d�}	i}
z|	j|||||d�}||
d<W|
Stjjy8}ztd|�|
d<WYd}~|
Sd}~ww)z�
    Generate a secure data key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.generate_data_key 'alias/mykey' number_of_bytes=1024 key_spec=AES_128
    r�r5�number_of_bytes�key_specr%�data_keyrrN)r�generate_data_keyrrrr�
r*r5rJrKr%rrrrrrrLrrrrrM}�"�
���rMc	

CrH)z�
    Generate a secure data key without a plaintext copy of the key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.generate_data_key_without_plaintext 'alias/mykey' number_of_bytes=1024 key_spec=AES_128
    rrIrLrrN)r�#generate_data_key_without_plaintextrrrrrNrrrrP�rOrPc	
C�lt||||d�}i}z|�|�}|d|d<W|Stjjy5}ztd|�|d<WYd}~|Sd}~ww)z�
    Generate a random string.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.generate_random number_of_bytes=1024
    rr6�randomrrN)r�generate_randomrrrr)	rJrrrrrrrRrrrrrS�s
���rSc

Cs|t||||d�}i}z|�||�}tjjj|dtd�|d<W|Stjj	y=}	zt
d|	�|d<WYd}	~	|Sd}	~	ww)z�
    Get the policy for the specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy
    r�Policy)�object_pairs_hook�
key_policyrrN)r�get_key_policyrr/r0Zdeserializerrrrr)
r*�policy_namerrrrrrrVrrrrrW�s����rWc	
CrQ)z�
    Get status of whether or not key rotation is enabled for a key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.get_key_rotation_status 'alias/mykey'
    rZKeyRotationEnabledrrrN)r�get_key_rotation_statusrrrr)	r*rrrrrrZkey_rotation_statusrrrrrY�s

���rYc
Cs�t||||d�}|�d�rt|�}i}z+g}	d}
	|j|||
d�}|dD]}|	�|�q%d|vr6|d}
nnq|	|d<W|Stjjy[}
ztd	|
�|d
<WYd}
~
|Sd}
~
ww)z�
    List grants for the specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.list_grants 'alias/mykey'
    rr!NT��limit�markerZGrantsZ
NextMarker�grantsrr)	rr'r(�list_grants�appendrrrr)r*r[r\rrrrrrZ_grantsZnext_markerr]r&rrrrr^s,

�
���r^c
Cs�t||||d�}|�d�rt|�}i}z|j|||d�}	|	d|d<W|StjjyA}
ztd|
�|d<WYd}
~
|Sd}
~
ww)	z�
    List key_policies for the specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.list_key_policies 'alias/mykey'
    rr!rZZPolicyNames�key_policiesrrN)rr'r(�list_key_policiesrrrr)r*r[r\rrrrrrr`rrrrra.s
���rac

Cs~t||||d�}i}z|�||tjj�|��d|d<W|Stjjy>}	zd|d<t	d|	�|d<WYd}	~	|Sd}	~	ww)z�
    Attach a key policy to the specified key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
    rTrFrrN)
r�put_key_policyrr/r0r1rrrr)
r*rXr3rrrrrrrrrrrbHs�
���rbc	

Cspt||||d�}	i}
z|	�|||||�}||
d<W|
Stjjy7}ztd|�|
d<WYd}~|
Sd}~ww)z�
    Reencrypt encrypted data with a new master key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.re_encrypt 'encrypted_data' 'alias/mynewkey' default '{"Statement":...}'
    rrFrrN)r�
re_encryptrrrr)
r9Zdestination_key_idZsource_encryption_contextZdestination_encryption_contextr%rrrrrrrFrrrrrcbs"�
���rcc	
Cs�t||||d�}|�d�rt|�}i}z
|�||�d|d<W|StjjyA}zd|d<td|�|d<WYd}~|Sd}~ww)	z�
    Revoke a grant from a key.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j...
    rr!TrFrrN)rr'r(�revoke_grantrrrr)	r*Zgrant_idrrrrrrrrrrrd�s


���rdc	
Cr)z�
    Update a key's description.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_kms.update_key_description 'alias/mykey' 'My key'
    rTrFrrN)r�update_key_descriptionrrrr)	r*r+rrrrrrrrrrre�r re)NNNN)NNNNNNNN)NNNNNNN)NNNNNN)NNNNN)+�__doc__�logging�collectionsrZsalt.serializers.jsonrZsalt.utils.compatZsalt.utils.versions�	getLoggerr
�logrZboto.kms�setLevel�CRITICALr�ImportError�AttributeErrorrrrr)r2r8r>r(r:rArCrDrErGrMrPrSrWrYr^rarbrcrdrerrrr�<module>s�'
�
�
�*
�"
�
!






�%
�'
�&
�
�

�#
�
�
�
%�

Youez - 2016 - github.com/yon3zu
LinuXploit