AlkantarClanX12

Your IP : 3.144.31.64


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

�

l��f�B��R�dZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZdZe
rhd�Zn
e��Zhd�ZddhZddhZddhZejddee���efZefZ e!fZ"	ddl#m#Z#m$Z$ddl%m%Z%e e#e$fz
Z ee%fz
Zn#e&$rYnwxYw	ddl'm(Z(ee(fz
Zn#e&$rYnwxYweej)fz
Ze ej*fz
Z e"ej+fz
Z"ee,gd���fe e,gd���fe"e,gd���fee,gd ���ffZ-Gd!�d"ej.��Z/d#�Z0d$�Z1d%�Z2d&�Z3d'�Z4Gd(�d)e��Z5Gd*�d+e5��Z6	dd,l7m8Z8n#e&$rd-�Z8YnwxYwGd.�d/e9��Z:Gd0�d1e:e��Z;Gd2�d3e:e	��Z<dS)4z�A sandbox layer that ensures unsafe operations cannot be performed.
Useful when the template itself comes from an untrusted source.
�N)�deque)�	Formatter)�EscapeFormatter)�Markup�)�abc)�PY2)�
range_type)�string_types)�Environment)�
SecurityErrori��>�	func_code�	func_dict�func_closure�func_globals�
func_defaults>�im_func�im_self�im_class�gi_frame�gi_code�cr_frame�cr_code�ag_code�ag_frame�ignorezthe sets module)�module)�UserDict�	DictMixin)�UserList)�Set)�add�clear�difference_update�discard�pop�remove�symmetric_difference_update�update)r#r&�popitem�
setdefaultr))�append�reverse�insert�sort�extendr')	r,�
appendleftr#r0�
extendleftr&�popleftr'�rotatec�*�eZdZdZd�Zd�Zd�Zd�ZdS)�_MagicFormatMappingz�This class implements a dummy wrapper to fix a bug in the Python
    standard library for string formatting.

    See https://bugs.python.org/issue13598 for information about why
    this is necessary.
    c�0�||_||_d|_dS)Nr)�_args�_kwargs�_last_index��self�args�kwargss   �n/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/sandbox.py�__init__z_MagicFormatMapping.__init__�s����
���������c��|dkrD|j}|xjdz
c_	|j|S#t$rYnwxYwt|��}|j|S)N�r)r:r8�LookupError�strr9)r<�key�idxs   r?�__getitem__z_MagicFormatMapping.__getitem__�sp���"�9�9��"�C�����!���
��z�#��&���
�
�
���
�����c�(�(�C��|�C� � s�,�
9�9c�*�t|j��S�N)�iterr9�r<s r?�__iter__z_MagicFormatMapping.__iter__�s���D�L�!�!�!rAc�*�t|j��SrJ)�lenr9rLs r?�__len__z_MagicFormatMapping.__len__�s���4�<� � � rAN)�__name__�
__module__�__qualname__�__doc__r@rHrMrP�rAr?r6r6}sZ�����������
	!�	!�	!�"�"�"�!�!�!�!�!rAr6c��t|tjtjf��r	|jdvrdS|j}t|t��r|SdS)N)�format�
