m $Ec@sddd!ZdkZdkZdklZlZdklZdkl Z dk l Z dk l Z d klZlZd klZgZeiZeied Zd Zeed Z/e/ed?dlZ?dmZ@dnZAdoZBdpZCdqZDdrZEdsZFdtZGduZHdvZIhdQe><dSe?<dUe@<dWeA<d[eB<d]eC<d_eD<daeE<dceF<deeG<dgeH<dieI|tjot|t|Snt|t||SdS(N(tinitialRtreduceRZR%R[(RZR[Rb((Rtguarded_reduces RccGs1|o|g}|i|ntt|S(N(R.titemRAtmaxR%(ReR.((Rt guarded_maxs RfcGs1|o|g}|i|ntt|S(N(R.ReRAtminR%(ReR.((Rt guarded_mins RhcGsLg}x6tt|D]"}t||}|i|qWt||S(N( t safe_seqstrangeRTtseqstseqnoRR[R?tmapRZ(RZRlR[RmRj((Rt guarded_maps Rnc CsN|id}|d} ti}tdd||||}|dj o|djo f}nyx|D]}|djot d|nt||d}|djo"t|||g|||}n|||||p tqnqnWt||||SWq=tj o} t d||| fq=Xnt d|dS(Nt.it*s!"from %s import *" is not alloweds,import of "%s" from "%s" is unauthorized. %ssimport of "%s" is unauthorized(tmnametsplitt mnamepartst firstmnameRRt load_moduleRtglobalstlocalstmoduletfromlistRt ImportErrorRRR t __import__twhy( RrRwRxRzRRtRRyRRuR}((Rtguarded_imports,       R|tGuardedListTypecBs7tZdZeidjoddedZnRS(NcOs t||S(N(RFRUtkwargs(R;RUR((Rt__call__"siicCsti|dddddtS(NtcmpRRD(RFtsortedtiterableRtFalse(R;RRRRD((RR&s(ii(R9RPRtsyst version_infoRRR(((RR!s RFtGuardedDictTypecBstZdZddZRS(NcOs t||S(N(R<RUR(R;RUR((RR+scCsti||S(N(R<R+tSR(R;RR((RR+.s(R9RPRRR+(((RR*s R<cCsttt|S(N(RRt enumerateR%R[(R[((Rtguarded_enumerate2sRcCstt||S(N(tsumR%tsequenceR(RR((Rt guarded_sum6sRc Csti}x|o|id}|djo |}nd||f}|i|d}|djo+t |||}|djodSqn t ||o||||| odSn|}q W|S(Nis%s.%s(RtmodulesRtR3tnextnameRrRR,t nextmodulet secureModuleRwRxRyR( RyRrRtRRwRxRRR((RRv:s"        cOst|||S(N(tbuiltin_guarded_applytfuncRUtkws(RRUR((Rt guarded_applyTsc Csdg}}x5|D]-}t||||i||d7}qWh}xA|iD]3\}}t||t||||||>=t __irshift__s&=t__iand__s^=t__ixor__s|=t__ior_cCs||7}|S(N(RYty(RYR((RRs cCs||8}|S(N(RYR(RYR((RRs cCs||9}|S(N(RYR(RYR((RRs cCs||:}|S(N(RYR(RYR((RRs cCs||}|S(N(RYR(RYR((RRs cCs||;}|S(N(RYR(RYR((RRs cCs||C}|S(N(RYR(RYR((RRs cCs||K}|S(N(RYR(RYR((RRs cCs||L}|S(N(RYR(RYR((RRs cCs||M}|S(N(RYR(RYR((RRs cCs||N}|S(N(RYR(RYR((RRs cCs||O}|S(N(RYR(RYR((Rt__ior__s cCs|t|t|oWt|t oFy |i}Wntj ot |}nXt d|i nt |||S(s{Do an inplace operation If the var has an inplace slot, then disallow the operation unless the var is a list. sCAugmented assignment to %s objects is not allowed in untrusted codeN(R tvart inplace_slotstopRVtvalid_inplace_typest __class__tclsRR t TypeErrorR9t inplace_opstexpr(RRRR((Rtprotected_inplacevars% t __builtins__t __metaclass__t_apply_t _getitem_t _getiter_t_print_t_write_t _inplacevar_(Pt __version__RtRestrictedPythontRestrictedPython.GuardsRtfull_write_guardtRestrictedPython.Utilitiestutility_builtinstRestrictedPython.EvaltRestrictionCapableEvaltSecurityManagementRt SecurityInfoRtSimpleObjectPoliciesRtContainerAssertionst zExceptionsR RR*R6RR R tsliceRRRR!R&R(R=R>RGRHRR"RRRSR%RRORaRdRgRiRoR~RRRRRvRRRRFtsetRt NameErrorRRRRRRRRRRRRRRRtPrintCollectort _safe_globalstget_safe_globalsRw(>RRR>RRRR~RRRORR RRRR"RRRRRgRdRRRoRHRvRRR(RGRRRRR=R&RRRR%R RRRRRRRiRRRRRSRRRRRRRR!Ra((Rt?s                  W                                     r Q