Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/jinja2/__pycache__/sandbox.cpython-311.pyc

�

�܋f9��V�UdZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
lmZd	dlmZd	dlmZd	d
lmZejdejdejf���ZdZe��Zejeed<e��Z ejeed<ddhZ!ddhZ"ddhZ#ej$e%gd���fej&e%gd���fej'e%gd���fe	e%gd���ffZ(ej)ej)ej*ej+efdfed<dejd ej,efd!�Z-d"e.d e/fd#�Z0d$ed efd%�Z1d&ejd'ed e2fd(�Z3d&ejd'ed e2fd)�Z4Gd*�d+e��Z5Gd,�d-e5��Z6Gd.�d/e��Z7Gd0�d1e7e
��Z8dS)2z�A sandbox layer that ensures unsafe operations cannot be performed.
Useful when the template itself comes from an untrusted source.
�N)�formatter_field_name_split)�abc)�deque)�	Formatter)�EscapeFormatter)�Markup�)�Environment)�
SecurityError)�Context)�	Undefined�F.)�boundi���UNSAFE_FUNCTION_ATTRIBUTES�UNSAFE_METHOD_ATTRIBUTES�gi_frame�gi_code�cr_frame�cr_code�ag_code�ag_frame)�add�clear�difference_update�discard�pop�remove�symmetric_difference_update�update)rr�popitem�
setdefaultr)�append�reverse�insert�sort�extendr)	r"�
appendleftrr&�
extendleftr�popleftr�rotate�
_mutable_spec�callable�returnc��t|tjtjf��r	|jdvrdS|j}t|t��r|SdS)N)�format�
format_map)�
isinstance�types�
MethodType�BuiltinMethodType�__name__�__self__�str)r,�objs  �_/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/sandbox.py�inspect_format_methodr:Ss\����5�#�U�%<�=����	�	�":�	:�	:��t�
�
�C��#�s�����
��4��argsc�x�t|�}t|��tkrtdt�d����|S)zWA range that can't generate ranges with a length of more than
    MAX_RANGE items.
    z@Range too big. The sandbox blocks ranges larger than MAX_RANGE (z).)�range�len�	MAX_RANGE�
OverflowError)r<�rngs  r9�
safe_rangerCasN����,�C�
�3�x�x�)����
)�$�
)�
)�
)�
�
�	
�
�Jr;�fc��d|_|S)z�Marks a function or method as unsafe.

    .. code-block: python

        @unsafe
        def delete(self):
            pass
    T)�unsafe_callable)rDs r9�unsaferGps���A���Hr;r8�attrc��t|tj��r
|tvrdS�nt|tj��r|tvs	|t
vrdSn�t|t��r	|dkrdSn�t|tjtjtj	f��rdSt|tj
��r|tvrdSnuttd��r&t|tj
��r|tvrdSn:ttd��r%t|tj��r|t vrdS|�d��S)a�Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    T�mro�
CoroutineType�AsyncGeneratorType�__)r1r2�FunctionTyperr3r�type�CodeType�
TracebackType�	FrameType�
GeneratorType�UNSAFE_GENERATOR_ATTRIBUTES�hasattrrK�UNSAFE_COROUTINE_ATTRIBUTESrL�!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES�
startswith)r8rHs  r9�is_internal_attributerY}sh���#�u�)�*�*���-�-�-��4�.�	�C��)�	*�	*���-�-�-��9Q�1Q�1Q��4�2R�	�C��	�	���5�=�=��4��	�C�%�.�%�*=�u��O�	P�	P���t�	�C��,�	-�	-�
��.�.�.��4�/�	���	(�	(��Z��U�=P�-Q�-Q���.�.�.��4�/�	��,�	-�	-��*��U�
%�3�3���4�4�4��4��?�?�4� � � r;c�L�tD]\}}t||��r||vcS�dS)a�This function checks if an attribute on a builtin mutable object
    (list, dict, set or deque) or the corresponding ABCs would modify it
    if called.

    >>> modifies_known_mutable({}, "clear")
    True
    >>> modifies_known_mutable({}, "keys")
    False
    >>> modifies_known_mutable([], "append")
    True
    >>> modifies_known_mutable([], "index")
    False

    If called with an unsupported object, ``False`` is returned.

    >>> modifies_known_mutable("foo", "upper")
    False
    F)r+r1)r8rH�typespecrGs    r9�modifies_known_mutabler\�sD��&*�"�"���&��c�8�$�$�	"��6�>�!�!�!�	"��5r;c���eZdZUdZdZejejejej	ej
