Debian Codegraph @

src/v4/metric/supplemental/re.rs

raw symbols SCIP
1 //! Vulnerability Response Effort (RE)
2
3 use crate::{
4 Error, Result,
5 v4::metric::{Metric, MetricType},
6 };
7 use alloc::borrow::ToOwned;
8 use core::{fmt, str::FromStr};
9
10 /// Vulnerability Response Effort (RE) - CVSS v4.0 Supplemental Metric Group
11 ///
12 /// Described in CVSS v4.0 Specification: Section 5.6
13 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
14 pub enum VulnerabilityResponseEffort {
15 /// Not Defined (X)
16 ///
17 /// > The metric has not been evaluated.
18 NotDefined,
19
20 /// Low (L)
21 ///
22 /// > The effort required to respond to a vulnerability is low/trivial.
23 /// > Examples include: communication on better documentation, configuration
24 /// > workarounds, or guidance from the vendor that does **not** require an
25 /// > immediate update, upgrade, or replacement by the consuming entity,
26 /// > such as firewall filter configuration.
27 Low,
28 /// Moderate (M)
29 ///
30 /// > The actions required to respond to a vulnerability require some effort
31 /// > on behalf of the consumer and could cause minimal service impact to
32 /// > implement. Examples include: simple remote update, disabling of a
33 /// > subsystem, or a low-touch software upgrade such as a driver update.
34 Moderate,
35 /// High (H)
36 ///
37 /// > The actions required to respond to a vulnerability are significant
38 /// > and/or difficult, and may possibly lead to an extended, scheduled
39 /// > service impact. This would need to be considered for scheduling
40 /// > purposes including honoring any embargo on deployment of the selected
41 /// > response. Alternatively, response to the vulnerability in the field is
42 /// > not possible remotely. The only resolution to the vulnerability
43 /// > involves physical replacement (e.g. units deployed would have to be
44 /// > recalled for a depot level repair or replacement). Examples include: a
45 /// > highly privileged driver update, microcode or UEFI BIOS updates, or
46 /// > software upgrades requiring careful analysis and understanding of any
47 /// > potential infrastructure impact before implementation. A UEFI BIOS
48 /// > update that impacts Trusted Platform Module (TPM) attestation without
49 /// > impacting disk encryption software such as Bit locker is a good recent
50 /// > example. Irreparable failures such as non-bootable flash subsystems,
51 /// > failed disks or solid-state drives (SSD), bad memory modules, network
52 /// > devices, or other non-recoverable under warranty hardware, should also
53 /// > be scored as having a High effort.
54 High,
55 }
56
57 impl Default for VulnerabilityResponseEffort {
58 fn default() -> Self {
59 Self::NotDefined
60 }
61 }
62
63 impl Metric for VulnerabilityResponseEffort {
64 const TYPE: MetricType = MetricType::RE;
65
66 fn as_str(self) -> &'static str {
67 match self {
68 VulnerabilityResponseEffort::NotDefined => "X",
69 VulnerabilityResponseEffort::Low => "L",
70 VulnerabilityResponseEffort::Moderate => "M",
71 VulnerabilityResponseEffort::High => "H",
72 }
73 }
74 }
75
76 impl fmt::Display for VulnerabilityResponseEffort {
77 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
78 write!(f, "{}:{}", Self::name(), self.as_str())
79 }
80 }
81
82 impl FromStr for VulnerabilityResponseEffort {
83 type Err = Error;
84
85 fn from_str(s: &str) -> Result<Self> {
86 match s {
87 "X" => Ok(VulnerabilityResponseEffort::NotDefined),
88 "L" => Ok(VulnerabilityResponseEffort::Low),
89 "M" => Ok(VulnerabilityResponseEffort::Moderate),
90 "H" => Ok(VulnerabilityResponseEffort::High),
91 _ => Err(Error::InvalidMetricV4 {
92 metric_type: Self::TYPE,
93 value: s.to_owned(),
94 }),
95 }
96 }
97 }