
    gh                     $   S SK r S SKJr  S SKJr  S SKrS SKJr  S SKJ	r	  S SK
JrJr  S SKJr  S SKJr  \(       a  S S	KJrJrJr  S S
KJr   S SKJrJr   S SKrSr " S S\5      rS rS rg! \ a	    \" S5      ef = f! \ a	    \" S5      ef = f)    N)deepcopy)wraps)DidNotEnable)should_send_default_pii)SOURCE_FOR_STYLETransactionSource)transaction_from_function)TYPE_CHECKING)AnyCallableDict)Event)StarletteIntegrationStarletteRequestExtractorzStarlette is not installedzFastAPI is not installedzgeneric FastAPI requestc                   (    \ rS rSrSr\S 5       rSrg)FastApiIntegration"   fastapic                      [        5         g N)patch_get_request_handler     b/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/integrations/fastapi.py
setup_onceFastApiIntegration.setup_once%   s
     	"#r   r   N)__name__
__module____qualname____firstlineno__
identifierstaticmethodr   __static_attributes__r   r   r   r   r   "   s    J$ $r   r   c                 b   SnUS:X  a7  UR                   R                  S5      nU(       a  [        U5      =(       d    SnO:US:X  a4  UR                   R                  S5      nU(       a  [        USS 5      nUb  UnU(       d  [        n[
        R                  nO	[        U   nU R                  X7S9  g )N endpointurlroutepath)source)	scopegetr	   getattr_DEFAULT_TRANSACTION_NAMEr   ROUTEr   set_transaction_name)r+   transaction_stylerequestnamer&   r(   r)   r*   s           r    _set_transaction_name_and_sourcer4   +   s    DJ&==$$Z0,X6<"D	e	#!!'*5&$/D("((!"34	t3r   c                  p   ^ [         R                  R                  mU4S jn U [         R                  l        g )Nc                    >^^ UR                  S5      nU(       aX  UR                  bK  [        R                  " UR                  5      (       d&  UR                  m[	        T5      U4S j5       nX2l        T" U 0 UD6mU4S jnU$ )N	dependantc                    > [         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$ r   )
sentry_sdkget_current_scopetransactionupdate_active_threadget_isolation_scopeprofileupdate_active_thread_id)argskwargscurrent_scopesentry_scopeold_calls       r   _sentry_callTpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_callR   sm     !+ < < > ,,8!--BBD)==?''3 ((@@B000r   c                    >^#    [         R                  " 5       R                  [        5      nUc  T" U 0 UD6I S h  vN $ U S   n[	        [         R
                  " 5       UR                  U5        [         R                  " 5       n[        U5      nUR                  5       I S h  vN mU4S jn[        R                  Ul        UR                  U" X25      5        T" U 0 UD6I S h  vN $  N NH N7f)Nr   c                    > U4S jnU$ )Nc                    > U R                  S0 5      nT(       a+  ST;   a  [        5       (       a  TS   US'   ST;   a  TS   US'   [        U5      U S'   U $ )Nr2   cookiesdata)r,   r   r   )eventhintrequest_infoinfos      r   event_processorړpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processor.<locals>.event_processort   s`     $)99Y#;L$,1H1J1J6:9oL3!T>37<L0'/'=E)$ Lr   r   )reqintegrationrP   rO   s      r   _make_request_event_processorzpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processorr   s    ! '&r   )r9   
get_clientget_integrationr   r4   r:   r1   r=   r   extract_request_infor!   _nameadd_event_processor)	r@   rA   rS   r2   rC   	extractorrT   rO   old_apps	          @r   _sentry_appSpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_appc   s     $//1AABTUK"$d5f5551gG,,,.0M0Mw &99;L1':I"7799D'$ "4!>!>L,,-gC !$1&111E 6 :2 2s5   7C/C)A&C/"C+#AC/$C-%C/+C/-C/)r,   callasyncioiscoroutinefunctionr   )r@   rA   r7   rE   r]   r\   rD   old_get_request_handlers        @@r   _sentry_get_request_handler>patch_get_request_handler.<locals>._sentry_get_request_handlerH   sv    JJ{+	*//	?? ~~H8_
1 
1 *N)4:6:&	2P r   )r   routingget_request_handler)rc   rb   s    @r   r   r   D   s)    %ooAACJ +FGOO'r   )r`   copyr   	functoolsr   r9   sentry_sdk.integrationsr   sentry_sdk.scoper   sentry_sdk.tracingr   r   sentry_sdk.utilsr	   typingr
   r   r   r   sentry_sdk._typesr   !sentry_sdk.integrations.starletter   r   r   ImportErrorr.   r   r4   r   r   r   r   <module>rq      s        0 4 B 6  **'53
 6 $- $42IF]  5
3
445
  3
1
223s   A. B  .A= B