o
    i                     @   s  d dl Zd dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ eeZeh dejB Zd	Ze d
ejeef defddZe dedefddZG dd deZG dd deZe jZdedejejgejf fddZG dd deZ dS )    N)
DDCompiler)DDExpression)
get_logger)config)normalize_ident)cached>U   2facvvjtijwtotppinpwdssnauthcsrfsaltxsrfdburlnonceoauthpkcs8tokenapikeyappkeyciphercookiegpgkeypasswdpgpkeysecretsshkeypemfilepincodesessionsymfonyvoteridxapikeyxrealipccnumberclientidmysqlpwdpasshashpassword	apisecret	authtoken	csrftoken	ipaddress	masterkey	passwordb	phpsessid	publickey	secretkey	sessionid	setcookie	signature	xsrftoken
connectsid
creditcard
licensekey
oauthtoken
privatekey
sessionkey
xauthtoken
xcsrftokenaccesstokencredentialsdatabaseurlgeolocationsecrettokentwiliotokenusersessionapisignatureclientsecretrecaptchakeyrefreshtokensecuritycodesignaturekeyauthorizationencryptionkeyroutingnumbertransactionidxforwardedforaiohttpsessionapplicationkeycertificatepinsecurityanswerencryptionkeyidconnectionstringsecurityquestionserviceaccountcredentialsz
{redacted}identreturnc                 C   s2   t t| tr| n| jddd}|tv o|tjvS )Nzutf-8replace)errors)r   
isinstancestrdecodeREDACTED_IDENTIFIERSr   redaction_excluded_identifiers)r]   
normalized rg   P/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/debugging/_redaction.pyredactp   s    ri   _typec                 C   s    t j}|d u r	dS || d uS )NF)r   redacted_types_research)rj   _rerg   rg   rh   redact_typev   s   rn   c                   @   s   e Zd ZdS )DDRedactedExpressionErrorN)__name__
__module____qualname__rg   rg   rg   rh   ro   ~   s    ro   c                       sl   e Zd Zedejdedejf fddZedejdejdejf fdd	Zededefd
dZ	  Z
S )DDRedactedCompilersar^   c                    s&   t |rtd|dt ||S )NzAccess to attribute  is not allowed)ri   ro   super__getmember__)clsrt   ru   	__class__rg   rh   rx      s   z DDRedactedCompiler.__getmember__oic                    s4   t |ttfrt|rtd|dt ||S )NzAccess to entry rv   )ra   rb   bytesri   ro   rw   	__index__)ry   r|   r}   rz   rg   rh   r      s   zDDRedactedCompiler.__index__c                 C   s   t |rtd|d|S )NzAccess to local rv   )ri   ro   )ry   rt   rg   rg   rh   __ref__   s   zDDRedactedCompiler.__ref__)rp   rq   rr   classmethodtAnyrb   rx   r   r   __classcell__rg   rg   rz   rh   rs      s     "rs   excc                    s   dt jdt jf fdd}|S )N_r^   c                    s    )Nrg   )r   r   rg   rh   r      s   z_redacted_expr.<locals>._)r   r   )r   r   rg   r   rh   _redacted_expr   s   r   c                	       sB   e Zd ZeZedededej	ej
gej
f f fddZ  ZS )DDRedactedExpressiondslr   r^   c                    s0   t |trtjd|dd t|S t ||S )Nz;Cannot compile expression that references potential PII: %sT)exc_info)ra   ro   logerrorr   rw   on_compiler_error)ry   r   r   rz   rg   rh   r      s   
z&DDRedactedExpression.on_compiler_error)rp   rq   rr   dd_compile_redacted__compiler__r   rb   	Exceptionr   Callabler   r   r   rg   rg   rz   rh   r      s    4r   )!typingr   ddtrace.debugging._expressionsr   r   ddtrace.internal.loggerr   1ddtrace.internal.settings.dynamic_instrumentationr   r   ddtrace.internal.utils.cacher   rp   r   	frozensetredacted_identifiersrd   REDACTED_PLACEHOLDERUnionrb   r~   boolri   rn   r   ro   rs   compiler   r   r   r   r   rg   rg   rg   rh   <module>   s0    Y^"