"""Built-in advisory rules for LiteLLM triage."""

from __future__ import annotations

from dataclasses import dataclass

from .versioning import is_less_than


@dataclass(frozen=True)
class Advisory:
    id: str
    title: str
    affected_versions: str
    fixed_version: str
    severity: str
    source: str
    published_on: str
    summary: str

    def matches(self, version: str) -> bool:
        if self.affected_versions.startswith("<"):
            return is_less_than(version, self.affected_versions[1:])
        return False


ADVISORIES = [
    Advisory(
        id="CVE-2025-11203",
        title="LiteLLM health endpoint API_KEY information disclosure",
        affected_versions="<1.63.14",
        fixed_version="1.63.14",
        severity="medium",
        source="https://www.zerodayinitiative.com/advisories/ZDI-25-929/",
        published_on="2025-10-03",
        summary=(
            "Authenticated users could trigger disclosure of sensitive information "
            "through the health endpoint API_KEY handling. LiteLLM points to "
            "v1.63.14-stable as the corrective release."
        ),
    ),
]
