# This file was auto-generated by Fern from our API Definition.

from ......core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .fingerprint import Fingerprint
from ...base.types.url_string import UrlString
from ...base.types.file_path import FilePath
from .remediation import Remediation
from .affected_package_type_id import AffectedPackageTypeId
from ......core.pydantic_utilities import IS_PYDANTIC_V2


class AffectedPackage(UncheckedBaseModel):
    """
    The Affected Package object describes details about a software package identified as affected by a vulnerability/vulnerabilities.
    """

    architecture: typing.Optional[str] = pydantic.Field(default=None)
    """
    Architecture is a shorthand name describing the type of computer hardware the packaged software is meant to run on.
    """

    cpe_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    The Common Platform Enumeration (CPE) name for the software package.
    """

    epoch: typing.Optional[int] = pydantic.Field(default=None)
    """
    The software package epoch. Epoch is a way to define weighted dependencies based on version numbers.
    """

    fixed_in_version: typing.Optional[str] = pydantic.Field(default=None)
    """
    The software package version in which a reported vulnerability was patched/fixed.
    """

    hash: typing.Optional[Fingerprint] = pydantic.Field(default=None)
    """
    Cryptographic hash to identify the binary instance of a software component. This can include any component such file, package, or library.
    """

    license: typing.Optional[str] = pydantic.Field(default=None)
    """
    The software license applied to this package.
    """

    license_url: typing.Optional[UrlString] = pydantic.Field(default=None)
    """
    The URL pointing to the license applied on package or software. This is typically a <code>LICENSE.md</code> file within a repository.
    """

    name: str = pydantic.Field()
    """
    The software package name.
    """

    package_manager: typing.Optional[str] = pydantic.Field(default=None)
    """
    The software packager manager utilized to manage a package on a system, e.g. npm, yum, dpkg etc.
    """

    package_manager_url: typing.Optional[UrlString] = pydantic.Field(default=None)
    """
    The URL of the package or library at the package manager, or the specific URL or URI of an internal package manager link such as <code>AWS CodeArtifact</code> or <code>Artifactory</code>.
    """

    path: typing.Optional[FilePath] = pydantic.Field(default=None)
    """
    The installation path of the affected package.
    """

    purl: typing.Optional[str] = pydantic.Field(default=None)
    """
    A purl is a URL string used to identify and locate a software package in a mostly universal and uniform way across programming languages, package managers, packaging conventions, tools, APIs and databases.
    """

    release: typing.Optional[str] = pydantic.Field(default=None)
    """
    Release is the number of times a version of the software has been packaged.
    """

    remediation: typing.Optional[Remediation] = pydantic.Field(default=None)
    """
    Describes the recommended remediation steps to address identified issue(s).
    """

    src_url: typing.Optional[UrlString] = pydantic.Field(default=None)
    """
    The link to the specific library or package such as within <code>GitHub</code>, this is different from the link to the package manager where the library or package is hosted.
    """

    type: typing.Optional[str] = pydantic.Field(default=None)
    """
    The type of software package, normalized to the caption of the <code>type_id</code> value. In the case of 'Other', it is defined by the source.
    """

    type_id: typing.Optional[AffectedPackageTypeId] = pydantic.Field(default=None)
    """
    The type of software package.
    """

    uid: typing.Optional[str] = pydantic.Field(default=None)
    """
    A unique identifier for the package or library reported by the source tool. E.g., the <code>libId</code> within the <code>sbom</code> field of an OX Security Issue or the SPDX <code>components.\*.bom-ref</code>.
    """

    vendor_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    The name of the vendor who published the software package.
    """

    version: str = pydantic.Field()
    """
    The software package version.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
            extra="allow"
        )  # type: ignore # Pydantic v2
    else:

        class Config:
            smart_union = True
            extra = pydantic.Extra.allow