format_map)�
isinstance�types�
MethodType�BuiltinMethodTyperQ�__self__r)�callable�objs  r?�inspect_format_methodr`�sa����5�#�U�%<�=����	�	�":�	:�	:��t�
�
�C��#�|�$�$���
��rAc�v�t|�}t|��tkrtdtz���|S)zWA range that can't generate ranges with a length of more than
    MAX_RANGE items.
    zDRange too big. The sandbox blocks ranges larger than MAX_RANGE (%d).)r
rO�	MAX_RANGE�
OverflowError)r=�rngs  r?�
safe_rangere�sE���d�
�C�
�3�x�x�)����
�!*�
+�
�
�	
�
�JrAc��d|_|S)znMarks a function or method as unsafe.

    ::

        @unsafe
        def delete(self):
            pass
    T)�unsafe_callable)�fs r?�unsaferi�s���A���HrAc��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�__)rYrZ�FunctionType�UNSAFE_FUNCTION_ATTRIBUTESr[�UNSAFE_METHOD_ATTRIBUTES�type�CodeType�
TracebackType�	FrameType�
GeneratorType�UNSAFE_GENERATOR_ATTRIBUTES�hasattrrl�UNSAFE_COROUTINE_ATTRIBUTESrm�!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES�
startswith)r_�attrs  r?�is_internal_attributer}�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� � � rAc�L�tD]\}}t||��r||vcS�dS)a�This function checks if an attribute on a builtin mutable object
    (list, dict, set or deque) would modify it if called.  It also supports
    the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and
    with Python 2.6 onwards the abstract base classes `MutableSet`,
    `MutableMapping`, and `MutableSequence`.

    >>> 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 (such as unicode) `False` is
    returned.

    >>> modifies_known_mutable("foo", "upper")
    False
    F)�
_mutable_specrY)r_r|�typespecris    r?�modifies_known_mutabler��sD��,*�"�"���&��c�8�$�$�	"��6�>�!�!�!�	"��5rAc��eZdZdZdZejejejej	ej
ejejd�Z
ejejd�Ze��Ze��Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zdd�Zd�ZdS)�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**�%)r�r�c��dS)a�Called during template compilation with the name of a unary
        operator to check if it should be intercepted at runtime.  If this
        method returns `True`, :meth:`call_unop` is executed for this unary
        operator.  The default implementation of :meth:`call_unop` will use
        the :attr:`unop_table` dictionary to perform the operator with the
        same logic as the builtin one.

        The following unary operators are interceptable: ``+`` and ``-``

        Intercepted calls are always slower than the native operator call,
        so make sure only to intercept the ones you are interested in.

        .. versionadded:: 2.6
        FrU)r<�operators  r?�intercept_unopz#SandboxedEnvironment.intercept_unopAs	���urAc���tj|g|�Ri|��t|jd<|j���|_|j���|_dS)N�range)	rr@re�globals�default_binop_table�copy�binop_table�default_unop_table�
unop_tabler;s   r?r@zSandboxedEnvironment.__init__Rs`����T�3�D�3�3�3�F�3�3�3� *���W���3�8�8�:�:����1�6�6�8�8����rAc�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.
        �_)r{r}�r<r_r|�values    r?�is_safe_attributez&SandboxedEnvironment.is_safe_attributeXs)���O�O�C�(�(�L�,A�#�t�,L�,L�M�MrAc�H�t|dd��pt|dd��S)aCheck if an object is safely callable.  Per default a function is
        considered safe unless the `unsafe_callable` attribute exists and is
        True.  Override this method to alter the behavior, but this won't
        affect the `unsafe` decorator from this module.
        rgF�alters_data)�getattr)r<r_s  r?�is_safe_callablez%SandboxedEnvironment.is_safe_callableas0��
�C�*�E�2�2�X�g�c�=�RW�6X�6X�
�	
rAc�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
        )r�)r<�contextr��left�rights     r?�
call_binopzSandboxedEnvironment.call_binopks��*�t���)�$��6�6�6rAc�.�|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
        )r�)r<r�r��args    r?�	call_unopzSandboxedEnvironment.call_unopts��)�t��x�(��-�-�-rAc��	||S#ttf$r�t|t��rt	t	|��}	t||��}|�|||��r|cYS|�||��cYS#t$rYnwxYw#t$rYnwxYwYnwxYw|�
||���S)z(Subscribe an object from sandboxed code.�r_�name)�	TypeErrorrDrYrrEr�r��unsafe_undefined�AttributeError�	Exception�	undefined)r<r_�argumentr|r�s     r?�getitemzSandboxedEnvironment.getitem}s��	D��x�=� ���;�'�	D�	D�	D��(�L�1�1�

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'c��	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�)r�r�r�r�r�rDr�)r<r_�	attributer�s    r?r�zSandboxedEnvironment.getattr�s���
	9��C��+�+�E��%�%�c�9�e�<�<�
����(�(��i�8�8�8���	�	�	�
��9�~�%�%�%���{�+�
�
�
���
������		�����~�~�#�I�~�6�6�6s5�A�
A0�A�A0�A*�'A0�)A*�*A0�/A0c�`�|�d|�d|jj�d�||t���S)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)r�r_�exc)r��	__class__rQr
)r<r_r�s   r?r�z%SandboxedEnvironment.unsafe_undefined�sB���~�~�~�#,�9�9�c�m�.D�.D�.D�
F�����
�
�	
rANc��t|t��rt||j��}nt	|��}|�N|jdkrCt
|��dks|r$tdt
|��|duzz���|d}d}t||��}|�	|||��}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.
        NrXrz0format_map() takes exactly one argument %d givenr)rYr�SandboxedEscapeFormatter�escape�SandboxedFormatterrQrOr�r6�vformatrr)r<�sr=r>�format_func�	formatter�rvs       r?�
