Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/jinja2/__pycache__/sandbox.cpython-37.pyc

168 lines
14 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<5D>B<00>@s<>dZddlZddlZddlmZddlmZddlmZm Z m
Z
m Z ddl m Z ddlmZddlmZd Ze r<>ed
d d d dg<05>Zne<13>Zedddg<03>Zeddg<02>Zeddg<02>Zeddg<02>ZddlZejddedd<1B>ddlmZefZefZ e!fZ"y6ddl#m#Z#m$Z$ddl%m%Z%e e#e$f7Z ee%f7ZWne&k
<EFBFBD>r@YnXyddl'm(Z(ee(f7ZWne&k
<EFBFBD>rrYnXee
j)f7Ze e
j*f7Z e"e
j+f7Z"ee,d d!d"d#d$d%d&d'g<08>fe e,d!d$d(d)d'g<05>fe"e,d*d+d,d-d.d%g<06>fee,d*d/d!d.d0d$d1d%d2g <09>ffZ-Gd3d4<64>d4e
j.<2E>Z/d5d6<64>Z0d7d8<64>Z1d9d:<3A>Z2d;d<<3C>Z3d=d><3E>Z4Gd?d@<40>d@e<04>Z5GdAdB<64>dBe5<65>Z6yddCl7m8Z8Wne&k
<EFBFBD>r<>dDdE<64>Z8YnXGdFdG<64>dGe9<65>Z:GdHdI<64>dIe:e<11>Z;GdJdK<64>dKe:e<0F>Z<dS)Laj
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.
<EFBFBD>N)<01> Environment)<01> SecurityError)<04> string_types<65>PY2<59>abc<62>
range_type)<01>Markup)<01>EscapeFormatter)<01> Formatteri<72><69>Z func_closure<72> func_codeZ func_dictZ func_defaultsZ func_globalsZim_classZim_funcZim_self<6C>gi_frame<6D>gi_code<64>cr_frame<6D>cr_code<64>ag_code<64>ag_frame<6D>ignorezthe sets modulezjinja2.sandbox)<01>module)<01>deque)<02>UserDict<63> DictMixin)<01>UserList)<01>Set<65>add<64>clear<61>difference_update<74>discard<72>pop<6F>remove<76>symmetric_difference_update<74>update<74>popitem<65>
setdefault<EFBFBD>append<6E>reverse<73>insert<72>sort<72>extend<6E>
appendleft<EFBFBD>
extendleft<EFBFBD>popleft<66>rotatec@s0eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
S) <0B>_MagicFormatMappingz<67>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)<03>_args<67>_kwargs<67> _last_index)<03>self<6C>args<67>kwargs<67>r3<00>2/tmp/pip-install-c3kgu56x/Jinja2/jinja2/sandbox.py<70>__init__psz_MagicFormatMapping.__init__cCsN|dkrD|j}|jd7_y
|j|Stk
r:YnXt|<02>}|j|S)N<><00>)r/r-<00> LookupError<6F>strr.)r0<00>key<65>idxr3r3r4<00> __getitem__us
z_MagicFormatMapping.__getitem__cCs
t|j<01>S)N)<02>iterr.)r0r3r3r4<00>__iter__<5F>sz_MagicFormatMapping.__iter__cCs
t|j<01>S)N)<02>lenr.)r0r3r3r4<00>__len__<5F>sz_MagicFormatMapping.__len__N)<08>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r5r<r>r@r3r3r3r4r,hs
 r,cCs8t|tjtjf<02>r|jdkr dS|j}t|t<06>r4|SdS)N)<02>format<61>
format_map)<07>
isinstance<EFBFBD>types<65>
MethodType<EFBFBD>BuiltinMethodTyperA<00>__self__r)<02>callable<6C>objr3r3r4<00>inspect_format_method<6F>s


