
    gh                        S SK r S SKrS SKJr  S SKrS SKJrJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJrJr  S S	KJr  \(       a  S S
KJr  S SKJr  S SKJrJr   S SKr S SKJrJrJ r J!r!J"r"J#r#  S SK$J%r%J&r&J'r'J(r(J)r)   S SK*J+r+  Sr- " S S\5      r.S r/S r0S r1S r2S r3S r4S r5g! \ a    Sr NSf = f! \ a	    S SK,J+r+   N?f = f! \ a	    \" S5      ef = f)    N)wraps)DidNotEnableIntegration)_filter_headers)SentryAsgiMiddleware)should_send_default_pii)SOURCE_FOR_STYLE)capture_internal_exceptionsensure_integration_enabledevent_from_exception)TYPE_CHECKING)Any)Union)EventEventProcessor)has_request_contexthas_websocket_contextRequestQuartrequest	websocket)got_background_exceptiongot_request_exceptiongot_websocket_exceptionrequest_startedwebsocket_started)ScaffoldzQuart is not installed)endpointurlc                   @    \ rS rSrSrS\ 3rSrS	S jr\S 5       r	Sr
g)
QuartIntegration9   quartz
auto.http. c                 T    U[         ;  a  [        SU< S[         < S35      eXl        g )Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES
ValueErrortransaction_style)selfr)   s     `/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/integrations/quart.py__init__QuartIntegration.__init__?   s,    $<<$&>@  "3    c                  0   [         R                  " [        5        [        R                  " [        5        [        R                  " [
        5        [        R                  " [
        5        [        R                  " [
        5        [        5         [        5         g N)
r   connect_request_websocket_startedr   r   _capture_exceptionr   r   patch_asgi_apppatch_scaffold_route r.   r+   
setup_onceQuartIntegration.setup_onceH   s[     	 :;!!"<= (();<%%&89''(:;r.   )r)   N)r   )__name__
__module____qualname____firstlineno__
identifieroriginr)   r,   staticmethodr7   __static_attributes__r6   r.   r+   r!   r!   9   s2    J*&F3 
 
r.   r!   c                  H   ^ [         R                  mU4S jn U [         l        g )Nc                    >^ #    [         R                  " 5       R                  [        5      c  T" T XU5      I S h  vN $ [	        UU 4S j[        R
                  SS9nU" XU5      I S h  vN $  N3 N7f)Nc                     > T" T/U Q70 UD6$ r0   r6   )akwold_appr*   s     r+   <lambda>Apatch_asgi_app.<locals>.sentry_patched_asgi_app.<locals>.<lambda>`   s    WT4A44r.      )span_originasgi_version)
