
    gh                     v   S SK r S SKrS SKJr  S SKJrJrJrJrJ	r	  S SK
JrJrJrJr  S SKJr  S SKJr  S SKJr  \(       a6  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  S SKJr  S SKJrJrJr  S SK J!r!J"r"   S SKJ#r#J$r$J%r%J&r'J(r)  Sr+ " S S\5      r, " S S\5      r-S r.S r/S r0g! \* a	    \" S5      ef = f)    N)SOURCE_FOR_STYLE)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionparse_versiontransaction_from_function)IntegrationDidNotEnable$_DEFAULT_FAILED_REQUEST_STATUS_CODES_check_minimum_version)SentryWsgiMiddleware)RequestExtractor)TYPE_CHECKING)Set)_ScopedResponse)Any)Dict)Callable)Optional)
FileUpload	FormsDictLocalRequest)EventProcessorEvent)BottleHTTPResponseRouterequest__version__zBottle not installed)endpointurlc                   J    \ rS rSrSrS\ 3rSr S
\S.S jjr\	S 5       r
Srg	)BottleIntegration2   bottlez
auto.http. )failed_request_status_codesc                `    U[         ;  a  [        SU< S[         < S35      eXl        X l        g )Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES
ValueErrortransaction_styler'   )selfr,   r'   s      a/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/integrations/bottle.py__init__BottleIntegration.__init__8   s4     $<<$&>@  "3+F(    c                    ^^^ [        [        5      n [        [        U 5        [        R
                  m[        [        T5      U4S j5       nU[        l        [        R                  m[        R                  " T5      U4S j5       nU[        l        [        R                  m[        R                  " T5      U4S j5       nU[        l        g )Nc                 P   >^  [        UU 4S j[        R                  S9nU" X5      $ )Nc                     > T" T/U Q70 UD6$ N )akwold_appr-   s     r.   <lambda>OBottleIntegration.setup_once.<locals>.sentry_patched_wsgi_app.<locals>.<lambda>T   s    !8!8R!8r1   )span_origin)r   r#   origin)r-   environstart_response
middlewarer9   s   `   r.   sentry_patched_wsgi_app=BottleIntegration.setup_once.<locals>.sentry_patched_wsgi_appP   s(     .8-44J
 g66r1   c                    > [         R                  " 5       R                  [        5      nUc  T" X5      $ [         R                  " 5       nSUl        UR                  [        U [        U5      5        T" X5      nU$ )Nr%   )	
sentry_sdk
get_clientget_integrationr#   get_isolation_scope_nameadd_event_processor_make_request_event_processorbottle_request)r-   r>   integrationscoperes
old_handles        r.   _patched_handle5BottleIntegration.setup_once.<locals>._patched_handle^   sp     %//1AABSTK"!$00224E"EK%%-dNKP T+CJr1   c                    >^^ T" U /UQ70 UD6m[         R                  " 5       R                  [        5      mTc  T$ UU4S jnU$ )Nc                     >  T" U 0 UD6n[        U[        5      (       a$  UR                  TR
                  ;   a
  [        USS9  U$ ! [          a  n[        USS9  UeS nAff = f)NF)handledT)	Exception_capture_exception
isinstancer   status_coder'   )argskwargsrN   	exceptionrL   prepared_callbacks       r.   wrapped_callbackUBottleIntegration.setup_once.<locals>.patched_make_callback.<locals>.wrapped_callback{   sh    $+T<V<C sL11;+R+RR&sD9
 ! $&y%@#O$s   A 
A!AA!)rD   rE   rF   r#   )r-   rY   rZ   r]   rL   r\   old_make_callbacks       @@r.   patched_make_callback;BottleIntegration.setup_once.<locals>.patched_make_callbackr   sM     !2$ H H H$//1AABSTK"((  $#r1   )r   BOTTLE_VERSIONr   r#   r   __call__r   _handle	functoolswrapsr   _make_callback)versionrA   rP   r`   r9   rO   r_   s       @@@r.   
setup_onceBottleIntegration.setup_onceH   s      /0'://	#$5w	?	7 
@	7 2^^
		$	 
%	 )!00	*	+	$ 
,	$4  5r1   )r'   r,   N)r    )__name__
__module____qualname____firstlineno__
identifierr=   r,   r   r/   staticmethodri   __static_attributes__r6   r1   r.   r#   r#   2   sF    J*&F %G %I	G  D5 D5r1   r#   c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
BottleRequestExtractor   c                 .    U R                   R                  $ r5   )r   r>   r-   s    r.   envBottleRequestExtractor.env       ||###r1   c                 .    U R                   R                  $ r5   )r   cookiesrv   s    r.   r{   BottleRequestExtractor.cookies   ry   r1   c                 J    U R                   R                  R                  5       $ r5   )r   bodyreadrv   s    r.   raw_dataBottleRequestExtractor.raw_data   s    ||  %%''r1   c                 v    U R                  5       (       a  g U R                  R                  R                  5       $ r5   )is_jsonr   formsdecoderv   s    r.   formBottleRequestExtractor.form   s)    <<>>||!!((**r1   c                 Z    U R                  5       (       a  g U R                  R                  $ r5   )r   r   filesrv   s    r.   r   BottleRequestExtractor.files   s     <<>>||!!!r1   c                     UR                   $ r5   )content_length)r-   files     r.   size_of_file#BottleRequestExtractor.size_of_file   s    """r1   r6   N)rk   rl   rm   rn   rw   r{   r   r   r   r   rq   r6   r1   r.   rs   rs      s     $$(+"#r1   rs   c                 R   SnUS:X  a!   UR                   R                  =(       d    SnOLUS:X  aF   UR                   R                  =(       d(    [	        UR                   R
                  5      =(       d    SnX0S'   S[        U   0U S'   g ! [         a     Nf = f! [         a     N/f = f)Nr&   r!   r    transactionsourcetransaction_info)routeruleRuntimeErrornamer   callbackr   )eventr,   r   r   s       r.    _set_transaction_name_and_sourcer      s    DE!	==%%+D 
j	(	"" ,W]]-C-CD   -!)+;<M+N OE
  		  		s#   B	 AB 	
BB
B&%B&c                    ^^ UU4S jnU$ )Nc                    > [        U TR                  T5        [        5          [        T5      R	                  U 5        S S S 5        U $ ! , (       d  f       U $ = fr5   )r   r,   r   rs   extract_into_event)r   hintrL   r   s     r.   event_processor6_make_request_event_processor.<locals>.event_processor   sJ    (0M0MwW(*"7+>>uE +  +* s   A
Ar6   )appr   rL   r   s    `` r.   rJ   rJ      s     r1   c                     [        U [        R                  " 5       R                  SUS.S9u  p#[        R                  " X#S9  g )Nr%   )typerT   )client_options	mechanism)r   )r   rD   rE   optionscapture_event)r[   rT   r   r   s       r.   rV   rV      s;    &!,,.66#8KE
 U.r1   )1re   rD   sentry_sdk.tracingr   sentry_sdk.utilsr   r   r   r   r   sentry_sdk.integrationsr	   r
   r   r   sentry_sdk.integrations.wsgir   $sentry_sdk.integrations._wsgi_commonr   typingr   collections.abcr   r   r   r   r   r   r%   r   r   r   sentry_sdk._typesr   r   r   r   r   r   rK   r   rb   ImportErrorr*   r#   rs   r   rJ   rV   r6   r1   r.   <module>r      s      /   > A  #<::7	/  / [5 [5|#- #>P0/W  /
-
../s   9B) )B8