403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.144.115.20
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3.6/site-packages/jinja2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/jinja2/__pycache__/sandbox.cpython-36.pyc
3

�G�gND�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZdd	lmZdd
lmZdZe
r�edd
dddg�Zne�Zedddg�Zeddg�Zeddg�Zeddg�ZddlZejddedd�ddlmZefZe fZ!e"fZ#y6ddl$m$Z$m%Z%dd l&m&Z&e!e$e%f7Z!ee&f7ZWne'k
�rPYnXydd!l(m)Z)ee)f7ZWne'k
�r�YnXdd"lm*Z*m+Z+m,Z,ee*f7Ze!e+f7Z!e#e,f7Z#ee-d#d$d%d&d'd(d)d*g�fe!e-d$d'd+d,d*g�fe#e-d-d.d/d0d1d(g�fee-d-d2d$d1d3d'd4d(d5g	�ffZ.Gd6d7�d7e�Z/d8d9�Z0d:d;�Z1d<d=�Z2d>d?�Z3Gd@dA�dAe�Z4GdBdC�dCe4�Z5yddDl6m7Z7Wne'k
�r�dEdF�Z7YnXGdGdH�dHe8�Z9GdIdJ�dJe9e�Z:GdKdL�dLe9e�Z;dS)Maj
    jinja2.sandbox
    ~~~~~~~~~~~~~~

    Adds a sandbox layer to Jinja as it was the default behavior in the old
    Jinja 1 releases.  This sandbox is slightly different from Jinja 1 as the
    default behavior is easier to use.

    The behavior can be changed by subclassing the environment.

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD.
�N)�Mapping)�update_wrapper)�Environment)�
SecurityError)�string_types�PY2)�Markup)�EscapeFormatter)�	Formatteri��Zfunc_closureZ	func_codeZ	func_dictZ
func_defaultsZfunc_globalsZim_classZim_funcZim_self�gi_frame�gi_code�cr_frame�cr_code�ag_code�ag_frame�ignorezthe sets modulezjinja2.sandbox)�module)�deque)�UserDict�	DictMixin)�UserList)�Set)�
MutableSet�MutableMapping�MutableSequence�add�clear�difference_update�discard�pop�remove�symmetric_difference_update�update�popitem�
setdefault�append�reverse�insert�sort�extend�
appendleft�
extendleft�popleft�rotatec@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_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.
    cCs||_||_d|_dS)Nr)�_args�_kwargs�_last_index)�self�args�kwargs�r5�/usr/lib/python3.6/sandbox.py�__init__ssz_MagicFormatMapping.__init__cCsN|dkrD|j}|jd7_y
|j|Stk
r:YnXt|�}|j|S)N��)r1r/�LookupError�strr0)r2�key�idxr5r5r6�__getitem__xs
z_MagicFormatMapping.__getitem__cCs
t|j�S)N)�iterr0)r2r5r5r6�__iter__�sz_MagicFormatMapping.__iter__cCs
t|j�S)N)�lenr0)r2r5r5r6�__len__�sz_MagicFormatMapping.__len__N)�__name__�
__module__�__qualname__�__doc__r7r>r@rBr5r5r5r6r.ks
r.cGs$t|�}t|�tkr tdt��|S)zWA range that can't generate ranges with a length of more than
    MAX_RANGE items.
    z+range too big, maximum size for range is %d)�rangerA�	MAX_RANGE�
OverflowError)r3�rngr5r5r6�
safe_range�s
rKcCs
d|_|S)znMarks a function or method as unsafe.

    ::

        @unsafe
        def delete(self):
            pass
    T)�unsafe_callable)�fr5r5r6�unsafe�s	rNcCs�t|tj�r|tkr�dSn�t|tj�r<|tks6|tkr�dSn�t|t�rT|dkr�dSnzt|tjtjtj	f�rndSt|tj
�r�|tkr�dSnFttd�r�t|tj
�r�|tkr�dSn"ttd�r�t|tj�r�|tkr�dS|jd�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�FunctionType�UNSAFE_FUNCTION_ATTRIBUTES�
MethodType�UNSAFE_METHOD_ATTRIBUTES�type�CodeType�
TracebackType�	FrameType�
GeneratorType�UNSAFE_GENERATOR_ATTRIBUTES�hasattrrP�UNSAFE_COROUTINE_ATTRIBUTESrQ�!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES�
startswith)�obj�attrr5r5r6�is_internal_attribute�s,
recCs(x"tD]\}}t||�r||kSqWdS)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_specrS)rcrdZtypespecrNr5r5r6�modifies_known_mutable�s
rgc@s�eZdZdZdZejejejej	ej
ejejd�Z
ejejd�Ze�Ze�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�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**�%)rirjcCsdS)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 excuted 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
        Fr5)r2�operatorr5r5r6�intercept_unop"sz#SandboxedEnvironment.intercept_unopcOs8tj|f|�|�t|jd<|jj�|_|jj�|_dS)NrG)	rr7rK�globals�default_binop_table�copy�binop_table�default_unop_table�
