Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/jinja2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/jinja2/__pycache__/sandbox.cpython-310.pyc
o

��g�:�@s$UdZddlZddlZddlZddlmZddlmZzddl	m
Z
Wney2ddlm
Z
Ynwddlm
Z
ddlmZddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlmZejdejdejfd�ZdZe�Z ej!e"e#d<e�Z$ej!e"e#d<ddhZ%ddhZ&ddhZ'ej(e)gd��fej*e)gd��fej+e)gd��fe
e)gd��ffZ,ej-ej-ej.ej/e"fdfe#d<d e0d!e1fd"d#�Z2d$ed!efd%d&�Z3d'ejd(e"d!e4fd)d*�Z5d'ejd(e"d!e4fd+d,�Z6Gd-d.�d.e�Z7Gd/d0�d0e7�Z8Gd1d2�d2e�Z9Gd3d4�d4e9e�Z:dS)5z�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)�update_wrapper)�	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�args�returncGs(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,�rng�r3�0/usr/lib/python3/dist-packages/jinja2/sandbox.py�
safe_rangeWs��r5�fcCs
d|_|S)z�Marks a function or method as unsafe.

    .. code-block: python

        @unsafe
        def delete(self):
            pass
    T)�unsafe_callable)r6r3r3r4�unsafefs	r8�obj�attrcCs�t|tj�r
|tvrdSnZt|tj�r|tvs|tvrdSnIt|t�r*|dkr)dSn=t|tjtjtj	f�r7dSt|tj
�rD|tvrCdSn#ttd�rVt|tj
�rV|tvrUdSnttd�rgt|tj�rg|tvrgdS|�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�__)�
isinstance�types�FunctionTyper�
MethodTyper�type�CodeType�
TracebackType�	FrameType�
GeneratorType�UNSAFE_GENERATOR_ATTRIBUTES�hasattrr<�UNSAFE_COROUTINE_ATTRIBUTESr=�!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES�
startswith)r9r:r3r3r4�is_internal_attributess8��
����
rMcCs(tD]\}}t||�r||vSqdS)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+r?)r9r:�typespecr8r3r3r4�modifies_known_mutable�s

�rOc
seZdZUdZdZejejejej	ej
ejejd�Z
ejeejejejgejffed<ejejd�Zejeejejgejffed<e�Zejeed<e�Zejeed<d	ejd
ejddf�fd
d�Zdejdedejdefdd�Zdejdefdd�Zdededejdejdejf
dd�Z dededejdejfdd�Z!dejdej"eejfdej"eje#ffd d!�Z$dejd"edej"eje#ffd#d$�Z%dejd"ede#fd%d&�Z&dejdej'ejd'effd(d)�Z(d*ed+ejd	ejd
ejdejf
d,d-�Z)�Z*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)rQrR�default_unop_table�intercepted_binops�intercepted_unopsr,�kwargsr-Ncs8t�j|i|��t|jd<|j��|_|j��|_dS)Nr.)	�super�__init__r5�globalsrV�copy�binop_tablerW�
unop_table)�selfr,rZ��	__class__r3r4r\�s
zSandboxedEnvironment.__init__r9r:�valuecCs|�d�p	t||�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.
        �_)rLrM�rar9r:rdr3r3r4�is_safe_attribute�sz&SandboxedEnvironment.is_safe_attributecCst|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``.
        r7F�alters_data)�getattr)rar9r3r3r4�is_safe_callables�z%SandboxedEnvironment.is_safe_callable�context�operator�left�rightcCs|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_)rarkrlrmrnr3r3r4�
