
    ghs                         S SK r S SKJr  S SKJr  S SKJr  \(       a$  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 rS rS rS rS rg)    N)should_send_default_pii)_filter_headers)TYPE_CHECKING)Any)Dict)Optional)Union)Literal)AnnotatedValuec                     0 nU S    H>  u  p#UR                  S5      nUR                  S5      nXA;   a  X   S-   U-   X'   M:  XQU'   M@     U$ )zV
Extract headers from the ASGI scope, in the format that the Sentry protocol expects.
headerslatin-1z, )decode)
asgi_scoper   raw_key	raw_valuekeyvalues         g/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/integrations/_asgi_common.py_get_headersr      s_    
 G(3nnY'  +>"<$.6GL CL 4 N    c                 :   U R                  SU5      nU R                  SS5      nU R                  SS5      U R                  SS5      -   nU(       a  U< SU< U< 3$ Ub;  Uu  p&SS	SS	S
.R                  U5      nXg:w  a  U< SU< SU< U< 3$ U< SU< U< 3$ U$ )zJ
Extract URL from the ASGI scope, without also including the querystring.
schemeserverN	root_path pathz://P   i  )httphttpswswss:)get)r   default_schemehostr   r   r   portdefault_ports           r   _get_urlr)   #   s    
 ^^Hn5F^^Hd+F>>+r*Z^^FB-GGD$dD11
 "S3GKKFS%+T4>>$dD11Kr   c                     U R                  S5      nU(       d  g[        R                  R                  UR	                  S5      5      $ )zZ
Extract querystring from the ASGI scope, in the format that the Sentry protocol expects.
query_stringNr   )r$   urllibparseunquoter   )r   qss     r   
_get_queryr0   9   s6    
 
	'B<<		) 455r   c                     [        U 5      n US   R                  S5      S   R                  5       $ ! [        [        4 a     Of = f US   $ ! [         a     Of = fU R                  S5      S   $ )z`
Extract IP Address from the ASGI scope based on request headers with fallback to scope client.
zx-forwarded-for,r   z	x-real-ipclient)r   splitstripKeyError
IndexErrorr$   )r   r   s     r   _get_ipr8   D   s    
 :&G()//4Q7==??j! {##  >>(#A&&s!   $2 AA	A 
AAc                 P   0 nU S   nUS;   aa  U R                  S5      US'   [        [        U 5      5      =US'   n[        U 5      US'   [	        XS:X  a  SOSUR                  S5      5      US	'   U R                  S
5      nU(       a  [        5       (       a  S[        U 5      0US'   U$ )z?
Returns data related to the HTTP request from the ASGI scope.
type)r   	websocketmethodr   r+   r   r!   r&   urlr3   REMOTE_ADDRenv)r$   r   r   r0   r)   r   r8   )r   request_datatyr   r3   s        r   _get_request_datarB   W   s    
 L	F	B	""!+!9X,;L<T,UUY''1*'=^$&,D'++f:M
U ^^H%F)++,gj.ABUr   )r,   sentry_sdk.scoper   $sentry_sdk.integrations._wsgi_commonr   typingr   r   r   r   r	   typing_extensionsr
   sentry_sdk.utilsr   r   r)   r0   r8   rB    r   r   <module>rI      s?     4 @  )/",6'&r   