o
    h                     @   sJ   d dl Z d dlZd dlmZmZ d dlmZ eeZ	G dd deZ
dS )    N)DictAny)CountermeasurePluginc                   @   s@   e Zd ZdZdeeef deeef fddZdefddZdS )	RandomErrorCountermeasureu8   
    随机返回HTTP错误码的反制动作实现
    contextreturnc                 C   sT   | di }| dg d}|std g d}t|}td|  d|iS )u  
        执行随机错误码返回动作。
        :param context: 包含 'config' 键的字典，'config' 中可包含 'error_codes' 列表。
                          默认值: [400, 401, 403, 404, 500, 502, 503]。
        :return: 包含执行结果的字典。
        configerror_codes)i  i  i  i  i  i  i  z6No error codes provided in config, using default list.z'Simulated returning random error code: Zerror_code_applied)getloggerwarningrandomchoiceinfo)selfr   r   r	   Zselected_error r   :/root/ive/./countermeasures/random_error/countermeasure.pyexecute   s   

z!RandomErrorCountermeasure.executec                 C   s   dS )Nz<Randomly returns an HTTP error code (40x/50x) to the client.r   )r   r   r   r   get_description    s   z)RandomErrorCountermeasure.get_descriptionN)	__name__
__module____qualname____doc__r   strr   r   r   r   r   r   r   r   	   s    "r   )r   loggingtypingr   r   pluginsr   	getLoggerr   r   r   r   r   r   r   <module>   s    
