"""
This module defines the base class for vulnerabilities.
"""

from pydantic import Field

from euvd.models._baserecord import _BaseRecord
from euvd.models.customfieldtypes import EPSSScoreValueType, EUVDIdType
from euvd.models.enisaidproductref import EnisaIdProductRef
from euvd.models.enisaidvendorref import EnisaIdVendorRef


class _BaseVulnerability(_BaseRecord):
    """
    Base class for vulnerabilities.
    """

    id: EUVDIdType
    assigner: str
    epss: EPSSScoreValueType

    products: set[EnisaIdProductRef] = Field(default_factory=set)
    vendors: set[EnisaIdVendorRef] = Field(default_factory=set)

    def __hash__(self) -> int:
        return hash(
            (
                self.id,
                self.description,
            )
        )


__all__ = [
    "_BaseVulnerability",
]