sentry_sdk
get_clientget_integrationr!   r   r>   )r*   scopereceivesend
middlewarerF   s   `    r+   sentry_patched_asgi_app/patch_asgi_app.<locals>.sentry_patched_asgi_appZ   sh       "223CDL ut<<<)4(//


  555 = 6s!   7A3A/.A3*A1+A31A3)r   __call__)rS   rF   s    @r+   r4   r4   V   s    nnG
6 -ENr.   c                  H   ^ [         R                  mU4S jn U [         l        g )Nc                  &   >^ T" U 0 UD6mU4S jnU$ )Nc                    >^  [         R                  " T 5      (       aJ  [        R                  " T 5      (       d/  [	        T 5      [        [        T 5      U 4S j5       5       nT" U5      $ T" T 5      $ )Nc                    > [         R                  " 5       nUR                  b  UR                  R                  5         [         R                  " 5       nUR
                  b  UR
                  R                  5         T" U 0 UD6$ r0   )rL   get_current_scopetransactionupdate_active_threadget_isolation_scopeprofileupdate_active_thread_id)argskwargscurrent_scopesentry_scopeold_funcs       r+   _sentry_funcTpatch_scaffold_route.<locals>._sentry_route.<locals>.decorator.<locals>._sentry_funcx   sm     %/$@$@$BM$00<%11FFH#-#A#A#CL#++7$,,DDF#T4V44r.   )inspect
isfunctionasyncioiscoroutinefunctionr   r   r!   )rd   re   old_decorators   ` r+   	decorator>patch_scaffold_route.<locals>._sentry_route.<locals>.decoratorq   sl     !!(++G4O4O5 5 x+,<hG
5 H !
5 %\22 **r.   r6   )r`   ra   rl   rk   	old_routes      @r+   _sentry_route+patch_scaffold_route.<locals>._sentry_routem   s    !4262	+2 r.   )r   route)ro   rn   s    @r+   r5   r5   i   s    I> #HNr.   c                      UR                   R                  UR                   R                  S.nU R                  X1   [        U   S9  g ! [
         a     g f = f)N)r   r   )source)url_ruleruler   set_transaction_namer	   	Exception)rO   r)   r   name_for_styles       r+    _set_transaction_name_and_sourcery      sd    
##((((11
 	""-#$56 	# 	
  s   AA	 	
AAc                   #    [         R                  " 5       R                  [        5      nUc  g [	        5       (       a  [
        R                  " 5       n[        5       (       a  [        R                  " 5       n[        [         R                  " 5       UR                  W5        [         R                  " 5       n[        XU5      nUR                  U5        g 7fr0   )rL   rM   rN   r!   r   r   _get_current_objectr   r   ry   rZ   r)   r]   _make_request_event_processoradd_event_processor)appra   integrationrequest_websocketrO   evt_processors         r+   r2   r2      s     '')99:JKK#779%99; %$$&(E(EGX **,E1#+VM	m,s   CCc                    ^ U4S jnU$ )Nc                 x  > Tc  U $ [        5          U R                  S0 5      nTR                  US'   TR                  US'   TR                  US'   [        [        TR                  5      5      US'   [        5       (       a  STR                  S   0US'   [        U 5        S S S 5        U $ ! , (       d  f       U $ = f)	Nr   r   query_stringmethodheadersREMOTE_ADDRr   env)r
   
setdefaultr   r   r   r   dictr   r   access_route_add_user_to_event)eventhintrequest_infor   s      r+   inner,_make_request_event_processor.<locals>.inner   s    
 ?L(* !++Ir:L")++L+2+?+?L(%,^^L"&5d7??6K&LL#&(('4g6J6J16M&NU#"5) +  +* s   BB**
B9r6   )r~   r   r   r   s    `  r+   r|   r|      s    0 Lr.   c                    #    [         R                  " 5       R                  [        5      nUc  g [	        U[         R                  " 5       R
                  SSS.S9u  pE[         R                  " XES9  g 7f)Nr#   F)typehandled)client_options	mechanism)r   )rL   rM   rN   r!   r   optionscapture_event)sender	exceptionra   r   r   r   s         r+   r3   r3      sa     '')99:JKK&!,,.66"u5KE U.s   A/A1c                     [         c  g [         R                  nUc  g [        5          U R                  S0 5      n[         R                  R                  US'   S S S 5        g ! , (       d  f       g = f)Nuserid)
quart_authcurrent_userr
   r   _auth_id)r   r   	user_infos      r+   r   r      sW    ""D|	$	&$$VR0	$11::	$ 
'	&	&s   0A  
A.)6ri   rg   	functoolsr   rL   sentry_sdk.integrationsr   r   $sentry_sdk.integrations._wsgi_commonr   sentry_sdk.integrations.asgir   sentry_sdk.scoper   sentry_sdk.tracingr	   sentry_sdk.utilsr
   r   r   typingr   r   r   sentry_sdk._typesr   r   r   ImportErrorr#   r   r   r   r   r   r   quart.signalsr   r   r   r   r   quart.scaffoldr   flask.sansio.scaffoldr'   r!   r4   r5   ry   r2   r|   r3   r   r6   r.   r+   <module>r      s        = @ = 4 / 
 !73  3+ / { :-&##L -,:/;O  J2  323  1
/
001s0   B, $C B: ,B76B7:C	C	C