unop_table)r2r3r4r5r5r6r74s
zSandboxedEnvironment.__init__cCs|jd�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.
        �_)rbre)r2rcrd�valuer5r5r6�is_safe_attribute:sz&SandboxedEnvironment.is_safe_attributecCst|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.
        rLFZalters_data)�getattr)r2rcr5r5r6�is_safe_callableCsz%SandboxedEnvironment.is_safe_callablecCs|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
        )rs)r2�contextrn�left�rightr5r5r6�
call_binopLszSandboxedEnvironment.call_binopcCs|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
        )ru)r2r{rn�argr5r5r6�	call_unopUszSandboxedEnvironment.call_unopcCs�y||Sttfk
r�t|t�r�yt|�}Wntk
rFYnZXyt||�}Wntk
rjYn6X|j|�}|dk	r�|S|j	|||�r�|S|j
||�SYnX|j||d�S)z(Subscribe an object from sandboxed code.N)rc�name)�	TypeErrorr:rSrr;�	Exceptionry�AttributeError�wrap_str_formatrx�unsafe_undefined�	undefined)r2rcZargumentrdrw�fmtr5r5r6�getitem^s&

zSandboxedEnvironment.getitemcCs�yt||�}Wn6tk
rDy||Sttfk
r>YnXYn6X|j|�}|dk	r\|S|j|||�rn|S|j||�S|j||d�S)z�Subscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        N)rcr�)ryr�r�r:r�rxr�r�)r2rc�	attributerwr�r5r5r6ryvs
zSandboxedEnvironment.getattrcCs|jd||jjf||td�S)z1Return an undefined object for unsafe attributes.z.access to attribute %r of %r object is unsafe.)r�rc�exc)r��	__class__rCr)r2rcr�r5r5r6r��s
z%SandboxedEnvironment.unsafe_undefinedcs�t|tjtjf�s|jdkr"dS|j�t�t�s6dSt���|jdk�t�t�rbt	|�j
d�}nt|�}|j�����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_mapN)�escapecsL�r<|rtd��t|�dkr0tdt|��d���|d}f}���||��S)Nz'format_map() takes no keyword argumentsr9z)format_map() takes exactly one argument (z given)r)r�rA)r3r4)�f_self�
is_format_map�str_type�vformatr5r6�wrapper�sz5SandboxedEnvironment.wrap_str_format.<locals>.wrapper)r�r�)rSrTrW�BuiltinMethodTyperC�__self__r;rYr�SandboxedEscapeFormatterr��SandboxedFormatterr�r)r2rwZ	formatterr�r5)r�r�r�r�r6r��s




z$SandboxedEnvironment.wrap_str_formatcOs*|j|�std|f��|j|f|�|�S)z#Call an object from sandboxed code.z%r is not safely callable)rzr�call)Z_SandboxedEnvironment__selfZ_SandboxedEnvironment__contextZ_SandboxedEnvironment__objr3r4r5r5r6r��s
zSandboxedEnvironment.callN)rCrDrErFZ	sandboxedrnr�sub�mul�truediv�floordiv�pow�modrq�pos�negrt�	frozensetZintercepted_binopsZintercepted_unopsror7rxrzr~r�r�ryr�r�r�r5r5r5r6rh�s0	

				$rhc@seZdZdZdd�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.
    cCs tj||||�sdSt||�S)NF)rhrxrg)r2rcrdrwr5r5r6rx�sz/ImmutableSandboxedEnvironment.is_safe_attributeN)rCrDrErFrxr5r5r5r6r��sr�)�formatter_field_name_splitcCs|j�S)N)Z_formatter_field_name_split)�
field_namer5r5r6r��sr�c@seZdZdd�Zdd�ZdS)�SandboxedFormatterMixincCs
||_dS)N)�_env)r2�envr5r5r6r7�sz SandboxedFormatterMixin.__init__c	CsVt|�\}}|j|||�}x2|D]*\}}|r<|jj||�}q |jj||�}q W||fS)N)r�Z	get_valuer�ryr�)	r2r�r3r4�first�restrcZis_attr�ir5r5r6�	get_field�sz!SandboxedFormatterMixin.get_fieldN)rCrDrEr7r�r5r5r5r6r��sr�c@seZdZdd�ZdS)r�cCstj||�tj|�dS)N)r�r7r
)r2r�r5r5r6r7�szSandboxedFormatter.__init__N)rCrDrEr7r5r5r5r6r��sr�c@seZdZdd�ZdS)r�cCstj||�tj||�dS)N)r�r7r	)r2r�r�r5r5r6r7�sz!SandboxedEscapeFormatter.__init__N)rCrDrEr7r5r5r5r6r��sr�)<rFrTrn�collectionsr�	functoolsrZjinja2.environmentrZjinja2.exceptionsrZjinja2._compatrrZjinja2.utilsrZ
markupsafer	�stringr
rH�setrVrXr^r`ra�warnings�filterwarnings�DeprecationWarningrZ_mutable_set_types�dictZ_mutable_mapping_types�listZ_mutable_sequence_typesrrr�ImportErrorZsetsrrrrr�rfr.rKrNrergrhr�Z_stringr��objectr�r�r�r5r5r5r6�<module>s�





$_


Youez - 2016 - github.com/yon3zu
LinuXploit