o
    Zhn                     @   s   zd dl mZ W n ey   dd ZY nw d dlmZmZmZ d dl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d deZdS )    )castc                 C   s   |S N )_objr   r   J/var/www/html/lang_env/lib/python3.10/site-packages/sentry_sdk/scrubber.py<lambda>   s    r   )capture_internal_exceptionsAnnotatedValueiter_event_frames)string_types)TYPE_CHECKING)Event)List)Optional)$passwordpasswdsecretZapi_keyZapikeyauthcredentialsZ	mysql_pwdZ
privatekeyZprivate_keytoken
ip_addresssessionZ	csrftokenZ	sessionidZremote_addrZx_csrftokenx_forwarded_for
set_cookiecookieauthorizationZ	x_api_keyr   Z	x_real_ipZaiohttp_sessionzconnect.sidZ
csrf_tokenZcsrfZ_csrfZ_csrf_tokenZ	PHPSESSID_sessionZsymfonyZuser_sessionZ_xsrfz
XSRF-TOKENc                   @   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   s.   |d u rt n|| _dd | jD | _|| _d S )Nc                 S   s   g | ]}|  qS r   )lower).0xr   r   r   
<listcomp>D   s    z*EventScrubber.__init__.<locals>.<listcomp>)DEFAULT_DENYLISTdenylist	recursive)selfr$   r%   r   r   r   __init__A   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)r&   lstvr   r   r   r+   G   s   

zEventScrubber.scrub_listc                 C   sj   t |tsdS | D ]'\}}t |tr%tt| | jv r%t	 ||< q| j
r2| | | | 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itemsr   r   strr   r$   r
   Z+substituted_because_contains_sensitive_datar%   r*   r+   )r&   dkr-   r   r   r   r*   V   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*   r&   eventr   r   r   scrub_requestj   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extrar7   r8   r   r   r   scrub_extrau      "zEventScrubber.scrub_extrac                 C   r;   )Nuserr7   r8   r   r   r   
scrub_user{   r>   zEventScrubber.scrub_userc                 C   s   t  7 d|v r"d|d v r*|d d D ]}d|v r!| |d  qW d    d S W d    d S W d    d S 1 s=w   Y  d S )NZbreadcrumbsvaluesr6   r7   )r&   r9   valuer   r   r   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&   r9   framer   r   r   scrub_frames   s   "zEventScrubber.scrub_framesc                 C   sh   t  ' d|v r|d D ]}d|v r| |d  qW d    d S W d    d S 1 s-w   Y  d S )Nspansr6   r7   )r&   r9   spanr   r   r   scrub_spans   s   "zEventScrubber.scrub_spansc                 C   s@   |  | | | | | | | | | | | d S r   )r:   r=   r@   rC   rF   rI   r8   r   r   r   scrub_event   s   




zEventScrubber.scrub_event)NF)__name__
__module____qualname__r'   r+   r*   r:   r=   r@   rC   rF   rI   rJ   r   r   r   r   r   @   s    
	r   N)typingr   ImportErrorZsentry_sdk.utilsr	   r
   r   Zsentry_sdk._compatr   Zsentry_sdk._typesr   r   r   r   r#   objectr   r   r   r   r   <module>   s    ,