/usr/local/lib/python3.6/site-packages/jinja2/__pycache__
NameSizeModeActions
async_utils.cpython-36.pyc24350644editdlrm
bccache.cpython-36.pyc130970644editdlrm
compiler.cpython-36.pyc543690644editdlrm
constants.cpython-36.pyc14960644editdlrm
debug.cpython-36.pyc53440644editdlrm
defaults.cpython-36.pyc12410644editdlrm
environment.cpython-36.pyc523970644editdlrm
exceptions.cpython-36.pyc54980644editdlrm
ext.cpython-36.pyc262740644editdlrm
filters.cpython-36.pyc497540644editdlrm
idtracking.cpython-36.pyc111250644editdlrm
lexer.cpython-36.pyc199830644editdlrm
loaders.cpython-36.pyc202170644editdlrm
meta.cpython-36.pyc37460644editdlrm
nativetypes.cpython-36.pyc48050644editdlrm
nodes.cpython-36.pyc411930644editdlrm
optimizer.cpython-36.pyc18610644editdlrm
parser.cpython-36.pyc276350644editdlrm
runtime.cpython-36.pyc328630644editdlrm
sandbox.cpython-36.pyc116960644editdlrm
tests.cpython-36.pyc64820644editdlrm
utils.cpython-36.pyc272170644editdlrm
visitor.cpython-36.pyc38390644editdlrm
_identifier.cpython-36.pyc18500644editdlrm
__init__.cpython-36.pyc18650644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/jinja2/__pycache__/sandbox.cpython-36.pyc (11696B)
3 ^TBg9@sUdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddl mZd d lmZd d lmZd d lmZd d lmZejdejdejfdZdZeZejeeZejeddhZ ddhZ!ddhZ"ej#e$ddddddddgfej%e$ddd d!dgfej&e$d"d#d$d%d&dgfe e$d"d'dd&d(dd)dd*g ffZ'ej(ej(ej)ej*efdf'ejej+ed+d,d-Z,e-e.d.d/d0Z/eed1d2d3Z0ejee1d4d5d6Z2ejee1d4d7d8Z3Gd9d:d:eZ4Gd;d<dd>e Z6Gd?d@d@e6e Z7dS)AzA 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.)Zboundigi_framegi_codecr_framecr_codeag_codeag_frameaddcleardifference_updatediscardpopremovesymmetric_difference_updateupdatepopitem setdefaultappendreverseinsertsortextend appendleft extendleftpopleftrotate)callablereturncCs:t|tjtjf s|jdkr"dS|j}t|tr6|SdS)Nformat format_map)r)r*) isinstancetypes MethodTypeBuiltinMethodType__name____self__str)r'objr30/tmp/pip-build-0s3hx122/Jinja2/jinja2/sandbox.pyinspect_format_methodSs  r5)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)r6rngr3r3r4 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)r=r3r3r4unsafeps r?)r2attrr(cCst|tjr|tkrdSnt|tjr<|tks6|tkrdSnt|trT|dkrdSnzt|tjtjtj frndSt|tj r|t krdSnFt tdrt|tj r|tkrdSn"t tdrt|tjr|tkrdS|jdS)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+r, FunctionTypeUNSAFE_FUNCTION_ATTRIBUTESr-UNSAFE_METHOD_ATTRIBUTEStypeCodeType TracebackType FrameType GeneratorTypeUNSAFE_GENERATOR_ATTRIBUTEShasattrrBUNSAFE_COROUTINE_ATTRIBUTESrC!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES startswith)r2r@r3r3r4is_internal_attribute}s,      rRcCs(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) _mutable_specr+)r2r@Ztypespecr?r3r3r4modifies_known_mutables  rTcseZdZUdZdZejejejej ej ej ej dZ ejeejejejgejff ejejdZejeejejgejffeZejeeZejeejejddfdd Zejeejed d d Zejed d dZeeejejejdddZeeejejdddZ ejej!eejfej!eje"fdddZ#ejeej!eje"fdddZ$ejee"dddZ%d$eej&ejdfejeejfej'ejeddd 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**%)rVrWN)r6kwargsr(cs4tj||t|jd<|jj|_|jj|_dS)Nr7) super__init__r<globalsdefault_binop_tablecopy binop_tabledefault_unop_table unop_table)selfr6r[) __class__r3r4r]s  zSandboxedEnvironment.__init__)r2r@valuer(cCs|jdpt|| 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. _)rQrR)rdr2r@rfr3r3r4is_safe_attributesz&SandboxedEnvironment.is_safe_attribute)r2r(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``. r>FZ alters_data)getattr)rdr2r3r3r4is_safe_callable sz%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 )ra)rdrkrlrmrnr3r3r4 call_binops zSandboxedEnvironment.call_binop)rkrlargr(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 )rc)rdrkrlrpr3r3r4 call_unop!szSandboxedEnvironment.call_unop)r2argumentr(cCsy||Sttfk rt|try t|}Wntk rFYnDXyt||}Wntk rjYn X|j|||r~|S|j||SYnX|j ||dS)z(Subscribe an object from sandboxed code.)r2name) TypeError LookupErrorr+r1 ExceptionriAttributeErrorrhunsafe_undefined undefined)rdr2rrr@rfr3r3r4getitem*s   zSandboxedEnvironment.getitem)r2 attributer(cCsryt||}Wn6tk rDy||Sttfk r>YnXYn X|j|||rX|S|j||S|j||dS)zSubscribe an object from sandboxed code and prefer the attribute. The attribute passed *must* be a bytestring. )r2rs)rirwrtrurhrxry)rdr2r{rfr3r3r4riAs  zSandboxedEnvironment.getattrcCs&|jd|dt|jd||tdS)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)rsr2exc)ryrHr/r )rdr2r{r3r3r4rxRs z%SandboxedEnvironment.unsafe_undefined.)sr6r[ format_funcr(cCst|trt||jd}nt|}|dk rl|jdkrlt|dksD|r`tdt||dk d|d}f}|j|||}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 givenr) r+rSandboxedEscapeFormatterrSandboxedFormatterr/r8rtvformatrH)rdr}r6r[r~ formatterrvr3r3r4 format_string\s z"SandboxedEnvironment.format_string)_SandboxedEnvironment__context_SandboxedEnvironment__objr6r[r(cOsJt|}|dk r |j||||S|j|s8t|d|j|f||S)z#Call an object from sandboxed code.Nz is not safely callable)r5rrjr call)Z_SandboxedEnvironment__selfrrr6r[fmtr3r3r4rys  zSandboxedEnvironment.call)N)+r/ __module__ __qualname____doc__Z sandboxedrlrsubmultruedivfloordivpowmodr_tDictr1CallableAnyposnegrb frozensetZintercepted_binops FrozenSetZintercepted_unopsr]boolrhrjr rorqUnionr rzrirxTupleOptionalrr __classcell__r3r3)rer4rUs< ,(     *rUcs0eZdZdZejeejedfdd 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. )r2r@rfr(cs tj|||sdSt|| S)NF)r\rhrT)rdr2r@rf)rer3r4rhsz/ImmutableSandboxedEnvironment.is_safe_attribute) r/rrrrrr1rrhrr3r3)rer4rsrcs\eZdZeejddfdd Zeejejej eejfej ejefdddZ Z S)rN)envr[r(c s||_tjf|dS)N)_envr\r])rdrr[)rer3r4r]szSandboxedFormatter.__init__) field_namer6r[r(c CsVt|\}}|j|||}x2|D]*\}}|r<|jj||}q |jj||}q W||fS)N)r get_valuerrirz) rdrr6r[firstrestr2is_attrir3r3r4 get_fields zSandboxedFormatter.get_field) r/rrr rrr]r1SequenceMappingrrrr3r3)rer4rsrc@s eZdZdS)rN)r/rrr3r3r3r4rsr)8rrlr,Ztypingr_stringr collectionsrrstringrZ markupsaferr environmentr exceptionsr Zruntimer r ZTypeVarrrr r9setrFSetr1rGrMrOrP MutableSetrMutableMappingMutableSequencerSrTyperrr5intr7r<r?rrRrTrUrrrr3r3r3r4sn          , %R