# Automatically generated by generate_types.py. Do not edit manually.
import enum

from pydantic import field_validator

from .base import CommonEntityType, load_entity_supported_types

__all__ = ["ThreatType", "ThreatTypes"]


class ThreatType(CommonEntityType):
    """
    ThreatType represents metadata for threats in Colander. Check :ref:`the list of supported types <threat_types>`.

    Example:
        >>> threat_type = ThreatTypes.TROJAN.value
        >>> print(threat_type.name)
        Trojan
    """

    @field_validator("short_name", mode="before")
    @classmethod
    def is_supported_type(cls, short_name: str):
        if short_name not in {t["short_name"] for t in load_entity_supported_types("threat")}:
            raise ValueError(f"{short_name} is not supported")
        return short_name


class ThreatTypes(enum.Enum):
    """
    ThreatTypes provides access to all supported threat types.

    This class loads threat type definitions from the threat types JSON file and exposes them as an enum.
    It also provides a method to look up a threat type by its short name.

    Example:
        >>> threat_type = ThreatTypes.TROJAN.value
        >>> print(threat_type.name)
        Trojan
        >>> default_type = ThreatTypes.by_short_name("nonexistent")
        >>> print(default_type.name)
        Generic
    """

    ADWARE = ThreatType(
        **{
            "short_name": "ADWARE",
            "name": "Adware",
            "description": "Software that automatically displays or downloads advertising material, often unwanted.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Adware - Software that automatically displays or downloads advertising material, often unwanted."""

    APT = ThreatType(
        **{
            "short_name": "APT",
            "name": "APT",
            "description": "Advanced Persistent Threat; a prolonged and targeted cyberattack by a well-resourced adversary.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """APT - Advanced Persistent Threat; a prolonged and targeted cyberattack by a well-resourced adversary."""

    BACKDOOR = ThreatType(
        **{
            "short_name": "BACKDOOR",
            "name": "Backdoor",
            "description": "Malware that allows unauthorized remote access to a compromised system.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Backdoor - Malware that allows unauthorized remote access to a compromised system."""

    BOTNET = ThreatType(
        **{
            "short_name": "BOTNET",
            "name": "Botnet",
            "description": "A network of compromised computers controlled by an attacker to perform coordinated tasks.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Botnet - A network of compromised computers controlled by an attacker to perform coordinated tasks."""

    BROWSER_HIJACKER = ThreatType(
        **{
            "short_name": "BROWSER_HIJACKER",
            "name": "Browser Hijacker",
            "description": "Malware that alters browser settings, redirects traffic, or injects unwanted ads.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Browser Hijacker - Malware that alters browser settings, redirects traffic, or injects unwanted ads."""

    CRYPTOJACKING = ThreatType(
        **{
            "short_name": "CRYPTOJACKING",
            "name": "Cryptojacking",
            "description": "Unauthorized use of a device to mine cryptocurrency.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Cryptojacking - Unauthorized use of a device to mine cryptocurrency."""

    CYBER_ATTACK = ThreatType(
        **{
            "short_name": "CYBER_ATTACK",
            "name": "Cyber Attack",
            "description": "An attempt by hackers to damage, disrupt, or gain unauthorized access to computer systems, networks, or devices.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Cyber Attack - An attempt by hackers to damage, disrupt, or gain unauthorized access to computer systems, networks, or devices."""

    CYBERCRIME = ThreatType(
        **{
            "short_name": "CYBERCRIME",
            "name": "Cybercrime",
            "description": "Criminal activities carried out using computers or the internet, including fraud, theft, and unauthorized access.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Cybercrime - Criminal activities carried out using computers or the internet, including fraud, theft, and unauthorized access."""

    DOXXING = ThreatType(
        **{
            "short_name": "DOXXING",
            "name": "Doxxing",
            "description": "The act of publicly revealing private or identifying information about an individual without their consent.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Doxxing - The act of publicly revealing private or identifying information about an individual without their consent."""

    DROPPER = ThreatType(
        **{
            "short_name": "DROPPER",
            "name": "Dropper",
            "description": "A type of malware designed to deliver and install other malicious software.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Dropper - A type of malware designed to deliver and install other malicious software."""

    EXPLOIT_KIT = ThreatType(
        **{
            "short_name": "EXPLOIT_KIT",
            "name": "Exploit Kit",
            "description": "A toolkit used to exploit vulnerabilities in software to deliver malware.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Exploit Kit - A toolkit used to exploit vulnerabilities in software to deliver malware."""

    GENERIC = ThreatType(
        **{
            "short_name": "GENERIC",
            "name": "Generic",
            "description": "A general or unspecified threat type that does not fit other categories.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Generic - A general or unspecified threat type that does not fit other categories."""

    HARASSMENT = ThreatType(
        **{
            "short_name": "HARASSMENT",
            "name": "Harassment",
            "description": "Unwanted behavior intended to intimidate, threaten, or disturb an individual, often through digital means.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Harassment - Unwanted behavior intended to intimidate, threaten, or disturb an individual, often through digital means."""

    INFO_STEALER = ThreatType(
        **{
            "short_name": "INFO_STEALER",
            "name": "Information Stealer",
            "description": "Malware designed to steal sensitive information such as credentials or financial data.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Information Stealer - Malware designed to steal sensitive information such as credentials or financial data."""

    LOADER = ThreatType(
        **{
            "short_name": "LOADER",
            "name": "Loader",
            "description": "Malware that loads and executes other malicious payloads on a system.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Loader - Malware that loads and executes other malicious payloads on a system."""

    MALVERTISING = ThreatType(
        **{
            "short_name": "MALVERTISING",
            "name": "Malvertising",
            "description": "The use of online advertising to spread malware.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Malvertising - The use of online advertising to spread malware."""

    MALWARE = ThreatType(
        **{
            "short_name": "MALWARE",
            "name": "Malware",
            "description": "A general term for any software intentionally designed to cause damage or unauthorized actions.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Malware - A general term for any software intentionally designed to cause damage or unauthorized actions."""

    MOBILE_MALWARE = ThreatType(
        **{
            "short_name": "MOBILE_MALWARE",
            "name": "Mobile Malware",
            "description": "A malware specifically targeting mobile devices to steal data or perform malicious actions.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Mobile Malware - A malware specifically targeting mobile devices to steal data or perform malicious actions."""

    PHISHING = ThreatType(
        **{
            "short_name": "PHISHING",
            "name": "Phishing",
            "description": "A technique to trick users into revealing sensitive information, often via fake emails or websites.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Phishing - A technique to trick users into revealing sensitive information, often via fake emails or websites."""

    PHYSICAL_ATTACK = ThreatType(
        **{
            "short_name": "PHYSICAL_ATTACK",
            "name": "Physical Attack",
            "description": "A threat involving physical actions intended to harm or compromise assets, infrastructure, or individuals.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Physical Attack - A threat involving physical actions intended to harm or compromise assets, infrastructure, or individuals."""

    RANSOMWARE = ThreatType(
        **{
            "short_name": "RANSOMWARE",
            "name": "Ransomware",
            "description": "Malware that encrypts data and demands payment for decryption.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Ransomware - Malware that encrypts data and demands payment for decryption."""

    RAT = ThreatType(
        **{
            "short_name": "RAT",
            "name": "Remote Access Trojan (RAT)",
            "description": "Malware that provides remote control over an infected system.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Remote Access Trojan (RAT) - Malware that provides remote control over an infected system."""

    ROOTKIT = ThreatType(
        **{
            "short_name": "ROOTKIT",
            "name": "Rootkit",
            "description": "Malware designed to hide its presence and provide privileged access to a system.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Rootkit - Malware designed to hide its presence and provide privileged access to a system."""

    SPAM = ThreatType(
        **{
            "short_name": "SPAM",
            "name": "Spam",
            "description": "Unsolicited or bulk messages, often used to deliver malware or phishing attempts.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Spam - Unsolicited or bulk messages, often used to deliver malware or phishing attempts."""

    SPYWARE = ThreatType(
        **{
            "short_name": "SPYWARE",
            "name": "Spyware",
            "description": "Malware that secretly gathers user information without consent.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Spyware - Malware that secretly gathers user information without consent."""

    STALKERWARE = ThreatType(
        **{
            "short_name": "STALKERWARE",
            "name": "Stalkerware",
            "description": "Software used to secretly monitor and track user activity, often for surveillance.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Stalkerware - Software used to secretly monitor and track user activity, often for surveillance."""

    TROJAN = ThreatType(
        **{
            "short_name": "TROJAN",
            "name": "Trojan",
            "description": "Malware disguised as legitimate software to trick users into installing it.",
            "icon": "",
            "nf_icon": "nf nf-fa-bug",
        }
    )
    """Trojan - Malware disguised as legitimate software to trick users into installing it."""

    default = GENERIC  # type: ignore[attr-defined]

    @classmethod
    def by_short_name(cls, short_name: str):
        sn = short_name.replace(" ", "_").upper()
        if sn in cls._member_names_:
            return cls[sn].value
        return cls.default.value

    @classmethod
    def suggest(cls, value: str) -> ThreatType:
        return cls.by_short_name(value)
