Debian Codegraph @

src/v4/metric/environmental/mva.rs

raw symbols SCIP
1 //! Availability Impact to the Vulnerable System (MVA)
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 /// Availability Impact to the Vulnerable System (MVA) - CVSS v4.0 Environmental
11 /// Metric Group
12 ///
13 /// Described in CVSS v4.0 Specification: Section 4.2
14 ///
15 /// > This metric measures the impact to the availability of the impacted system
16 /// > resulting from a successfully exploited vulnerability. While the
17 /// > Confidentiality and Integrity impact metrics apply to the loss of
18 /// > confidentiality or integrity of data (e.g., information, files) used by
19 /// > the system, this metric refers to the loss of availability of the impacted
20 /// > system itself, such as a networked service (e.g., web, database, email).
21 /// > Since availability refers to the accessibility of information resources,
22 /// > attacks that consume network bandwidth, processor cycles, or disk space
23 /// > all impact the availability of a system. The resulting score is greatest
24 /// > when the consequence to the system is highest.
25 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
26 pub enum ModifiedAvailabilityImpactToTheVulnerableSystem {
27 /// Not Defined (X)
28 ///
29 /// > The metric has not been evaluated.
30 NotDefined,
31 /// None (N)
32 ///
33 /// > There is no impact to availability within the Vulnerable System.
34 None,
35 /// Low (L)
36 ///
37 /// > Performance is reduced or there are interruptions in resource
38 /// > availability. Even if repeated exploitation of the vulnerability is
39 /// > possible, the attacker does not have the ability to completely deny
40 /// > service to legitimate users. The resources in the Vulnerable System
41 /// > are either partially available all of the time, or fully available
42 /// > only some of the time, but overall there is no direct, serious
43 /// > consequence to the Vulnerable System.
44 Low,
45 /// High (H)
46 ///
47 /// > There is a total loss of availability, resulting in the attacker being
48 /// > able to fully deny access to resources in the Vulnerable System; this
49 /// > loss is either sustained (while the attacker continues to deliver the
50 /// > attack) or persistent (the condition persists even after the attack
51 /// > has completed). Alternatively, the attacker has the ability to deny
52 /// > some availability, but the loss of availability presents a direct,
53 /// > serious consequence to the Vulnerable System (e.g., the attacker
54 /// > cannot disrupt existing connections, but can prevent new connections;
55 /// > the attacker can repeatedly exploit a vulnerability that, in each
56 /// > instance of a successful attack, leaks a only small amount of memory,
57 /// > but after repeated exploitation causes a service to become completely
58 /// > unavailable).
59 High,
60 }
61
62 impl Default for ModifiedAvailabilityImpactToTheVulnerableSystem {
63 fn default() -> Self {
64 Self::NotDefined
65 }
66 }
67
68 impl Metric for ModifiedAvailabilityImpactToTheVulnerableSystem {
69 const TYPE: MetricType = MetricType::MVA;
70
71 fn as_str(self) -> &'static str {
72 match self {
73 ModifiedAvailabilityImpactToTheVulnerableSystem::NotDefined => "X",
74 ModifiedAvailabilityImpactToTheVulnerableSystem::None => "N",
75 ModifiedAvailabilityImpactToTheVulnerableSystem::Low => "L",
76 ModifiedAvailabilityImpactToTheVulnerableSystem::High => "H",
77 }
78 }
79 }
80
81 impl fmt::Display for ModifiedAvailabilityImpactToTheVulnerableSystem {
82 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
83 write!(f, "{}:{}", Self::name(), self.as_str())
84 }
85 }
86
87 impl FromStr for ModifiedAvailabilityImpactToTheVulnerableSystem {
88 type Err = Error;
89
90 fn from_str(s: &str) -> Result<Self> {
91 match s {
92 "X" => Ok(ModifiedAvailabilityImpactToTheVulnerableSystem::NotDefined),
93 "N" => Ok(ModifiedAvailabilityImpactToTheVulnerableSystem::None),
94 "L" => Ok(ModifiedAvailabilityImpactToTheVulnerableSystem::Low),
95 "H" => Ok(ModifiedAvailabilityImpactToTheVulnerableSystem::High),
96 _ => Err(Error::InvalidMetricV4 {
97 metric_type: Self::TYPE,
98 value: s.to_owned(),
99 }),
100 }
101 }
102 }