mf?ddlZddlZddlmZddlmZmZmZmZmZm Z m Z ddlZ ddl m Z mZmZmZmZddlmZerzddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlm Z ddlm!Z!m"Z"ee#efZ$eeee#efge e!e#ffZ%e e#e&fZ'er ddl(m)Z)m*Z*m+Z+eZ,nddl-m)Z)m*Z*m+Z+e#e.fZ,dZ/dZ0dZ1dZ2gZ3dZ4Gdde5Z6ddZ7dS)N)datetime)AnnotatedValuecapture_internal_exceptiondisable_capture_eventformat_timestamp json_dumps safe_repr strip_string) text_typePY2 string_types number_types iteritems)MYPY) timedelta) TracebackType)Any)Callable)ContextManager)Dict)List)Optional)Tuple)Type)Union)NotImplementedTypeEvent)MappingSequenceSeti@B zc:t|dSN)global_repr_processorsappend) processors L/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/serializer.pyadd_global_repr_processorr)Os!!),,,,,c*eZdZdZdZdZdZdZdS)Memo_ids_objsc"i|_g|_dSr$r-)selfs r(__init__z Memo.__init__Ws  r*c:|j||Sr$)r/r&r1objs r(memoizez Memo.memoize\s # r*c~|jd}t||jvrdS||jt|<dS)NTF)r/idr.r4s r( __enter__zMemo.__enter__as<jn c77di  4!$DIbgg 5r*c|jt|jddSr$)r.popr9r/)r1tyvaluetbs r(__exit__z Memo.__exit__js4 b))**D11111r*N)__name__ __module__ __qualname__ __slots__r2r6r:r@r*r(r,r,TsU!I  22222r*r,Fc  tgggfd fdfd d fd fd f d fd}tjd  |fi|}r t|tr d |d <t }r|d krt |d pg}|tj j z}||kr[t t|}|tz } | d kr/|||| r t|tr d |d <|tjd S#tjd wxYw)Ncttkr tdz }dt|i}n#t$ri}YnwxYw|ttkddi|dS)Nr8)len setdefaultr IndexErrorr&update)metasegmentnode meta_stackpaths r( _annotatezserialize.._annotate{s*ooT** s:23!"~0071C1CRHH       d # # #*ooT** 2!!"b))0066666sAA%% A43A4c d}|dkrddkrddkrdS|dvr2dd kr&ddkrd dkrd dkrdSn#t$rYd SwxYwd S)a By default non-serializable objects are going through safe_repr(). For certain places in the event (local vars) we want to repr() even things that are JSON-serializable to make their type more apparent. For example, it's useful to see the difference between a unicode-string and a bytestring when viewing a stacktrace. For container-types we still don't do anything different. Generally we just try to make the Sentry UI present exactly what a pretty-printed repr would look like. :returns: `True` if we are somewhere in frame variables, and `False` if we are in a position where we will never encounter frame variables when recursing (for example, we're in `event.extra`). `None` if we are not (yet) in frame variables, but might encounter them when recursing (e.g. we're in `event.exception`) r stacktracerHframesvarsT)threads exceptionvaluesNFrL)p0rRs r(_should_repr_stringsz'serialize.._should_repr_stringss( aB\!!d1g&9&9d1g>O>Ot...Gx''G|++Gx''Gv%%t   44 us&A"4A"" A0/A0c }|dvr|Sd}|dkrddkrdS|dkrddkr d dS|d krdSn#t$rYd SwxYwd S) z A databag is any value that we need to trim. :returns: Works like `_should_repr_strings()`. `True` for "yes", `False` for :"no", `None` for "maybe soon". )TNrrequestrHdataT breadcrumbsr[extraNFr^)rvr_r`rRs r( _is_databagzserialize.._is_databags %%''B\!! aBY47f#4#4t]""tAw(':':QtW}}t   44 us!AAA A A"!A"cj| | |5}|r?tcddd|*  t dzd=SS|||||cddd|*  t dzd=SS#1swxYwYn#t $rt tj|r0Y|+  t dzd=dSdSY|+  t dzd=dSdSwxYw |+  t dzd=dSdS#|)  t dzd=wxYw)NrH) is_databagshould_repr_stringsremaining_depthremaining_breadthz=) r&r6 CYCLE_MARKERr<rJ BaseExceptionrsysexc_info) r5rjrkrOrmrlresult_serialize_node_implmemorQrRs r(_serialize_nodez"serialize.._serialize_nodesj   KK  0c"" f('       &" s4yy1}//#,+)(;$3&7        &" s4yy1}//#'             &s|~~ 6 6 6 XW" s4yy1}///#"" s4yy1}///#"  &" s4yy1}///#"w" s4yy1}/////s]C B9 C1B9 C9B==CB=CF,E1F!FEF-F2cZt|trdi|j|j}|S)NrE) isinstancermetadatar>)r5rSs r(_flatten_annotatedz%serialize.._flatten_annotateds9 c> * *  I % % % % %)C r*c  | }| }|r |t}|r |t}|}|>|dkr8ddgg|r%tt|SdS|r8tr1|d}tD]$}|||}|t ur |cS%|t |ttfrP|s=t |tr7tj |stj |rt|S|St |tr-|stt|nt|St |t rt#t%|}i}d} t%|D]Y\} } |!| |krt'|n2t| } | | ||||dz nd|} | || <| dz } Z|St |t(st |t*t,frgg} t/|D]S\} } |!| |krt'|n,| | | ||||dz nd|T| S|rt|}nOt |t2r|d d }t |t6st|}rOt'd kr<dd kr0d dkr$t'||St|S)Nrz!limitx)rem)rtrl)rJrH)rOrkrjrlrmzutf-8replacerWspansr8 description)MAX_DATABAG_DEPTHMAX_DATABAG_BREADTHr r r%NotImplementedrwboolrfloatmathisinfisnanrr rrdictrrJserializable_str_typesr r enumerater&bytesdecoder )r5rjrkrlrmhintsr'rrrv_dictikvstr_krv_listrSryrhrur`rtrRsmart_transaction_trimmingspan_description_bytess r(rsz'serialize.._serialize_node_impls<  &"6"6"8"8   $J  0/1/O  4+3 3   %%  &?a+?+? IHc?+ , , , , H)),y~~*F*FGGG4  60 6!oFFE3 6 6 "3..//--f555550 ;*S4*>??;" 3&& ,0JsOO ?Cz# !~~% X & &; +$ *3//000s^^  W % %4 y~~&&CGA!#  1$0Q:K5K5KI#c((++++E!! #O!(;)&2%4a$7$7&7   "#QNC!788 Z #x> >  G!#  1$0Q:K5K5KI#c((++++E#O !,?#-*6)8!(;(;!*;       N  %C..CC#u%% 5jj)44c<00 %nn ' D QQ7""RM)) " ) )#c(( 3 3 3J!!,s"3"3444r*c2d}fd} dtt|dpg|D]\}}|dpd}t ||kr0|t ||z z} |dgt |||d< dd = t d zd =|d krn  t d zd =d S) a Modifies serialized_event in-place trying to remove excess_bytes from span descriptions. The original event is used read-only to access the span timestamps (represented as RFC3399-formatted strings in serialized_event). It uses heuristics to prioritize preserving the description of spans that might be the most interesting ones in terms of understanding and optimizing performance. r"c|\}} d|}tj}|dp|}|dp|}||z }|dpd}|t| fS)Nr~start_timestamp timestamprrI)rutcnowgetrJ) argsrserialized_spanspannowstartenddurationrevents r(+shortest_duration_longest_description_firstzcserialize.._truncate_span_descriptions..shortest_duration_longest_description_firsts!% A>!$D/##CHH.//63E((;''.3CU{H)--m<<BKs;///0 0r*r~)keyrrI) max_lengthNrHr)r&sortedrrrJextendr r<) serialized_eventr excess_bytes min_lengthrrrrryrQrRs ` r(_truncate_span_descriptionsz.serialize.._truncate_span_descriptionsssb  1 1 1 1 1 G &**7339r : :;     GAt((=117RK;:-- C ,,z9 9L KKM* + + +#5"4[Z@@@##D RSS 3t99q=??+q  !  s4yy1} ' ' 'r*Tr_metar~F)NNNNN) r,rsetrwrsumrJr sentry_sdkutilsMAX_STRING_LENGTHrMAX_EVENT_BYTES)rrkwargsrrgsum_span_description_bytes span_countdescriptions_budget_bytesoriginal_bytesrrSryrhrursr`rtrQrRrs ` @@@@@@@@@@r( serializerts 66D DJ 7 7 7 7 7 7$$$$$L>  "0"0"0"0"0"0"0"0"0H{5{5{5{5{5{5{5{5{5{5{5{5{5z4(4(4(4(4(4(4(ld###%) _U - -f - -  (*R.. ($Q-BwK%()?%@%@" % 4*Dq*H*HUYYw//5266J )3Z5E5W(W %*,EEE!$Z^^!4!4-? !##0/E<HHH"4jT&:&:4&0m7 !%((((!%((((s -CEE4)F)8rprrsentry_sdk.utilsrrrrrr r rsentry_sdk._compatr r r rrsentry_sdk._typesrrtypesrtypingrrrrrrrrrrrstrSpan ReprProcessorintSegment collectionsrrr rcollections.abcrrrrrnr%r)objectr,rrEr*r(rs TTTTTTTTTTTTTT""""""""""""######%%%%%%;;;;;;;; S>Dc4S>2E:Lc:Q4RRSMCHoG *3222222222) 7666666666"5\ --- 222226222@[)[)[)[)[)[)r*