o
    iA                     @   sj   d dl mZmZmZ d dlmZmZmZmZ er$d dl	m
Z
 d dlmZ g dZg dZG dd dZd	S )
    )capture_internal_exceptionsAnnotatedValueiter_event_frames)TYPE_CHECKINGcastListDict)Event)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                   @   s   e Zd Z				d!dddededdddf
d	d
ZdeddfddZdeddfddZd"ddZd"ddZ	d"ddZ
d"ddZd"ddZd"ddZd"dd ZdS )#EventScrubberNFdenylistzOptional[List[str]]	recursivesend_default_piipii_denylistreturnc                 C   sX   |du rt  n|| _|s|du rt n|}|  j|7  _dd | jD | _|| _dS )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.
        Nc                 S   s   g | ]}|  qS  )lower).0xr2   r2   P/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/sentry_sdk/scrubber.py
<listcomp>U   s    z*EventScrubber.__init__.<locals>.<listcomp>)DEFAULT_DENYLISTcopyr-   DEFAULT_PII_DENYLISTr.   )selfr-   r.   r/   r0   r2   r2   r6   __init__>   s   
zEventScrubber.__init__lstc                 C   s0   t |tsdS |D ]}| | | | q	dS )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)r;   r=   vr2   r2   r6   rA   X   s   

zEventScrubber.scrub_listdc                 C   sd   t |tsdS | D ]$\}}t |tr"| | jv r"t ||< q| jr/| 	| | 
| qdS )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strr3   r-   r   +substituted_because_contains_sensitive_datar.   r@   rA   )r;   rC   krB   r2   r2   r6   r@   f   s   


zEventScrubber.scrub_dicteventr	   c                 C   s   t  J d|v r=d|d v r| |d d  d|d v r&| |d d  d|d v rE| |d d  W d    d S W d    d S W d    d S 1 sPw   Y  d S )Nrequestheaderscookiesdatar   r@   r;   rI   r2   r2   r6   scrub_requesty   s   "zEventScrubber.scrub_requestc                 C   R   t   d|v r| |d  W d    d S W d    d S 1 s"w   Y  d S )NextrarN   rO   r2   r2   r6   scrub_extra      "zEventScrubber.scrub_extrac                 C   rQ   )NuserrN   rO   r2   r2   r6   
scrub_user   rT   zEventScrubber.scrub_userc                 C   s   t  F d|v r)t|d ts1d|d v r9|d d D ]%}d|v r(| |d  qW d    d S W d    d S W d    d S W d    d S 1 sLw   Y  d S )NbreadcrumbsvaluesrM   )r   r>   r   r@   )r;   rI   valuer2   r2   r6   scrub_breadcrumbs   s"   "zEventScrubber.scrub_breadcrumbsc                 C   sP   t   t|D ]}d|v r| |d  qW d    d S 1 s!w   Y  d S )Nvars)r   r   r@   )r;   rI   framer2   r2   r6   scrub_frames   s   "zEventScrubber.scrub_framesc                 C   sz   t  0 d|v r#tttttf  |d D ]}d|v r"| |d  qW d    d S W d    d S 1 s6w   Y  d S )NspansrM   )r   r   r   r   rF   objectr@   )r;   rI   spanr2   r2   r6   scrub_spans   s   "zEventScrubber.scrub_spansc                 C   s@   |  | | | | | | | | | | | d S )N)rP   rS   rV   rZ   r]   ra   rO   r2   r2   r6   scrub_event   s   




zEventScrubber.scrub_event)NFFN)rI   r	   r1   N)__name__
__module____qualname__boolr<   r_   rA   r@   rP   rS   rV   rZ   r]   ra   rb   r2   r2   r2   r6   r,   =   s2    







r,   N)sentry_sdk.utilsr   r   r   typingr   r   r   r   sentry_sdk._typesr	   r
   r8   r:   r,   r2   r2   r2   r6   <module>   s    '