o
    i                     @   s   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
 d dlmZ dd	lmZ dd
lmZ eeZeddG dd deZdS )    )	dataclass)ClassVar)Optional)SpanProcessor)Span)	SpanTypes)
get_logger   )_iast_end_request)_iast_start_requestF)eqc                   @   sd   e Zd ZU dZeed   ed< edddZedddZ	ddd	Z
d
efddZd
efddZdS )AppSecIastSpanProcessorN	_instancereturnc                 C   s&   | j du r|   }| _ |  dS dS )zEnable the IAST span processor.N)r   register)clsinstance r   R/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/appsec/_iast/processor.pyenable   s   
zAppSecIastSpanProcessor.enablec                 C   s"   | j dur| j   d| _ dS dS )z Disable the IAST span processor.N)r   
unregister)r   r   r   r   disable   s   


zAppSecIastSpanProcessor.disablec                 C   s   ddl m} |  d S )Nr	   )	load_iast) r   )selfr   r   r   r   __post_init__#   s   
z%AppSecIastSpanProcessor.__post_init__spanc                 C   s   |j tjkrd S t| d S )N)	span_typer   WEBr   r   r   r   r   r   on_span_start(   s   z%AppSecIastSpanProcessor.on_span_startc                 C   s   |j tjkrdS t|d dS )aR  Report reported vulnerabilities.

        Span Tags:
            - `_dd.iast.json`: Only when one or more vulnerabilities have been detected will we include the custom tag.
            - `_dd.iast.enabled`: Set to 1 when IAST is enabled in a request. If a request is disabled
              (e.g. by sampling), then it is not set.
        N)r   )r   r   r   r
   r   r   r   r   on_span_finish.   s   z&AppSecIastSpanProcessor.on_span_finish)r   N)__name__
__module____qualname__r   r   r   __annotations__classmethodr   r   r   r   r    r!   r   r   r   r   r      s   
 
r   N)dataclassesr   typingr   r   ddtrace._trace.processorr   ddtrace._trace.spanr   ddtrace.extr   ddtrace.internal.loggerr   _iast_request_contextr
   _iast_request_context_baser   r"   logr   r   r   r   r   <module>   s    