File "sandbox.cpython-37.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/sandbox.cpython-37.pyc
File size: 11.52 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

B

:`9@s(UdZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
lmZd	dlmZd	dlmZd	d
lmZejdejdejfdZdZeZejeed<eZ ejeed<ddhZ!ddhZ"ddhZ#ej$e%ddddddd d!gfej&e%ddd"d#d!gfej'e%d$d%d&d'd(dgfe	e%d$d)dd(d*dd+dd,g	ffZ(ej)ej)ej*ej+efdfed-<ejej,ed.d/d0Z-e.e/d1d2d3Z0eed4d5d6Z1ejee2d7d8d9Z3ejee2d7d:d;Z4Gd<d=d=eZ5Gd>d?d?e5Z6Gd@dAdAeZ7GdBdCdCe7e
Z8dS)DzA 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)	UndefinedF.)boundiUNSAFE_FUNCTION_ATTRIBUTESUNSAFE_METHOD_ATTRIBUTESgi_framegi_codecr_framecr_codeag_codeag_frameaddcleardifference_updatediscardpopremovesymmetric_difference_updateupdatepopitem
setdefaultappendreverseinsertsortextend
appendleft
extendleftpopleftrotate
_mutable_spec)callablereturncCs8t|tjtjfr|jdkr dS|j}t|tr4|SdS)N)format
format_map)
isinstancetypes
MethodTypeBuiltinMethodType__name____self__str)r+objr7?/opt/alt/python37/lib/python3.7/site-packages/jinja2/sandbox.pyinspect_format_methodSs

r9)argsr,cGs(t|}t|tkr$tdtd|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).)rangelen	MAX_RANGE
OverflowError)r:rngr7r7r8
safe_rangeas
r@)fr,cCs
d|_|S)zMarks a function or method as unsafe.

    .. code-block: python

        @unsafe
        def delete(self):
            pass
    T)unsafe_callable)rAr7r7r8unsafeps	rC)r6attrr,cCst|tjr|tkrdSnt|tjr<|tks6|tkrdSnt|trT|dkrdSnzt|tjtjtj	frndSt|tj
r|tkrdSnFttdrt|tj
r|tkrdSn"ttdrt|tjr|tkrdS|dS)aTest 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
    Tmro
CoroutineTypeAsyncGeneratorType__)r/r0FunctionTyperr1rtypeCodeType
TracebackType	FrameType
GeneratorTypeUNSAFE_GENERATOR_ATTRIBUTEShasattrrFUNSAFE_COROUTINE_ATTRIBUTESrG!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES
startswith)r6rDr7r7r8is_internal_attribute}s,

rTcCs(x"tD]\}}t||r||kSqWdS)aThis 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/)r6rDZtypespecrCr7r7r8modifies_known_mutables
rUcseZdZUdZdZejejejej	ej
ejejdZ
ejeejejejgejffed<ejejdZejeejejgejffed<eZejeed<eZejeed<ejejd	d
fddZejeejed
ddZejedddZeeejejejdddZ eeejejdddZ!ejej"eejfej"eje#fdddZ$ejeej"eje#fdddZ%ejee#ddd Z&d(eej'ejd!fejeejfej(ejed"d#d$Z)eejejejejd%d&d'Z*Z+S))SandboxedEnvironmentaThe 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)rWrXdefault_unop_tableintercepted_binopsintercepted_unopsN)r:kwargsr,cs4tj||t|jd<|j|_|j|_dS)Nr;)	super__init__r@globalsr\copybinop_tabler]
unop_table)selfr:r`)	__class__r7r8rbs
zSandboxedEnvironment.__init__)r6rDvaluer,cCs|dpt||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.
        _)rSrT)rgr6rDrir7r7r8is_safe_attributesz&SandboxedEnvironment.is_safe_attribute)r6r,cCst|ddpt|ddS)zCheck 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``.
        rBFZalters_data)getattr)rgr6r7r7r8is_safe_callablesz%SandboxedEnvironment.is_safe_callable)contextoperatorleftrightr,cCs|j|||S)zFor 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
        )re)rgrnrorprqr7r7r8
