#!/usr/bin/env python
"""
Provides the Exploitation decision point and its values.
"""
#  Copyright (c) 2024-2025 Carnegie Mellon University.
#  NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE
#  ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS.
#  CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND,
#  EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT
#  NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR
#  MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE
#  OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE
#  ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM
#  PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
#  Licensed under a MIT (SEI)-style license, please see LICENSE or contact
#  permission@sei.cmu.edu for full terms.
#  [DISTRIBUTION STATEMENT A] This material has been approved for
#  public release and unlimited distribution. Please see Copyright notice
#  for non-US Government use and distribution.
#  This Software includes and/or makes use of Third-Party Software each
#  subject to its own license.
#  DM24-0278

from ssvc.decision_points.base import DecisionPointValue
from ssvc.decision_points.helpers import print_versions_and_diffs
from ssvc.decision_points.ssvc.base import SsvcDecisionPoint

ACTIVE = DecisionPointValue(
    name="Active",
    key="A",
    definition="Shared, observable, reliable evidence that the exploit is being"
    " used in the wild by real attackers; there is credible public reporting.",
)

POC_1 = DecisionPointValue(
    name="PoC",
    key="P",
    definition="One of the following cases is true: (1) private evidence of exploitation is attested but not shared; "
    "(2) widespread hearsay attests to exploitation; (3) typical public PoC in places such as Metasploit"
    " or ExploitDB; or (4) the vulnerability has a well-known method of exploitation.",
)

POC_2 = DecisionPointValue(
    name="Public PoC",
    key="P",
    definition="One of the following is true: (1) Typical public PoC exists in sources such as Metasploit or websites like ExploitDB; or (2) the vulnerability has a well-known method of exploitation.",
)

EXP_NONE = DecisionPointValue(
    name="None",
    key="N",
    definition="There is no evidence of active exploitation and no public proof of concept (PoC) of how to exploit the vulnerability.",
)


def _strip_spaces(s):
    return " ".join([x.strip() for x in s.splitlines()])


EXPLOITATION_1 = SsvcDecisionPoint(
    name="Exploitation",
    definition="The present state of exploitation of the vulnerability.",
    key="E",
    version="1.0.0",
    values=(
        EXP_NONE,
        POC_1,
        ACTIVE,
    ),
)

EXPLOITATION_1_1_0 = SsvcDecisionPoint(
    name="Exploitation",
    definition="The present state of exploitation of the vulnerability.",
    key="E",
    version="1.1.0",
    values=(
        EXP_NONE,
        POC_2,
        ACTIVE,
    ),
)

VERSIONS = (EXPLOITATION_1, EXPLOITATION_1_1_0)
LATEST = VERSIONS[-1]


def main():
    print_versions_and_diffs(VERSIONS)


if __name__ == "__main__":
    main()
