Debian Codegraph @

src/v4/metric/environmental/msa.rs

raw symbols SCIP
1 //! Availability Impact to the Subsequent System (MSA)
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 Subsequent System (MSA) - 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 ModifiedAvailabilityImpactToTheSubsequentSystem {
27 /// Not Defined (X)
28 ///
29 /// > The metric has not been evaluated.
30 NotDefined,
31
32 /// Negligible (N)
33 ///
34 /// > There is no impact to availability within the Subsequent System or all
35 /// > availability impact is constrained to the Vulnerable System.
36 Negligible,
37
38 /// Low (L)
39 ///
40 /// > Performance is reduced or there are interruptions in resource
41 /// > availability. Even if repeated exploitation of the vulnerability is
42 /// > possible, the attacker does not have the ability to completely deny
43 /// > service to legitimate users. The resources in the Subsequent System
44 /// > are either partially available all of the time, or fully available
45 /// > only some of the time, but overall there is no direct, serious
46 /// > consequence to the Subsequent System.
47 Low,
48
49 /// High (H)
50 ///
51 /// > There is a total loss of availability, resulting in the attacker being
52 /// > able to fully deny access to resources in the Subsequent System; this
53 /// > loss is either sustained (while the attacker continues to deliver the
54 /// > attack) or persistent (the condition persists even after the attack
55 /// > has completed). Alternatively, the attacker has the ability to deny
56 /// > some availability, but the loss of availability presents a direct,
57 /// > serious consequence to the Subsequent System (e.g., the attacker
58 /// > cannot disrupt existing connections, but can prevent new connections;
59 /// > the attacker can repeatedly exploit a vulnerability that, in each
60 /// > instance of a successful attack, leaks a only small amount of memory,
61 /// > but after repeated exploitation causes a service to become completely
62 /// > unavailable).
63 High,
64
65 /// Safety (S)
66 Safety,
67 }
68
69 impl Default for ModifiedAvailabilityImpactToTheSubsequentSystem {
70 fn default() -> Self {
71 Self::NotDefined
72 }
73 }
74
75 impl Metric for ModifiedAvailabilityImpactToTheSubsequentSystem {
76 const TYPE: MetricType = MetricType::MSA;
77
78 fn as_str(self) -> &'static str {
79 match self {
80 ModifiedAvailabilityImpactToTheSubsequentSystem::NotDefined => "X",
81 ModifiedAvailabilityImpactToTheSubsequentSystem::Negligible => "N",
82 ModifiedAvailabilityImpactToTheSubsequentSystem::Low => "L",
83 ModifiedAvailabilityImpactToTheSubsequentSystem::High => "H",
84 ModifiedAvailabilityImpactToTheSubsequentSystem::Safety => "S",
85 }
86 }
87 }
88
89 impl fmt::Display for ModifiedAvailabilityImpactToTheSubsequentSystem {
90 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
91 write!(f, "{}:{}", Self::name(), self.as_str())
92 }
93 }
94
95 impl FromStr for ModifiedAvailabilityImpactToTheSubsequentSystem {
96 type Err = Error;
97
98 fn from_str(s: &str) -> Result<Self> {
99 match s {
100 "X" => Ok(ModifiedAvailabilityImpactToTheSubsequentSystem::NotDefined),
101 "N" => Ok(ModifiedAvailabilityImpactToTheSubsequentSystem::Negligible),
102 "L" => Ok(ModifiedAvailabilityImpactToTheSubsequentSystem::Low),
103 "H" => Ok(ModifiedAvailabilityImpactToTheSubsequentSystem::High),
104 "S" => Ok(ModifiedAvailabilityImpactToTheSubsequentSystem::Safety),
105 _ => Err(Error::InvalidMetricV4 {
106 metric_type: Self::TYPE,
107 value: s.to_owned(),
108 }),
109 }
110 }
111 }