rNcGs$t|<00>}t|<01>tkr tdt<00><01>|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).)rr?<00> MAX_RANGE<47> OverflowError)r1<00>rngr3r3r4<00>
safe_range<EFBFBD>s  rRcCs
d|_|S)znMarks a function or method as unsafe.
::
@unsafe
def delete(self):
pass
T)<01>unsafe_callable)<01>fr3r3r4<00>unsafe<66>s rUcCs<>t|tj<02>r|tkr<>dSn<>t|tj<04>r<|tks6|tkr<>dSn<>t|t<06>rT|dkr<>dSnzt|tjtjtj f<03>rndSt|tj
<EFBFBD>r<>|t kr<>dSnFt td<03>r<>t|tj <0A>r<>|tkr<>dSn"t td<04>r<>t|tj<0F>r<>|tkr<>dS|<01>d<05>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<72> CoroutineType<70>AsyncGeneratorType<70>__)rGrH<00> FunctionType<70>UNSAFE_FUNCTION_ATTRIBUTESrI<00>UNSAFE_METHOD_ATTRIBUTES<45>type<70>CodeType<70> TracebackType<70> FrameType<70> GeneratorType<70>UNSAFE_GENERATOR_ATTRIBUTES<45>hasattrrW<00>UNSAFE_COROUTINE_ATTRIBUTESrX<00>!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES<45>
startswith)rM<00>attrr3r3r4<00>is_internal_attribute<74>s,  
 rhcCs(x"tD]\}}t||<02>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)<02> _mutable_specrG)rMrgZtypespecrUr3r3r4<00>modifies_known_mutable<6C>s
 rjc@s<>eZdZdZdZejejejej ej
ej ej d<03>Z ejejd<04>Ze<11>Ze<11>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Zd d<0E>Zdd<10>Zdd<12>Zdd<14>Zdd<16>Zddd<19>Zdd<1B>ZdS)<1D>SandboxedEnvironmenta<74>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)<07>+<2B>-<2D>*<2A>/z//z**<2A>%)rlrmcCsdS)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
Fr3)r0<00>operatorr3r3r4<00>intercept_unop-sz#SandboxedEnvironment.intercept_unopcOs8tj|f|<01>|<02>t|jd<|j<04><05>|_|j<07><05>|_dS)N<>range) rr5rR<00>globals<6C>default_binop_table<6C>copy<70> binop_table<6C>default_unop_table<6C>
unop_table)r0r1r2r3r3r4r5?s
 zSandboxedEnvironment.__init__cCs|<02>d<01>pt||<02> 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.
