AnonSec Shell
Server IP : 208.109.241.143  /  Your IP : 3.144.28.245
Web Server : Apache
System : Linux 143.241.109.208.host.secureserver.net 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
User : internationaljou ( 1003)
PHP Version : 8.1.30
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/var/opt/nydus/ops/mysql/connector/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /proc/self/root/var/opt/nydus/ops/mysql/connector/__pycache__/utils.cpython-38.pyc
U

;�g9\�@s�UdZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&dd	l'm(Z(m)Z)dd
l*m+Z+dZ,e-e.d<e/e0e
e&fZ1e"e#e/e#e0e#e
e#e&fe.d
<e$e/e2fe/d�dd�Z3e/e2d�dd�Z4e/e2d�dd�Z5e/e2d�dd�Z6e/e2d�dd�Z7e/e2d�dd�Z8e/e2d�dd�Z9e/e2d�dd�Z:e2e/e"e2e2fd �d!d"�Z;e2e"e2e!e2fd�d#d$�Z<e2e!e"e!e2d%fd�d&d'�Z=d[e2e!e2e!e/e"e2e2fd(�d)d*�Z>e2e/e"e2e/fd �d+d,�Z?e2e"e2e!e/fd�d-d.�Z@e+eAd�d/d0�ZBd\e+e!eAe/dd2�d3d4�ZCeeAeAfd5�d6d7�ZDeeAeAfd5�d8d9�ZEe!eeAeAfd5�d:d;�ZFe"eAeAeAfd5�d<d=�ZGeAeAd>�d?d@�ZHeAeeAeeAge-ffd>�dAdB�ZIeAe!e"eAeAfdC�dDdE�ZJeAeAdF�dGdH�ZKd]e$e/e+feAeLdK�dLdM�ZMe�eeAe$eAe"eAeAfffd5�dNdO��ZNeAedP�dQdR�ZOeAeAddS�dTdU�ZPeAddV�dWdX�ZQGdYdZ�dZ�ZRdS)^z
Utilities.�N)�Decimal)�	lru_cache)�in_table_a1�in_table_b1�in_table_c3�in_table_c4�in_table_c5�in_table_c6�in_table_c7�in_table_c8�in_table_c9�in_table_c11�in_table_c12�in_table_c21_c22�in_table_d1�in_table_d2)�Any�Callable�Dict�List�Optional�Tuple�Type�Union�)�
HexLiteral)�DEPRECATED_TLS_CIPHERSUITES�DEPRECATED_TLS_VERSIONS)�
StrOrBytesF�__MYSQL_DEBUG__�
NUMERIC_TYPES)�buf�returncCs�t|t�r|St|�t�}}|dkr.|dS|dkr^||dd|7}tt�d|�d�S||dd|7}tt�d|�d�S)z&Unpacks the given buffer to an integerrr���<I��<Q)�
isinstance�int�len�	bytearray�struct�unpack)r!�length�tmp�r0�H/opt/nydus/tmp/pip-target-d6ig7x5r/lib64/python/mysql/connector/utils.py�intreadJs
r2)�ir"cCs$|dks|dkrtd��t�d|�S)z^
    Takes an unsigned byte (1 byte) and packs it as a bytes-object.

    Returns string.
    r�z int1store requires 0 <= i <= 255�<B��
