
    Dj&                     p    d dl mZmZmZ d dlmZ erd dlmZ d dlmZ d dlm	Z	 g dZ
g dZ G d d	      Zy
)    )capture_internal_exceptionsAnnotatedValueiter_event_frames)TYPE_CHECKING)Event)List)Optional) passwordpasswdsecretapi_keyapikeyauthcredentials	mysql_pwd
privatekeyprivate_keytokensession	csrftoken	sessionidx_csrftokenx_forwarded_for
set_cookiecookieauthorization	x_api_keyaiohttp_sessionzconnect.sid
csrf_tokencsrf_csrf_csrf_token	PHPSESSID_sessionsymfonyuser_session_xsrfz
XSRF-TOKEN)r   	x_real_ip
ip_addressremote_addrc                   L    e Zd Z	 ddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zy)EventScrubberNc                    |t         j                         n|| _        |s-|t        j                         n|}| xj                  |z  c_        | j                  D cg c]  }|j	                          c}| _        || _        yc c}w )a
  
        A scrubber that goes through the event payload and removes sensitive data configured through denylists.

        :param denylist: A security denylist that is always scrubbed, defaults to DEFAULT_DENYLIST.
        :param recursive: Whether to scrub the event payload recursively, default False.
        :param send_default_pii: Whether pii is sending is on, pii fields are not scrubbed.
        :param pii_denylist: The denylist to use for scrubbing when pii is not sent, defaults to DEFAULT_PII_DENYLIST.
        N)DEFAULT_DENYLISTcopydenylistDEFAULT_PII_DENYLISTlower	recursive)selfr0   r3   send_default_piipii_denylistxs         WC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\sentry_sdk/scrubber.py__init__zEventScrubber.__init__?   sp     4<3C(--//;/C$))+  MM\)M,0MM:q:" ;s   Bc                 x    t        |t              sy|D ]$  }| j                  |       | j                  |       & y)a*  
        If a list is passed to this method, the method recursively searches the list and any
        nested lists for any dictionaries. The method calls scrub_dict on all dictionaries
        it finds.
        If the parameter passed to this method is not a list, the method does nothing.
        N)
isinstancelist
scrub_dict
scrub_list)r4   lstvs      r8   r>   zEventScrubber.scrub_listV   s8     #t$ 	AOOAOOA	    c                 <   t        |t              sy|j                         D ]x  \  }}t        |t              r4|j	                         | j
                  v rt        j                         ||<   J| j                  sW| j                  |       | j                  |       z y)a[  
        If a dictionary is passed to this method, the method scrubs the dictionary of any
        sensitive data. The method calls itself recursively on any nested dictionaries (
        including dictionaries nested in lists) if self.recursive is True.
        This method does nothing if the parameter passed to it is not a dictionary.
        N)r;   dictitemsstrr2   r0   r   +substituted_because_contains_sensitive_datar3   r=   r>   )r4   dkr@   s       r8   r=   zEventScrubber.scrub_dicte   sx     !T"GGI 	#DAq !S!aggi4==&@%QQS!""	#rA   c                     t               5  d|v rZd|d   v r| j                  |d   d          d|d   v r| j                  |d   d          d|d   v r| j                  |d   d          d d d        y # 1 sw Y   y xY w)Nrequestheaderscookiesdatar   r=   r4   events     r8   scrub_requestzEventScrubber.scrub_requesty   s    (* 	>E!i 00OOE)$4Y$?@i 00OOE)$4Y$?@U9--OOE)$4V$<=	> 	> 	>s   AA33A<c                 r    t               5  d|v r| j                  |d          d d d        y # 1 sw Y   y xY w)NextrarN   rO   s     r8   scrub_extrazEventScrubber.scrub_extra   s5    (* 	0%g/	0 	0 	0   -6c                 r    t               5  d|v r| j                  |d          d d d        y # 1 sw Y   y xY w)NuserrN   rO   s     r8   
scrub_userzEventScrubber.scrub_user   s4    (* 	/f.	/ 	/ 	/rU   c                     t               5  d|v r-d|d   v r&|d   d   D ]  }d|v s| j                  |d           d d d        y # 1 sw Y   y xY w)NbreadcrumbsvaluesrM   rN   )r4   rP   values      r8   scrub_breadcrumbszEventScrubber.scrub_breadcrumbs   sb    (* 	;%u]33!&}!5h!? ;!U? OOE&M:;	; 	; 	;s   AAAc                     t               5  t        |      D ]  }d|v s| j                  |d           	 d d d        y # 1 sw Y   y xY w)Nvars)r   r   r=   )r4   rP   frames      r8   scrub_frameszEventScrubber.scrub_frames   sH    (* 	3*51 3U?OOE&M23	3 	3 	3s   ??Ac                     t               5  d|v r#|d   D ]  }d|v s| j                  |d           d d d        y # 1 sw Y   y xY w)NspansrM   rN   )r4   rP   spans      r8   scrub_spanszEventScrubber.scrub_spans   sO    (* 	6%!'N 6D~V56	6 	6 	6s   <<Ac                     | j                  |       | j                  |       | j                  |       | j                  |       | j	                  |       | j                  |       y )N)rQ   rT   rX   r]   ra   re   rO   s     r8   scrub_eventzEventScrubber.scrub_event   sT    5!u%% rA   )NFFN)__name__
__module____qualname__r9   r>   r=   rQ   rT   rX   r]   ra   re   rg    rA   r8   r,   r,   >   s7    SW#.#(	>0/;36 rA   r,   N)sentry_sdk.utilsr   r   r   typingr   sentry_sdk._typesr   r   r	   r.   r1   r,   rk   rA   r8   <module>ro      s=     !'% N q  q rA   