File size: 943 Bytes
26aeea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Abstract base class for all vulnerability tasks."""

from abc import ABC, abstractmethod
from typing import Any, Dict, Tuple


class BaseTask(ABC):
    """
    Each task models a vulnerable system + its invariants.
    Subclasses implement the system, action handlers, and state.
    """

    TASK_ID: str = ""
    max_steps: int = 5

    @abstractmethod
    def apply_action(self, action: Dict) -> Any:
        """
        Apply a structured action to the system.
        Returns raw output (query results, rendered HTML, auth response, etc.)
        """

    @abstractmethod
    def evaluate(self) -> Tuple[float, Dict]:
        """
        Run the multi-signal evaluator.
        Returns (reward ∈ [0.0, 1.0], signals dict).
        """

    @abstractmethod
    def get_state(self) -> Dict:
        """
        Return a compact state dict for inclusion in the observation.
        Must be JSON-serializable and < a few KB.
        """