ejejd�Z
ejeejejejgejffed<ejejd�Zejeejejgejffed<e��Zejeed<e��Zejeed<d	ejd
ejddf�fd
�Zdejdedejdefd�Zdejdefd�Zdededejdejdejf
d�Z dededejdejfd�Z!dejdej"eejfdej"eje#ffd�Z$dejdedej"eje#ffd�Z%dejdede#fd�Z&	d&ded	ej'ejd fd
ejeejfd!ej(ejdef
d"�Z)d#ed$ejd	ejd
ejdejf
d%�Z*�xZ+S)'�SandboxedEnvironmenta�The sandboxed environment.  It works like the regular environment but
    tells the compiler to generate sandboxed code.  Additionally subclasses of
    this environment may override the methods that tell the runtime what
    attributes or functions are safe to access.

    If the template tries to access insecure code a :exc:`SecurityError` is
    raised.  However also other exceptions may occur during the rendering so
    the caller has to ensure that all exceptions are caught.
    T)�+�-�*�/z//z**�%�default_binop_table)r_r`�default_unop_table�intercepted_binops�intercepted_unopsr<�kwargsr-Nc����t��j|i|��t|jd<|j���|_|j���|_dS)Nr>)	�super�__init__rC�globalsrd�copy�binop_tablere�
unop_table)�selfr<rh�	__class__s   �r9rkzSandboxedEnvironment.__init__�s\��������$�)�&�)�)�)� *���W���3�8�8�:�:����1�6�6�8�8����r;r8rH�valuec�N�|�d��pt||��S)aYThe sandboxed environment will call this method to check if the
        attribute of an object is safe to access.  Per default all attributes
        starting with an underscore are considered private as well as the
        special attributes of internal python objects as returned by the
        :func:`is_internal_attribute` function.
        �_)rXrY)rpr8rHrrs    r9�is_safe_attributez&SandboxedEnvironment.is_safe_attributes)���O�O�C�(�(�L�,A�#�t�,L�,L�M�Mr;c�H�t|dd��pt|dd��S)z�Check if an object is safely callable. By default callables
        are considered safe unless decorated with :func:`unsafe`.

        This also recognizes the Django convention of setting
        ``func.alters_data = True``.
        rFF�alters_data)�getattr)rpr8s  r9�is_safe_callablez%SandboxedEnvironment.is_safe_callables0��
�C�*�E�2�2�X�g�c�=�RW�6X�6X�
�	
r;�context�operator�left�rightc�0�|j|||��S)z�For intercepted binary operator calls (:meth:`intercepted_binops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        )rn)rprzr{r|r}s     r9�
call_binopzSandboxedEnvironment.call_binops��*�t���)�$��6�6�6r;�argc�.�|j||��S)z�For intercepted unary operator calls (:meth:`intercepted_unops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        )ro)rprzr{r�s    r9�	call_unopzSandboxedEnvironment.call_unop!s��)�t��x�(��-�-�-r;�argumentc��	||S#ttf$r�t|t��rt	t|��}	t	||��}|�|||��r|cYS|�||��cYS#t$rYnwxYw#t$rYnwxYwYnwxYw|�	||���S)z(Subscribe an object from sandboxed code.�r8�name)
�	TypeError�LookupErrorr1r7rxru�unsafe_undefined�AttributeError�	Exception�	undefined)rpr8r�rHrrs     r9�getitemzSandboxedEnvironment.getitem*s��	D��x�=� ���;�'�	D�	D�	D��(�C�(�(�

D�D��x�=�=�D�D� '��T� 2� 2�� �1�1�#�x��G�G�)�#(�L�L�L�#�4�4�S�(�C�C�C�C�C��*�����������!�����D�������		D�����~�~�#�H�~�5�5�5sV�
�&B'�B�B�B'�,B'�
B�B'�B�B'�
B!�B'� B!�!B'�&B'�	attributec��	t||��}|�|||��r|S|�||��S#t$r%	||cYS#tt
f$rYnwxYwYnwxYw|�||���S)z�Subscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        r�)rxrur�r�r�r�r�)rpr8r�rrs    r9rxzSandboxedEnvironment.getattrAs���
	9��C��+�+�E��%�%�c�9�e�<�<�
����(�(��i�8�8�8���	�	�	�
��9�~�%�%�%���{�+�
�
�
���
������		�����~�~�#�I�~�6�6�6s5�A�
A0�A�A0�A*�'A0�)A*�*A0�/A0c�p�|�d|�dt|��j�d�||t���S)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)r�r8�exc)r�rOr5r)rpr8r�s   r9r�z%SandboxedEnvironment.unsafe_undefinedRsR���~�~�
9�9�
9�
9��S�	�	�"�
9�
9�
9�����
�
�	
r;�s.�format_funcc�x�t|t��rt||j���}nt	|��}|�O|jdkrDt
|��dks|r%tdt
|��|duz�d����|d}d}|�|||��}t|��|��S)	z�If a format call is detected, then this is routed through this
        method so that our safety sandbox can be used for it.
        )�escapeNr0r	z(format_map() takes exactly one argument z givenr�)