call_binops	zSandboxedEnvironment.call_binop)rnroargr,cCs|j||S)zFor 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
        )rf)rgrnrorsr7r7r8	call_unop!szSandboxedEnvironment.call_unop)r6argumentr,cCsy||Sttfk
rt|tryt|}Wntk
rFYnDXyt||}Wntk
rjYn X||||r~|S|||SYnX|j	||dS)z(Subscribe an object from sandboxed code.)r6name)
	TypeErrorLookupErrorr/r5	ExceptionrlAttributeErrorrkunsafe_undefined	undefined)rgr6rurDrir7r7r8getitem*s 
zSandboxedEnvironment.getitem)r6	attributer,cCsryt||}Wn6tk
rDy||Sttfk
r>YnXYn X||||rX|S|||S|j||dS)zSubscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        )r6rv)rlrzrwrxrkr{r|)rgr6r~rir7r7r8rlAszSandboxedEnvironment.getattrcCs&|jd|dt|jd||tdS)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)rvr6exc)r|rJr3r
)rgr6r~r7r7r8r{Rs
z%SandboxedEnvironment.unsafe_undefined.)sr:r`format_funcr,cCst|trt||jd}nt|}|dk	rl|jdkrlt|dksD|r`tdt||dk	d|d}d}||||}t	||S)	zIf a format call is detected, then this is routed through this
        method so that our safety sandbox can be used for it.
        )escapeNr.rz(format_map() takes exactly one argument z givenrr7)
r/rSandboxedEscapeFormatterrSandboxedFormatterr3r<rwvformatrJ)rgrr:r`r	formatterrvr7r7r8
format_string\s
z"SandboxedEnvironment.format_string)_SandboxedEnvironment__context_SandboxedEnvironment__objr:r`r,cOsJt|}|dk	r |||||S||s8t|d|j|f||S)z#Call an object from sandboxed code.Nz is not safely callable)r9rrmr
call)Z_SandboxedEnvironment__selfrrr:r`fmtr7r7r8rys
zSandboxedEnvironment.call)N),r3
__module____qualname____doc__Z	sandboxedrorsubmultruedivfloordivpowmodr\tDictr5CallableAny__annotations__posnegr]	frozensetr^	FrozenSetr_rbboolrkrmrrrrtUnionrr}rlr{TupleOptionalrr
__classcell__r7r7)rhr8rVs<
	0,		
 *rVcs0eZdZdZejeejedfddZZ	S)ImmutableSandboxedEnvironmentzWorks 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.
    )r6rDrir,cs t|||sdSt||S)NF)rarkrU)rgr6rDri)rhr7r8rksz/ImmutableSandboxedEnvironment.is_safe_attribute)
r3rrrrrr5rrkrr7r7)rhr8rsrcs\eZdZeejddfddZeejejej	eejfej
ejefdddZZS)rN)envr`r,cs||_tjf|dS)N)_envrarb)rgrr`)rhr7r8rbszSandboxedFormatter.__init__)
field_namer:r`r,c	CsVt|\}}||||}x2|D]*\}}|r<|j||}q |j||}q W||fS)N)r	get_valuerrlr})	rgrr:r`firstrestr6is_attrir7r7r8	get_fieldszSandboxedFormatter.get_field)
r3rrr	rrrbr5SequenceMappingrrrr7r7)rhr8rsrc@seZdZdS)rN)r3rrr7r7r7r8rsr)9rror0typingr_stringrcollectionsrrstringrZ
markupsaferrenvironmentr	
exceptionsr
ZruntimerrTypeVarrrr
r=setrSetr5rrrOrQrR
MutableSetrMutableMappingMutableSequencer*rTyperrr9intr;r@rCrrTrUrVrrrr7r7r7r8<module>sn0
%R