o
    0 i                     @   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secretZapi_keyZapikeyauthcredentialsZ	mysql_pwdZ
privatekeyZprivate_keytokensessionZ	csrftokenZ	sessionidZx_csrftokenx_forwarded_for
set_cookiecookieauthorizationZ	x_api_keyZaiohttp_sessionzconnect.sidZ
csrf_tokenZcsrfZ_csrfZ_csrf_tokenZ	PHPSESSID_sessionZsymfonyZuser_sessionZ_xsrfz
XSRF-TOKEN)r   Z	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   _/home/app/PaddleOCR-VL-test/.venv_paddleocr/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)selfr"   r$   Zsend_default_piiZpii_denylistr   r   r   __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)r%   lstvr   r   r   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   r"   r   Z+substituted_because_contains_sensitive_datar$   r)   r*   )r%   dkr,   r   r   r   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)   r%   eventr   r   r   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extrar6   r7   r   r   r   scrub_extra      "zEventScrubber.scrub_extrac                 C   r:   )Nuserr6   r7   r   r   r   
scrub_user   r=   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 )NZbreadcrumbsvaluesr5   )r   r'   r   r)   )r%   r8   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%   r8   framer   r   r   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spansr5   )r   r   r   r   r/   objectr)   )r%   r8   spanr   r   r   scrub_spans   s   "zEventScrubber.scrub_spansc                 C   s@   |  | | | | | | | | | | | d S )N)r9   r<   r?   rB   rE   rI   r7   r   r   r   scrub_event   s   




zEventScrubber.scrub_event)NFFN)__name__
__module____qualname__r&   r*   r)   r9   r<   r?   rB   rE   rI   rJ   r   r   r   r   r   =   s    
r   N)Zsentry_sdk.utilsr   r   r   typingr   r   r   r   Zsentry_sdk._typesr	   r
   r    r#   r   r   r   r   r   <module>   s    '