format_stringz"SandboxedEnvironment.format_string�s����a�� � �	1�0��q�x�@�@�I�I�*�4�0�0�I��"�{�';�|�'K�'K��4�y�y�A�~�~��~��F��4�y�y�F�$�$6�7�9����
�!�W�F��D�$�T�6�2�2��
�
�
�q�$��
/�
/���t�A�w�w�r�{�{�rAc���t|��}|�|�||||��S|�|��st|�d����|j|g|�Ri|��S)z#Call an object from sandboxed code.Nz is not safely callable)r`r�r�r
�call)�_SandboxedEnvironment__self�_SandboxedEnvironment__context�_SandboxedEnvironment__objr=r>�fmts      r?r�zSandboxedEnvironment.call�s~��#�E�*�*���?��'�'��T�6�5�A�A�A��&�&�u�-�-�	H��u�u�u� F�G�G�G��y�~�e�5�d�5�5�5�f�5�5�5rArJ)rQrRrSrT�	sandboxedr�r"�sub�mul�truediv�floordiv�pow�modr��pos�negr��	frozenset�intercepted_binops�intercepted_unopsr�r@r�r�r�r�r�r�r�r�r�rUrAr?r�r�s6���������I��\�
�\�
�\�
�
����l�
�\���� (�|�(�,�?�?�� #�����"�	�������"9�9�9�N�N�N�
�
�
�7�7�7�.�.�.�6�6�6�*7�7�7�"
�
�
�����.
6�
6�
6�
6�
6rAr�c��eZdZdZd�ZdS)�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.
    c�b�t�||||��sdSt||��S)NF)r�r�r�r�s    r?r�z/ImmutableSandboxedEnvironment.is_safe_attribute�s6��#�5�5�d�C��u�M�M�	��5�)�#�t�4�4�4�4rAN)rQrRrSrTr�rUrAr?r�r��s-��������
5�5�5�5�5rAr�)�formatter_field_name_splitc�*�|���SrJ)�_formatter_field_name_split)�
field_names r?r�r��s���5�5�7�7�7rAc��eZdZd�Zd�ZdS)�SandboxedFormatterMixinc��||_dSrJ)�_env�r<�envs  r?r@z SandboxedFormatterMixin.__init__�s
����	�	�	rAc���t|��\}}|�|||��}|D]>\}}|r|j�||��}�#|j�||��}�?||fSrJ)r��	get_valuer�r�r�)	r<r�r=r>�first�restr_�is_attr�is	         r?�	get_fieldz!SandboxedFormatterMixin.get_field�s��0��<�<���t��n�n�U�D�&�1�1���	0�	0�J�G�Q��
0��i�'�'��Q�/�/����i�'�'��Q�/�/����E�z�rAN)rQrRrSr@r�rUrAr?r�r��s2�������������rAr�c��eZdZd�ZdS)r�c�d�t�||��tj|��dSrJ)r�r@rr�s  r?r@zSandboxedFormatter.__init__�s/���(�(��s�3�3�3���4� � � � � rAN�rQrRrSr@rUrAr?r�r��s#������!�!�!�!�!rAr�c��eZdZd�ZdS)r�c�f�t�||��tj||��dSrJ)r�r@r)r<r�r�s   r?r@z!SandboxedEscapeFormatter.__init__�s1���(�(��s�3�3�3�� ��v�.�.�.�.�.rANr�rUrAr?r�r��s#������/�/�/�/�/rAr�)=rTr�rZ�warnings�collectionsr�stringr�
markupsaferr�_compatrr	r
r�environmentr�
exceptionsr
rbrp�setrqrwryrz�filterwarnings�DeprecationWarningrQ�_mutable_set_types�dict�_mutable_mapping_types�list�_mutable_sequence_typesrrr �ImportError�setsr!�
MutableSet�MutableMapping�MutableSequencer�r�Mappingr6r`rerir}r�r�r��_stringr��objectr�r�r�rUrAr?�<module>rs�����������������������������&�&�&�&�&�&�������������������������!�!�!�!�!�!�$�$�$�$�$�$�%�%�%�%�%�%�
�	��'�"�"�"���"%�����>�=�=�� *�9�5�� *�9�5��&/�
�$;�!������!3�H������V������'��	�,�,�,�,�,�,�,�,�!�!�!�!�!�!��x��3�3���8�+�%�����	�	�	��D�	����	��������3�&� �����	�	�	��D�	�����s�~�'�'���3�-�/�/���C�/�1�1��	��	�	
�	
�	
�	
�	
�� 	��	�E�E�E�F�F��
	 ��	�M�M�M�N�N��
	��	�

�

�

�	
�	
��1(�
�V!�!�!�!�!�#�+�!�!�!�>������

�

�

�"!�"!�"!�J���8K6�K6�K6�K6�K6�;�K6�K6�K6�\	5�	5�	5�	5�	5�$8�	5�	5�	5�8�2�2�2�2�2�2�2���8�8�8�8�8�8�8�8�8���������f����!�!�!�!�!�0�)�!�!�!�/�/�/�/�/�6��/�/�/�/�/s6�B(�(B0�/B0�4C�C	�C	�&E-�-E8�7E8