ValueErrorr,�pack�r3r0r0r1�	int1storeXsr:cCs$|dks|dkrtd��t�d|�S)z`
    Takes an unsigned short (2 bytes) and packs it as a bytes-object.

    Returns string.
    r�z"int2store requires 0 <= i <= 65535�<Hr6r9r0r0r1�	int2storecsr=cCs,|dks|dkrtd��t�d|�dd�S)zb
    Takes an unsigned integer (3 bytes) and packs it as a bytes-object.

    Returns string.
    r��z%int3store requires 0 <= i <= 16777215r%�r6r9r0r0r1�	int3storensr@cCs$|dks|dkrtd��t�d|�S)zb
    Takes an unsigned integer (4 bytes) and packs it as a bytes-object.

    Returns string.
    r���z'int4store requires 0 <= i <= 4294967295r%r6r9r0r0r1�	int4storeysrBcCs$|dks|dkrtd��t�d|�S)zZ
    Takes an unsigned integer (8 bytes) and packs it as string.

    Returns string.
    r�z!int8store requires 0 <= i <= 2^64r'r6r9r0r0r1�	int8store�srDcCs\|dks|dkrtd��|dkr&t}n.|dkr4t}n |dkrBt}n|dkrPt}nt}||�S)z�
    Takes an unsigned integers and packs it as a bytes-object.

    This function uses int1store, int2store, int3store,
    int4store or int8store depending on the integer value.

    returns string.
    rrCz!intstore requires 0 <= i <=  2^64r4r;r>rA)r7r:r=r@rBrD)r3Z
formed_stringr0r0r1�intstore�s	rEcCst|dks|dkrtd��|dkr,t�d|�S|dkrDdt�d|�S|d	krdd
t�d|�dd�Sd
t�d|�S)z|
    Takes an unsigned integer and packs it as bytes,
    with the information of how much bytes the encoded int takes.
    rrCzRequires 0 <= i <= 2^64�r5r;��r<r>��r%r?��r'r6r9r0r0r1�lc_int�srJ)r!�sizer"cCs|d|�}||d�|fS)zi
    Reads bytes from a buffer.

    Returns a tuple with buffer less the read bytes, and the bytes.
    rNr0�r!rK�resr0r0r1�
read_bytes�srNcCs�|ddkr|dd�dfSd}}|d}|dkrX|}|d|d�|d|d�fS|dkrfd}n|dkrtd	}n|d
kr�d}t|d|d��}|||dd�||d||d�fS)u�
    Takes a buffer and reads a length coded string from the start.

    This is how Length coded strings work

    If the string is 250 bytes long or smaller, then it looks like this:

      <-- 1b  -->
      +----------+-------------------------
      |  length  | a string goes here
      +----------+-------------------------

    If the string is bigger than 250, then it looks like this:

      <- 1b -><- 2/3/8 ->
      +------+-----------+-------------------------
      | type |  length   | a string goes here
      +------+-----------+-------------------------

      if type == ü:
          length is code in next 2 bytes
      elif type == ý:
          length is code in next 3 bytes
      elif type == þ:
          length is code in next 8 bytes

    NULL has a special value. If the buffer starts with û then
    it's a NULL and we return None as value.

    Returns a tuple (trucated buffer, bytes).
    rrFrN����r?�r&�r2)r!r.�lsizeZfstr0r0r1�read_lc_string�s  rV.cCsg}dddd�}t|�}d}||k�r
||}|dkr:dS|dkrV|�d�|d	7}q|d
kr�|}|�||d	||d	��|d	|7}qd}z||}Wntk
r�YdSXt||d	||d	��}|�||d	||||d	��|d	||7}qt|�S)zXReads all length encoded strings from the given buffer

    Returns a list of bytes
    rQr?r&)rPrRrSrr4NrFrrO)r*�append�KeyErrorr2�tuple)r!Zbyteslst�sizes�buf_len�pos�firstr.rUr0r0r1�read_lc_string_list�s0


&r^)r!�endrKr"c
Cs�|dkr|dkrtd��|dk	rxz|�|�}Wn,tk
rZ}ztd�|�W5d}~XYnX||dd�|d|�fS|dk	r�t||�Std��dS)zr
    Reads a string up until a character or for a given size.

    Returns a tuple (trucated buffer, string).
    Nz&read_string() needs either end or sizezend byte not present in bufferrrz.read_string() needs either end or size (weird))r7�indexrN)r!r_rK�idx�errr0r0r1�read_string"s

rccCs t|d|��}||d�|fS)zMRead an integer from buffer

    Returns a tuple (truncated buffer, int)
    rNrTrLr0r0r1�read_int;srdcCs�|std��|d}|dkr,|dd�dfS|dkrH|dd�t|�fS|dkrt|dd�t�d|dd��dfS|d	kr�|d
d�t�d|dd
�d�dfS|d
kr�|dd�t�d|dd��dfStd��dS)z�
    Takes a buffer and reads an length code string from the start.

    Returns a tuple with buffer less the integer and the integer read.
    z
Empty buffer.rrFrNrPr?z<xHrRr#r%r$rS�	z<xQz%Failed reading length encoded integer)r7r)r,r-)r!Zlcbyter0r0r1�read_lc_intDs$($rfcCs2t|t�sd�dd�|D��Sd�dd�|D��S)z"Debug function for showing buffers�cSsg|]}d|d���qS�z\xZ02xr0��.0�cr0r0r1�
<listcomp>asz"_digest_buffer.<locals>.<listcomp>cSsg|]}dt|�d���qSrh)�ordrir0r0r1rlbs)r(�str�join)r!r0r0r1�_digest_buffer^s
rp�)�abuffer�prefix�limitr"cCsL|r<|r"|dkr"t|d|��}nt|�}t|d|�ntt|��dS)z2Debug function printing output of _digest_buffer()rz: N)rp�print)rrrsrt�digestr0r0r1�print_bufferesrw�r"c	Cs�i}tj�dd�}tj�|�s"|St|dd��P}|D]D}|�d�}t|�dkrPq4|d��}|d�d	��	d
�}|||<q4W5QRX|S)zsParse the contents of /etc/os-release file.

    Returns:
        A dictionary containing release information.
    �/etcz
os-release�utf-8��encoding�=rQrr�
�"�
�os�pathro�exists�open�splitr*�lower�rstrip�strip)�distro�os_release_file�file_obj�line�	key_value�key�valuer0r0r1�_parse_os_releasess
r�c	Cs�i}tj�dd�}tj�|�r�t|dd��P}|D]D}|�d�}t|�dkrLq0|d��}|d�d	��	d
�}|||<q0W5QRX|S)ztParse the contents of /etc/lsb-release file.

    Returns:
        A dictionary containing release information.
    ryzlsb-releaserzr{r}rQrrr~rr�)r�Zlsb_release_filer�r�r�r�r�r0r0r1�_parse_lsb_release�s
r�c	Cs�i}ttjddd���}ztjd|d�}Wn tk
rHYW5QR�dSX|�t����	�}|D]F}|�
d�}t|�dkr|q`|d	�d
d��
�}|d�d
�}|||<q`W5QRX|S)ztParse the output of the lsb_release command.

    Returns:
        A dictionary containing release information.
    �wrzr{)�lsb_releasez-a)�stderrN�:rQr� �_r�	)r�r��devnull�
subprocess�check_output�OSError�decode�sys�getfilesystemencoding�
splitlinesr�r*�replacer�r�)r�r��stdout�linesr�r�r�r�r0r0r1�_parse_lsb_release_command�s
r�cCs�t�}|r,|�dd�|�dd�|�dd�fSt�}|rX|�dd�|�dd�|�dd�fSt�}|r�|�dd�|�d	d�|�d
d�fSdS)aNTries to determine the name of the Linux OS distribution name.

    First tries to get information from ``/etc/os-release`` file.
    If fails, tries to get the information of ``/etc/lsb-release`` file.
    And finally the information of ``lsb-release`` command.

    Returns:
        A tuple with (`name`, `version`, `codename`)
    Z
distrib_idrgZdistrib_releaseZdistrib_codename�distributor_id�release�codename�name�
version_id�version_codename)rgrgrg)r��getr�r�)r�r0r0r1�linux_distribution�s&



�


�


�r�)�unicode_strr"cCs|rt�|d�dkrdSdS)z�Get the readiness direction of the unicode string.

    We assume that the direction is "L-to-R" if the first character does not
    indicate the direction is "R-to-L" or an "AL" (Arabic Letter).
    r)�R�AL�R-to-LzL-to-R)�unicodedata�
bidirectional)r�r0r0r1�_get_unicode_read_direction�sr�cCs@t|�}|dkr8t|d�r(t|d�s0td��dtiSdtiS)at
    1) The characters in section 5.8 MUST be prohibited.

    2) If a string contains any RandALCat character, the string MUST NOT
       contain any LCat character.

    3) If a string contains any RandALCat character, a RandALCat
       character MUST be the first character of the string, and a
       RandALCat character MUST be the last character of the string.
    r�r���zvInvalid unicode Bidirectional sequence, if the first character is RandALCat, the final charactermust be RandALCat too.z7Bidirectional Characters requirement 2 [StringPrep, d2])r�rr7r)r�Zread_dirr0r0r1�_get_unicode_direction_rule�s�r�)�normalized_strr"c
Cs�ttttttttttt	t
d�}z|�t|��Wn2t
k
rb}z|t|�fWY�Sd}~XYnX|D]6}|��D](\}}||�rt|dkrt||fSqtqhdS)a�Check for Prohibited Output according to rfc4013 profile.

    This profile specifies the following characters as prohibited input:

       - Non-ASCII space characters [StringPrep, C.1.2]
       - ASCII control characters [StringPrep, C.2.1]
       - Non-ASCII control characters [StringPrep, C.2.2]
       - Private Use characters [StringPrep, C.3]
       - Non-character code points [StringPrep, C.4]
       - Surrogate code points [StringPrep, C.5]
       - Inappropriate for plain text characters [StringPrep, C.6]
       - Inappropriate for canonical representation characters [StringPrep, C.7]
       - Change display properties or deprecated characters [StringPrep, C.8]
       - Tagging characters [StringPrep, C.9]

    In addition of checking of Bidirectional Characters [StringPrep, Section 6]
    and the Unassigned Code Points [StringPrep, A.1].

    Returns:
        A tuple with ("probited character", "breaked_rule")
    )z4Space characters that contains the ASCII code pointsz&Space characters non-ASCII code pointsz(Unassigned Code Points [StringPrep, A.1]z.Non-ASCII space characters [StringPrep, C.1.2]z,ASCII control characters [StringPrep, C.2.1]z(Private Use characters [StringPrep, C.3]z+Non-character code points [StringPrep, C.4]z'Surrogate code points [StringPrep, C.5]z9Inappropriate for plain text characters [StringPrep, C.6]zGInappropriate for canonical representation characters [StringPrep, C.7]zDChange display properties or deprecated characters [StringPrep, C.8]z$Tagging characters [StringPrep, C.9]Nr�)r
rrrrrrr	r
rr�updater�r7rn�items)r��rulesrb�charZrule�funcr0r0r1�"validate_normalized_unicode_strings,�"r�)�a_stringr"cCs0dd�|D�}d�|�}t�d|�}|s,dS|S)a(normalizes a unicode string according to rfc4013

    Normalization of a unicode string according to rfc4013: The SASLprep profile
    of the "stringprep" algorithm.

    Normalization Unicode equivalence is the specification by the Unicode
    character encoding standard that some sequences of code points represent
    essentially the same character.

    This method normalizes using the Normalization Form Compatibility
    Composition (NFKC), as described in rfc4013 2.2.

    Returns:
        Normalized unicode string according to rfc4013.
    cSs(g|] }t|�rdnt|�r dn|�qS)r�rg)rr)rjr�r0r0r1rlIs�z,normalize_unicode_string.<locals>.<listcomp>rg�NFKC)ror��	normalize)r�Z	nstr_listZnstrr0r0r1�normalize_unicode_string6s�
r��rz)�payloadr|r"c
Csrt|t�r|St|t�r t|�St|t�sjzt|j|d��WStk
rh}ztd�|�W5d}~XYnXt|�S)z(Initialize a bytearray from the payload.r{zpayload must be a str or bytesN)r(r+r)�bytes�encode�AttributeErrorr7)r�r|rbr0r0r1�init_bytearray[s


r�cCs�ddd�}tjdkrldt��dkr.d|d<n&dt��dkrHd	|d<nt��|d<d
t��d��|d<nHt��|d<t��d
kr�dt��d��|d<nd�t	�dd��|d<|S)z4Return a dict with the platform arch and OS version.rg)�arch�version�ntZ64r�x86_64r�Z32�i386zWindows-rr��DarwinzmacOS-�-rQ)
r�r��platform�architecture�	win32_ver�machine�system�mac_verror�)�platr0r0r1�get_platformls



r�)�fullpathr"c
Cs�t|t�std��z(|�dd�\}}t�|�}t||�}WnVtk
r`td|�d��d�Yn2ttfk
r�}zt|��|�W5d}~XYnX|S)a(Import an object from a fully qualified module path.

    Args:
        obj (str): A string representing the fully qualified name of the object.

    Returns:
        Object: The imported object.

    Raises:
        ValueError: If the object can't be imported.

    .. versionadded:: 8.0.33
    z]'fullpath' should be a str representing the fully qualified name of the object to be imported�.rzNo callable named '�'N)	r(rnr7�rsplit�	importlib�
import_module�getattrr��ModuleNotFoundError)r�Z
module_strZcallable_str�module�objrbr0r0r1�
import_object�s
�
r�)�cipher_as_ossl�tls_versionr"cCs0|t�|i���kr,d|�d�}t�|t�dS)aIEmits a warning if a deprecated cipher is being utilized.

    Args:
        cipher: Must be ingested as OpenSSL name.
        tls_versions: TLS version to check the cipher against.

    Raises:
        DeprecationWarning: If the cipher is flagged as deprecated
                            according to the OSSA cipher list.
    z$This connection is using TLS cipher �[ which is now deprecated and will be removed in a future release of MySQL Connector/Python.N)rr��values�warnings�warn�DeprecationWarning)r�r��warn_msgr0r0r1�warn_ciphersuites_deprecated�s
