from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, Optional
import uuid
@dataclass
class Finding:
id: str
severity: str # CRITICAL|HIGH|MEDIUM|LOW
title: str
region: Optional[str]
evidence: Dict[str, Any]
remediation_hint: str
def new_finding(
severity: str,
title: str,
region: Optional[str],
evidence: Dict[str, Any],
remediation_hint: str,
) -> Finding:
return Finding(
id=str(uuid.uuid4()),
severity=severity,
title=title,
region=region,
evidence=evidence,
remediation_hint=remediation_hint,
)
_SEV_ORDER = {"LOW": 0, "MEDIUM": 1, "HIGH": 2, "CRITICAL": 3}
def severity_at_least(sev: str, minimum: str) -> bool:
return _SEV_ORDER.get(sev.upper(), 0) >= _SEV_ORDER.get(minimum.upper(), 0)