File size: 1,036 Bytes
0355450 |
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 37 38 39 40 41 42 43 44 45 |
"""Security analysis data models and logic."""
from dataclasses import dataclass
from enum import Enum
from typing import Optional
class RiskLevel(str, Enum):
"""Severity levels for security incidents."""
CRITICAL = "critical"
HIGH = "high"
MEDIUM = "medium"
LOW = "low"
INFO = "info"
@dataclass
class SecurityAnalysis:
"""Structured analysis result from the LLM."""
summary: str
"""Brief summary of what happened."""
risk_level: RiskLevel
"""Severity classification."""
remediation: str
"""Suggested corrective actions."""
indicators: list[str]
"""Key indicators of compromise or anomalies found."""
raw_response: str
"""Full LLM response for transparency."""
def to_dict(self) -> dict:
"""Convert to dictionary for Gradio output."""
return {
"summary": self.summary,
"risk_level": self.risk_level.value.upper(),
"remediation": self.remediation,
"indicators": self.indicators,
}
|