?QgBRdZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddl m Z dd l m Z dd l mZdd l mZdd lmZdd lmZdZe rhdZn eZhdZddhZddhZddhZejddeeefZefZ e!fZ" ddl#m#Z#m$Z$ddl%m%Z%e e#e$fz Z ee%fz Zn #e&$rYnwxYw ddl'm(Z(ee(fz Zn #e&$rYnwxYwee j)fz Ze e j*fz Z e"e j+fz Z"ee,gdfe e,gdfe"e,gdfee,gd ffZ-Gd!d"e j.Z/d#Z0d$Z1d%Z2d&Z3d'Z4Gd(d)eZ5Gd*d+e5Z6 dd,l7m8Z8n#e&$rd-Z8YnwxYwGd.d/e9Z:Gd0d1e:eZ;Gd2d3e:e Z func_code func_dict func_closure func_globals func_defaults>im_funcim_selfim_classgi_framegi_codecr_framecr_codeag_codeag_frameignorezthe sets module)module)UserDict DictMixin)UserList)Set)addcleardifference_updatediscardpopremovesymmetric_difference_updateupdate)r#r&popitem setdefaultr))appendreverseinsertsortextendr') r, appendleftr#r0 extendleftr&popleftr'rotatec*eZdZdZdZdZdZdZdS)_MagicFormatMappingzThis 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. c0||_||_d|_dS)Nr)_args_kwargs _last_indexselfargskwargss n/builddir/build/BUILD/imunify360-venv-2.5.0/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/sandbox.py__init__z_MagicFormatMapping.__init__s  c|dkrD|j}|xjdz c_ |j|S#t$rYnwxYwt|}|j|S)Nr)r:r8 LookupErrorstrr9)r<keyidxs r? __getitem__z_MagicFormatMapping.__getitem__sp "99"C    !   z#&    c((C|C  s , 99c*t|jSN)iterr9r<s r?__iter__z_MagicFormatMapping.__iter__sDL!!!rAc*t|jSrJ)lenr9rLs r?__len__z_MagicFormatMapping.__len__s4<   rAN)__name__ __module__ __qualname____doc__r@rHrMrPrAr?r6r6}sZ ! ! !"""!!!!!rAr6ct|tjtjfr |jdvrdS|j}t|t r|SdS)N)format format_map) isinstancetypes MethodTypeBuiltinMethodTyperQ__self__r )callableobjs r?inspect_format_methodr`sa 5#U%<=    ": : :t  C#|$$ rAcvt|}t|tkrtdtz|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).)r rO MAX_RANGE OverflowError)r=rngs r? safe_rangeresE d C 3xx) !* +   JrAcd|_|S)znMarks a function or method as unsafe. :: @unsafe def delete(self): pass T)unsafe_callable)fs r?unsaferisA HrAct|tjr |tvrdSnt|tjr|tvs |t vrdSnt|t r |dkrdSnt|tjtjtj frdSt|tj r |tvrdSnuttdr&t|tj r |tvrdSn:ttdr%t|tjr |t vrdS|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__)rYrZ FunctionTypeUNSAFE_FUNCTION_ATTRIBUTESr[UNSAFE_METHOD_ATTRIBUTEStypeCodeType TracebackType FrameType GeneratorTypeUNSAFE_GENERATOR_ATTRIBUTEShasattrrlUNSAFE_COROUTINE_ATTRIBUTESrm!UNSAFE_ASYNC_GENERATOR_ATTRIBUTES startswith)r_attrs r?is_internal_attributer}sh#u)** - - -4 . C) * * - - -9Q1Q1Q42R C   5==4  C%.%*=uO P P t C, - -  . . .4 /  ( (ZU=P-Q-Q . . .4 / , - -* U %33 4 4 44 ??4  rAcLtD]\}}t||r||vcSdS)aThis 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_specrY)r_r|typespecris r?modifies_known_mutablersD,*""& c8 $ $ "6> ! ! ! " 5rAceZdZdZdZejejejej ej ej ej dZ ejejdZeZeZdZdZdZdZd Zd Zd Zd Zd ZddZdZdS)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**%)rrcdS)aCalled 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 executed 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 FrU)r<operators r?intercept_unopz#SandboxedEnvironment.intercept_unopAs urActj|g|Ri|t|jd<|j|_|j|_dS)Nrange) r r@reglobalsdefault_binop_tablecopy binop_tabledefault_unop_table unop_tabler;s r?r@zSandboxedEnvironment.__init__Rs`T3D333F333 * W388::16688rAcN|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. _)r{r}r<r_r|values r?is_safe_attributez&SandboxedEnvironment.is_safe_attributeXs)OOC((L,A#t,L,LMMrAcHt|ddpt|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. rgF alters_data)getattr)r<r_s r?is_safe_callablez%SandboxedEnvironment.is_safe_callableas0 C*E 2 2 Xgc=RW6X6X  rAc0|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 )r)r<contextrleftrights r? call_binopzSandboxedEnvironment.call_binopks*t)$666rAc.|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 )r)r<rrargs r? call_unopzSandboxedEnvironment.call_unopts)tx(---rAc ||S#ttf$rt|trt t |} t ||}||||r|cYS|||cYS#t$rYnwxYw#t$rYnwxYwYnwxYw| ||S)z(Subscribe an object from sandboxed code.r_name) TypeErrorrDrYr rErrunsafe_undefinedAttributeError Exception undefined)r<r_argumentr|rs r?getitemzSandboxedEnvironment.getitem}s Dx= ;' D D D(L11 D Dx==DD 'T 2 2 11#xGG)#(LLL#44S(CCCCC * !D  D~~#H~555sV &B'BBB',B' BB'BB' B!B' B!!B'&B'c t||}||||r|S|||S#t$r% ||cYS#tt f$rYnwxYwYnwxYw|||S)zSubscribe an object from sandboxed code and prefer the attribute. The attribute passed *must* be a bytestring. r)rrrrrrDr)r<r_ attributers r?rzSandboxedEnvironment.getattrs 9C++E%%c9e<<  ((i88 8    9~%%%{+      ~~#I~666s5A A0 AA0A*'A0)A**A0/A0c`|d|d|jjd||tS)z1Return an undefined object for unsafe attributes.zaccess to attribute z of z object is unsafe.)rr_exc)r __class__rQr )r<r_rs r?rz%SandboxedEnvironment.unsafe_undefinedsB~~~#,99cm.D.D.D F    rANct|trt||j}nt |}|N|jdkrCt |dks|r$tdt ||duzz|d}d}t||}| |||}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. NrXrz0format_map() takes exactly one argument %d givenr) rYrSandboxedEscapeFormatterescapeSandboxedFormatterrQrOrr6vformatrr)r<sr=r> format_func formatterrvs r? format_stringz"SandboxedEnvironment.format_strings a  10qx@@II*400I  "{';|'K'K4yyA~~~F4yyF$$679 !WFD$T622   q$ / /tAwwr{{rAct|}||||||S||st|d|j|g|Ri|S)z#Call an object from sandboxed code.Nz is not safely callable)r`rrr call)_SandboxedEnvironment__self_SandboxedEnvironment__context_SandboxedEnvironment__objr=r>fmts r?rzSandboxedEnvironment.calls~#E** ?''T65AA A&&u-- Huuu FGG Gy~e5d555f555rArJ)rQrRrSrT sandboxedrr"submultruedivfloordivpowmodrposnegr frozensetintercepted_binopsintercepted_unopsrr@rrrrrrrrrrUrAr?rrs6I \ \ \  l \ (|(,?? #" "999 NNN   777...666*777"   . 6 6 6 6 6rArceZdZdZdZdS)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. cbt||||sdSt|| S)NF)rrrrs r?rz/ImmutableSandboxedEnvironment.is_safe_attributes6#55dCuMM 5)#t4444rAN)rQrRrSrTrrUrAr?rrs- 55555rAr)formatter_field_name_splitc*|SrJ)_formatter_field_name_split) field_names r?rrs55777rAceZdZdZdZdS)SandboxedFormatterMixinc||_dSrJ)_envr<envs r?r@z SandboxedFormatterMixin.__init__s  rAct|\}}||||}|D]>\}}|r|j||}#|j||}?||fSrJ)r get_valuerrr) r<rr=r>firstrestr_is_attris r? get_fieldz!SandboxedFormatterMixin.get_fields0<< tnnUD&11 0 0JGQ 0i''Q//i''Q//EzrAN)rQrRrSr@rrUrAr?rrs2rArceZdZdZdS)rcdt||tj|dSrJ)rr@rrs r?r@zSandboxedFormatter.__init__s/((s3334     rANrQrRrSr@rUrAr?rrs#!!!!!rArceZdZdZdS)rcft||tj||dSrJ)rr@r)r<rrs r?r@z!SandboxedEscapeFormatter.__init__s1((s333 v.....rANrrUrAr?rrs#/////rAr)=rTrrZwarnings collectionsrstringr markupsaferr_compatrr r r environmentr exceptionsr rbrpsetrqrwryrzfilterwarningsDeprecationWarningrQ_mutable_set_typesdict_mutable_mapping_typeslist_mutable_sequence_typesrrr ImportErrorsetsr! MutableSetMutableMappingMutableSequencerrMappingr6r`rerir}rrr_stringrobjectrrrrUrAr?rs &&&&&&!!!!!!$$$$$$%%%%%%   '""""%>== *95 *95&/ $;! !3HV' ,,,,,,,,!!!!!!x338+%   D  3&    D s~''3-//C/11        EEEFF  MMMNN      1( V!!!!!#+!!!>       "!"!"!J8K6K6K6K6K6;K6K6K6\ 5 5 5 5 5$8 5 5 582222222888888888     f   !!!!!0)!!! /////6/////s6 B((B0/B04 CC C &E--E87E8