\!*TddlmZddlmZddlmZmZddlmZddl m Z ddl m Z m Z ddlmZerddlmZdd lmZdd lmZdd lmZ dd lZdd lZdd lmZn#e$r edwxYwGddeZGddeZdZGddeZdZdZ dZ!dZ"dZ#d S))absolute_import)Hub) Integration DidNotEnable)RequestExtractor)SentryWsgiMiddleware)capture_internal_exceptionsevent_from_exception)MYPY)Any)Dict)Optional)EventProcessorN) __version__zFalcon not installedc2eZdZdZdZdZdZdZdZdS)FalconRequestExtractorc|jjSN)requestenvselfs ~/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/sentry_sdk/integrations/falcon.pyrzFalconRequestExtractor.envs |c|jjSr)rcookiesrs rrzFalconRequestExtractor.cookies s |##rcdSrrs rformzFalconRequestExtractor.form$trcdSrrrs rfileszFalconRequestExtractor.files(r rc>|}|dkrdSdS)Nrz[REQUEST_CONTAINING_RAW_DATA])content_length)rr$s rraw_datazFalconRequestExtractor.raw_data,s+,,.. A  224rch |jjS#tjj$r|jjcYSwxYwr)rmediafalconerrorsHTTPBadRequest_mediars rjsonzFalconRequestExtractor.json9sE '<% %}+ ' ' ' <& & & &  's  11N) __name__ __module__ __qualname__rrrr"r%r,rrrrrsn   $$$    ' ' ' ' 'rrceZdZdZdZdS)SentryFalconMiddlewarez9Captures exceptions in Falcon requests and send to Sentryctj}|t}|dS|5}d|_|t||ddddS#1swxYwYdS)Nr()rcurrentget_integrationFalconIntegrationconfigure_scope_nameadd_event_processor_make_request_event_processor)rreqrespargskwargshub integrationscopes rprocess_requestz&SentryFalconMiddleware.process_requestHsk))*;<<   F  " " We"EK  % %&CC&U&U V V V W W W W W W W W W W W W W W W W W Ws+A77A;>A;N)r-r.r/__doc__rArrrr1r1Es.CC W W W W Wrr1) uri_templatepathc4eZdZdZdZddZedZdS)r5r(NrCc\|tvrtd|dtd||_dS)Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES ValueErrortransaction_style)rrJs r__init__zFalconIntegration.__init__\sJ $< < <*$$$&>&>&>@ "3rch ttttjd}n<#t t f$r(tdtwxYw|dkrtdtttdS)N.zUnparsable Falcon version: {})zFalcon 1.4 or newer required.) tuplemapintFALCON_VERSIONsplitrI TypeErrorrformat_patch_wsgi_app_patch_handle_exception_patch_prepare_middleware)versions r setup_oncezFalconIntegration.setup_oncees WC^%9#%>%>??@@GGI& W W W>EEnUUVV V W V  >?? ?!!!!#####s 479A0)rC)r-r.r/ identifierrJrK staticmethodr[rrrr5r5WsNJ3333 $ $\ $ $ $rr5cVtjjfd}|tj_dS)Nctj}|t}| ||St fd}|||S)Nc||Srr)envi start_resporiginal_wsgi_apprs rzB_patch_wsgi_app..sentry_patched_wsgi_app..s%6%6tT:%N%Nr)rr3r4r5r)rrstart_responser>r?sentry_wrappedrcs` rsentry_patched_wsgi_appz0_patch_wsgi_app..sentry_patched_wsgi_appyslk))*;<<  $$T3?? ?- N N N N N  ~c>222r)r(API__call__)rgrcs @rrWrWus9 + 3 3 3 3 32FJrcVtjjfd}|tj_dS)NcVt|dtr |d}n|d} |g|R}tj}|t }|Jt |s;|j}t||j ddd\}}| |||S)Nrr(F)typehandled)client_options mechanism)hint) isinstance Exceptionrr3r4r5_is_falcon_http_errorclientr options capture_event) rr<ex was_handledr>r?rueventrqoriginal_handle_exceptions rsentry_patched_handle_exceptionz@_patch_handle_exception..sentry_patched_handle_exceptions d1gy ) ) aBBaB//>KE4   e$  / / /r)r(rh_handle_exception)r|r{s @rrXrXs: & <8$CFJ   rcZtjj dfd }|tj_dS)NFctj}|t}|t g|pgz}||Sr)rr3r4r5r1) middlewareindependent_middlewarer>r?original_prepare_middlewares r!sentry_patched_prepare_middlewarezD_patch_prepare_middleware..sentry_patched_prepare_middlewaresRk))*;<<  "0223z7GRHJ**:7MNNNr)NF)r( api_helpersprepare_middleware)rrs @rrYrYsL"("4"G16OOOOOO-NF)))rcXt|tjtjjfSr)rrr( HTTPError http_status HTTPStatus)rxs rrtrts b6+V-?-JK L LLrcfd}|S)Ncjdkr j|d<njdkr j|d<t5t |dddn #1swxYwY|S)NrC transactionrD)rJrCrDr rextract_into_event)rzrqr?r:s rinnerz,_make_request_event_processor..inners  (N : :#E-  *f 4 4#&8E- ( * * B B "3 ' ' : :5 A A A B B B B B B B B B B B B B B B s#A**A.1A.r)r:r?rs`` rr9r9s)       Lr)$ __future__rsentry_sdk.hubrsentry_sdk.integrationsrr$sentry_sdk.integrations._wsgi_commonrsentry_sdk.integrations.wsgirsentry_sdk.utilsr r sentry_sdk._typesr typingr r rrr(falcon.api_helpersrrS ImportErrorrobjectr1rHr5rWrXrYrtr9rrrrs)&&&&&&========AAAAAA======NNNNNNNN""""""1000000/MMM4444444/// ,- . ../''''''''''-''''''T W W W W WV W W W4$$$$$ $$$<222( C C CFNNN"MMM s AA*