r1r�SandboxedEscapeFormatterr��SandboxedFormatterr5r?r��vformatrO)rpr�r<rhr��	formatter�rvs       r9�
format_stringz"SandboxedEnvironment.format_string\s����a�� � �	1�0��a�h�G�G�G�I�I�*�4�0�0�I��"�{�';�|�'K�'K��4�y�y�A�~�~��~��A��D�	�	�V�4�%7�8�A�A�A����
�!�W�F��D�
�
�
�q�$��
/�
/���t�A�w�w�r�{�{�r;�_SandboxedEnvironment__context�_SandboxedEnvironment__objc���t|��}|�|�||||��S|�|��st|�d����|j|g|�Ri|��S)z#Call an object from sandboxed code.Nz is not safely callable)r:r�ryr�call)�_SandboxedEnvironment__selfr�r�r<rh�fmts      r9r�zSandboxedEnvironment.callys���$�E�*�*���?��'�'��T�6�5�A�A�A��&�&�u�-�-�	E��5� C� C� C�D�D�D��y�~�e�5�d�5�5�5�f�5�5�5r;�N),r5�
__module__�__qualname__�__doc__�	sandboxedr{r�sub�mul�truediv�floordiv�pow�modrd�t�Dictr7�Callable�Any�__annotations__�pos�negre�	frozensetrf�	FrozenSetrgrk�boolruryrrr��Unionr
r�rxr��Tuple�Optionalr�r��
__classcell__�rqs@r9r^r^�s������������I��\�
�\�
�\�
�
����l�
�\�K�K�����Q�Z��������0E�%F� F�G�����\�
�\�C�C����s�A�J���w���~�$>�>�?����&,5�9�;�;����C�(�6�6�6�+4�)�+�+��q�{�3�'�5�5�5�9�a�e�9�q�u�9��9�9�9�9�9�9�N�Q�U�N�#�N�a�e�N��N�N�N�N�	
�A�E�	
�d�	
�	
�	
�	
�	7��	7�*-�	7�56�U�	7�CD�5�	7�	
��	7�	7�	7�	7�.��.�C�.�a�e�.���.�.�.�.�6��5�6�$%�G�C���J�$7�6�	
����	�!�	"�6�6�6�6�.7�1�5�7�S�7�Q�W�Q�U�I�=M�5N�7�7�7�7�"
�A�E�
�c�
�i�
�
�
�
�/3������g�a�e�S�j�!����s�A�E�z�"�	�
�Z��
�+��

�
����:6��6��u�6��u�	6�
�%�6�
��
6�6�6�6�6�6�6�6r;r^c�H��eZdZdZdejdedejdef�fd�Z�xZ	S)�ImmutableSandboxedEnvironmentz�Works exactly like the regular `SandboxedEnvironment` but does not
    permit modifications on the builtin mutable objects `list`, `set`, and
    `dict` by using the :func:`modifies_known_mutable` function.
    r8rHrrr-c�p��t���|||��sdSt||��S)NF)rjrur\)rpr8rHrrrqs    �r9ruz/ImmutableSandboxedEnvironment.is_safe_attribute�s9����w�w�(�(��d�E�:�:�	��5�)�#�t�4�4�4�4r;)
r5r�r�r�r�r�r7r�rur�r�s@r9r�r��sg���������
5�Q�U�5�#�5�a�e�5��5�5�5�5�5�5�5�5�5�5r;r�c
���eZdZdedejddf�fd�Zdedejejdej	eejfdej
ejeffd�Z�xZS)	r��envrhr-Nc�H��||_t��jdi|��dS)Nr�)�_envrjrk)rpr�rhrqs   �r9rkzSandboxedFormatter.__init__�s-�����	������"�"�6�"�"�"�"�"r;�
field_namer<c���t|��\}}|�|||��}|D]>\}}|r|j�||��}�#|j�||��}�?||fSr�)r�	get_valuer�rxr�)	rpr�r<rh�first�restr8�is_attr�is	         r9�	get_fieldzSandboxedFormatter.get_field�s���1��<�<���t��n�n�U�D�&�1�1���	0�	0�J�G�Q��
0��i�'�'��Q�/�/����i�'�'��Q�/�/����E�z�r;)
r5r�r�r
r�r�rkr7�Sequence�Mappingr�r�r�r�s@r9r�r��s��������#�K�#�1�5�#�T�#�#�#�#�#�#�
��
�%&�Z���%6�
�@A�	�#�q�u�*�@U�
�	
������	�
�
�
�
�
�
�
�
r;r�c��eZdZdS)r�N)r5r�r�r�r;r9r�r��s�������Dr;r�)9r�r{r2�typingr��_stringr�collectionsrr�stringr�
markupsaferr�environmentr
�
exceptionsr�runtimerr
�TypeVarr�r�rr@�setr�Setr7r�rrTrVrW�
MutableSetr��MutableMapping�MutableSequencer+r��Typer�r�r:�intr>rCrGr�rYr\r^r�r�r�r�r;r9�<module>r�s������������������.�.�.�.�.�.�������������������&�&�&�&�&�&�������$�$�$�$�$�$�%�%�%�%�%�%�������������
�A�I�c���C���J�/�0�0�0��
�	�*-�����A�E�#�J�.�.�.�(+�s�u�u��!�%��*�,�,�,� *�9�5�� *�9�5��&/�
�$;�!�	���	�	
�	
�	
�	
�	
�� 	���	�E�E�E�F�F��
	���	�M�M�M�N�N��
	��	�

�

�

�	
�	
��1(B�
�q�w�q�w�q�v�q�{�3�'7�7�8�#�=�>�(�(�(�V�A�J��1�:�c�?������c��e�����

�a�

�A�

�

�

�

�"!�q�u�"!�C�"!�D�"!�"!�"!�"!�J����S��T�����2N6�N6�N6�N6�N6�;�N6�N6�N6�b
5�
5�
5�
5�
5�$8�
5�
5�
5����������$	�	�	�	�	�1�?�	�	�	�	�	r;

Hacked By AnonymousFox1.0, Coded By AnonymousFox