call_binops	zSandboxedEnvironment.call_binop�argcCs|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`)rarkrlrpr3r3r4�	call_unopszSandboxedEnvironment.call_unop�argumentcCs�z||WSttfyVt|t�rTzt|�}Wn	ty"Yn2wzt||�}Wn	ty3Yn!w|�|�}|durA|YS|�|||�rL|YS|�	||�YSYnw|j
||d�S)z(Subscribe an object from sandboxed code.N�r9�name)�	TypeError�LookupErrorr?�str�	Exceptionri�AttributeError�wrap_str_formatrg�unsafe_undefined�	undefined)rar9rrr:rd�fmtr3r3r4�getitem s.

��
��zSandboxedEnvironment.getitem�	attributecCs�zt||�}Wnty#z||WYSttfy YnwYnw|�|�}|dur/|S|�|||�r8|S|�||�S|j||d�S)z�Subscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        Nrs)riryrurvrzrgr{r|)rar9rrdr}r3r3r4ri:s"��
zSandboxedEnvironment.getattrcCs&|jd|�dt|�j�d�||td�S)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)rtr9�exc)r|rC�__name__r)rar9rr3r3r4r{Ns��z%SandboxedEnvironment.unsafe_undefined.cs�t|tjtjf�r|jdvrdS|j�t�t�sdSt���|jdk�t�t�r0t	|�j
d�}nt|�}|j�dt
jdt
jdtf����fdd	�}t||�S)
aIf the given value is a ``str.format`` or ``str.format_map`` method,
        return a new function than handles sandboxing. This is done at access
        rather than in :meth:`call`, so that calls made without ``call`` are
        also sandboxed.
        )�format�
format_mapNr�)�escaper,rZr-csL�r|rtd��t|�dkrtdt|��d���|d}d}���||��S)Nz'format_map() takes no keyword argumentsr	z)format_map() takes exactly one argument (z given)rr3)rur/)r,rZ��f_self�
is_format_map�str_type�vformatr3r4�wrapperss�z5SandboxedEnvironment.wrap_str_format.<locals>.wrapper)r?r@rB�BuiltinMethodTyper��__self__rwrCr�SandboxedEscapeFormatterr��SandboxedFormatterr��t�Anyr)rard�	formatterr�r3r�r4rzXs �



$
z$SandboxedEnvironment.wrap_str_format�_SandboxedEnvironment__context�_SandboxedEnvironment__objcOs0|�|�st|�d���|j|g|�Ri|��S)z#Call an object from sandboxed code.z is not safely callable)rjr�call)�_SandboxedEnvironment__selfr�r�r,rZr3r3r4r��s
zSandboxedEnvironment.call)+r��
__module__�__qualname__�__doc__�	sandboxedrlr�sub�mul�truediv�floordiv�pow�modrVr��Dictrw�Callabler��__annotations__�pos�negrW�	frozensetrX�	FrozenSetrYr\�boolrgrjrrorq�Unionr
r~rir{�Optionalrzr��
__classcell__r3r3rbr4rP�sh

,�(�	����
�	��
�$$
,�����rPcs6eZdZdZdejdedejdef�fdd�Z�Z	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.
    r9r:rdr-cs t��|||�s
dSt||�S)NF)r[rgrOrfrbr3r4rg�sz/ImmutableSandboxedEnvironment.is_safe_attribute)
r�r�r�r�r�r�rwr�rgr�r3r3rbr4r��s*r�c
sfeZdZdedejddf�fdd�Zdedejejdej	eejfdej
ejeffd	d
�Z�ZS)r��envrZr-Ncs||_t�jdi|��dS)Nr3)�_envr[r\)rar�rZrbr3r4r\�szSandboxedFormatter.__init__�
field_namer,c	CsRt|�\}}|�|||�}|D]\}}|r|j�||�}q|j�||�}q||fS)N)r�	get_valuer�rir~)	rar�r,rZ�first�restr9�is_attr�ir3r3r4�	get_field�szSandboxedFormatter.get_field)
r�r�r�r
r�r�r\rw�Sequence�Mapping�Tupler�r�r3r3rbr4r��s�
���r�c@seZdZdS)r�N)r�r�r�r3r3r3r4r��sr�);r�rlr@�typingr��_stringr�collectionsr�collections.abcr�ImportError�	functoolsr�stringr�
markupsaferr�environmentr
�
exceptionsr�runtimerr
�TypeVarr�r�rr0�setr�Setrwr�rrHrJrK�
MutableSetr��MutableMapping�MutableSequencer+r��Typer��intr.r5r8r�rMrOrPr�r�r�r3r3r3r4�<module>sh���
�
���(�+
%d


Spamworldpro Mini