o
    h                     @   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Zdd Zdd Zd	d
 Zdd Zdd Zdd Z	dd Z
dd Zdd ZdS )EventScrubberNFc                 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xr-   r-   U/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/sentry_sdk/scrubber.py
<listcomp>R   s    z*EventScrubber.__init__.<locals>.<listcomp>)DEFAULT_DENYLISTcopydenylistDEFAULT_PII_DENYLIST	recursive)selfr5   r7   send_default_piipii_denylistr-   r-   r1   __init__>   s   
zEventScrubber.__init__c                 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)r8   lstvr-   r-   r1   r?   U   s   

zEventScrubber.scrub_listc                 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strr.   r5   r   +substituted_because_contains_sensitive_datar7   r>   r?   )r8   dkrA   r-   r-   r1   r>   d   s   


zEventScrubber.scrub_dictc                 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>   r8   eventr-   r-   r1   scrub_requestx   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extrarL   rM   r-   r-   r1   scrub_extra      "zEventScrubber.scrub_extrac                 C   rP   )NuserrL   rM   r-   r-   r1   
scrub_user   rS   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valuesrK   )r   r<   r   r>   )r8   rN   valuer-   r-   r1   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>   )r8   rN   framer-   r-   r1   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spansrK   )r   r   r   r   rD   objectr>   )r8   rN   spanr-   r-   r1   scrub_spans   s   "zEventScrubber.scrub_spansc                 C   s@   |  | | | | | | | | | | | d S )N)rO   rR   rU   rY   r\   r`   rM   r-   r-   r1   scrub_event   s   




zEventScrubber.scrub_event)NFFN)__name__
__module____qualname__r;   r?   r>   rO   rR   rU   rY   r\   r`   ra   r-   r-   r-   r1   r,   =   s    
r,   N)sentry_sdk.utilsr   r   r   typingr   r   r   r   sentry_sdk._typesr	   r
   r3   r6   r,   r-   r-   r-   r1   <module>   s    '