"""漏洞信息模型模块"""
from dataclasses import dataclass
from typing import List, Set, Dict


@dataclass
class Vulnerability:
    """漏洞信息模型"""
    id: str
    package: str
    version: str
    description: str
    fix_versions: List[str]
    aliases: Set[str]
    ai_impact: str  # 对AI模型的影响描述
    
    def to_dict(self) -> Dict[str, any]:
        """转换为字典，用于JSON序列化"""
        return {
            "id": self.id,
            "package": self.package,
            "version": self.version,
            "description": self.description,
            "fix_versions": self.fix_versions,
            "aliases": list(self.aliases),  # Set类型不能直接序列化，转为列表
            "ai_impact": self.ai_impact
        }
    