�r�)r�r"cCs$|tkr d|�d�}t�|t�dS)aEmits a warning if a deprecated TLS version is being utilized.

    Args:
        tls_versions: TLS version to check.

    Raises:
        DeprecationWarning: If the TLS version is flagged as deprecated
                            according to the OSSA cipher list.
    z%This connection is using TLS version r�N)rr�r�r�)r�r�r0r0r1�warn_tls_version_deprecated�s

�r�csXeZdZdZedd�dd�Zeed�dd�Zeedd	��fd
d�Zed�d
d�Z	�Z
S)�GenericWrapperz<Base class that provides basic object wrapper functionality.N)�wrappedr"cCs
||_dS)zConstructor.N)�_wrapped)�selfr�r0r0r1�__init__�szGenericWrapper.__init__)�attrr"cCs ||jkrt||�St|j|�S)z�Gets an attribute.

        Attributes defined in the wrapper object have higher precedence
        than those wrapped object equivalent. Attributes not found in
        the wrapper are then searched in the wrapped object.
        )�__dict__r�r�)r�r�r0r0r1�__getattr__�s

zGenericWrapper.__getattr__)r�r�r"csFd|jkr||jd<dS||jkr4t��||�dS|j�||�dS)zSets an attribute.r�N)r��super�__setattr__r�)r�r�r���	__class__r0r1r��s


zGenericWrapper.__setattr__rxcCs
|jjjS)zGets the wrapped class name.)r�r��__name__)r�r0r0r1�get_wrapped_class�sz GenericWrapper.get_wrapped_class)r��
__module__�__qualname__�__doc__rr�rnr�r�r��
__classcell__r0r0r�r1r��s


r�)NN)Nrq)r�rz)Sr�r�r�r�r,r�r�r�r��decimalr�	functoolsr�
stringpreprrrrrr	r
rrr
rrrr�typingrrrrrrrrZcustom_typesrZtls_ciphersrr�typesrr�bool�__annotations__r)�floatr r�r2r:r=r@rBrDrErJrNrVr^rcrdrfrnrprwr�r�r�r�r�r�r�r�r+r�r�r�r�r�r�r0r0r0r1�<module>s�@(�(
5 *�
�	��%"�4&�
�(

Anon7 - 2022
AnonSec Team