<20>_)rfrh)r0rMrg<00>valuer3r3r4<00>is_safe_attributeEsz&SandboxedEnvironment.is_safe_attributecCst|dd<02>pt|dd<02> 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.
rSFZ alters_data)<01>getattr)r0rMr3r3r4<00>is_safe_callableNs z%SandboxedEnvironment.is_safe_callablecCs|j|||<04>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
)rw)r0<00>contextrq<00>left<66>rightr3r3r4<00>
call_binopWszSandboxedEnvironment.call_binopcCs|j||<03>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
)ry)r0rrq<00>argr3r3r4<00> call_unop`szSandboxedEnvironment.call_unopc Cs<>y||Sttfk
r<EFBFBD>t|t<03>r<>y t|<02>}Wntk
rFYnDXyt||<03>}Wntk
rjYn X|<00>|||<04>r~|S|<00> ||<02>SYnX|j
||d<01>S)z(Subscribe an object from sandboxed code.)rM<00>name) <0B> TypeErrorr8rGrr9<00> Exceptionr}<00>AttributeErrorr|<00>unsafe_undefined<65> undefined)r0rM<00>argumentrgr{r3r3r4<00>getitemis 
 zSandboxedEnvironment.getitemc Csryt||<02>}Wn6tk
rDy||Sttfk
r>YnXYn X|<00>|||<03>rX|S|<00>||<02>S|j||d<01>S)z<>Subscribe an object from sandboxed code and prefer the
attribute. The attribute passed *must* be a bytestring.
)rMr<>)r}r<>r<>r8r|r<>r<>)r0rM<00> attributer{r3r3r4r}~s  zSandboxedEnvironment.getattrcCs|jd||jjf||td<02>S)z1Return an undefined object for unsafe attributes.z.access to attribute %r of %r object is unsafe.)r<>rM<00>exc)r<><00> __class__rAr)r0rMr<>r3r3r4r<><00>s
z%SandboxedEnvironment.unsafe_undefinedNcCs<>t|t<01>rt||j<03>}nt|<00>}|dk rf|jdkrft|<02>dksB|rZtdt|<02>|dk <00><01>|d}d}t||<03>}|<05> |||<03>}t
|<01>|<06>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.
NrFr7z0format_map() takes exactly one argument %d givenr) rGr<00>SandboxedEscapeFormatter<65>escape<70>SandboxedFormatterrAr?r<>r,<00>vformatr])r0<00>sr1r2Z format_func<6E> formatter<65>rvr3r3r4<00> format_string<6E>s

z"SandboxedEnvironment.format_stringcOsJt|<02>}|dk r |<00>||||<02>S|<00>|<02>s8td|f<00><01>|j|f|<03>|<04>S)z#Call an object from sandboxed code.Nz%r is not safely callable)rNr<>r~r<00>call)Z_SandboxedEnvironment__selfZ_SandboxedEnvironment__contextZ_SandboxedEnvironment__objr1r2<00>fmtr3r3r4r<><00>s 
zSandboxedEnvironment.call)N)rArBrCrDZ sandboxedrqr<00>sub<75>mul<75>truediv<69>floordiv<69>pow<6F>modru<00>pos<6F>negrx<00> frozensetZintercepted_binopsZintercepted_unopsrrr5r|r~r<>r<>r<>r}r<>r<>r<>r3r3r3r4rk<00>s0 

    
rkc@seZdZdZdd<03>ZdS)<05>ImmutableSandboxedEnvironmentz<74>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 t<00>||||<03>sdSt||<02> S)NF)rkr|rj)r0rMrgr{r3r3r4r|<00>sz/ImmutableSandboxedEnvironment.is_safe_attributeN)rArBrCrDr|r3r3r3r4r<><00>sr<>)<01>formatter_field_name_splitcCs|<00><00>S)N)Z_formatter_field_name_split)<01>
field_namer3r3r4r<><00>sr<>c@seZdZdd<02>Zdd<04>ZdS)<06>SandboxedFormatterMixincCs
||_dS)N)<01>_env)r0<00>envr3r3r4r5<00>sz SandboxedFormatterMixin.__init__c CsVt|<01>\}}|<00>|||<03>}x2|D]*\}}|r<|j<02>||<08>}q |j<02>||<08>}q W||fS)N)r<><00> get_valuer<65>r}r<>) r0r<>r1r2<00>first<73>restrM<00>is_attr<74>ir3r3r4<00> get_field<6C>s z!SandboxedFormatterMixin.get_fieldN)rArBrCr5r<>r3r3r3r4r<><00>sr<>c@seZdZdd<02>ZdS)r<>cCst<00>||<01>t<02>|<00>dS)N)r<>r5r
)r0r<>r3r3r4r5<00>s zSandboxedFormatter.__init__N)rArBrCr5r3r3r3r4r<><00>sr<>c@seZdZdd<02>ZdS)r<>cCst<00>||<01>t<02>||<02>dS)N)r<>r5r )r0r<>r<>r3r3r4r5<00>s z!SandboxedEscapeFormatter.__init__N)rArBrCr5r3r3r3r4r<><00>sr<>)=rDrHrqZjinja2.environmentrZjinja2.exceptionsrZjinja2._compatrrrrZ jinja2.utilsrZ
markupsafer <00>stringr
rO<00>setr[r\rbrdre<00>warnings<67>filterwarnings<67>DeprecationWarning<6E> collectionsrZ_mutable_set_types<65>dictZ_mutable_mapping_types<65>listZ_mutable_sequence_typesrrr<00> ImportErrorZsetsr<00>
MutableSet<EFBFBD>MutableMapping<6E>MutableSequencer<65>ri<00>Mappingr,rNrRrUrhrjrkr<><00>_stringr<67><00>objectr<74>r<>r<>r3r3r3r4<00><module>s<>         
        
 
 $O