Debian Codegraph @

src/v4/metric/environmental/msi.rs

raw symbols SCIP
1 //! Integrity Impact to the Subsequent System (MSI)
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 /// Integrity Impact to the Subsequent System (MSI) - 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 integrity of a successfully exploited
16 /// > vulnerability. Integrity refers to the trustworthiness and veracity of
17 /// > information. Integrity of a system is impacted when an attacker causes
18 /// > unauthorized modification of system data. Integrity is also impacted when
19 /// > a system user can repudiate critical actions taken in the context of the
20 /// > system (e.g. due to insufficient logging).
21 /// > The resulting score is greatest when the consequence to the system is
22 /// > highest.
23 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
24 pub enum ModifiedIntegrityImpactToTheSubsequentSystem {
25 /// Not Defined (X)
26 ///
27 /// > The metric has not been evaluated.
28 NotDefined,
29
30 /// Negligible (N)
31 ///
32 /// > There is no loss of integrity within the Subsequent System or all
33 /// > integrity impact is constrained to the Vulnerable System.
34 Negligible,
35
36 /// Low (L)
37 ///
38 /// > Modification of data is possible, but the attacker does not have
39 /// > control over the consequence of a modification, or the amount of
40 /// > modification is limited. The data modification does not have a direct,
41 /// > serious impact to the Subsequent System.
42 Low,
43
44 /// High (H)
45 ///
46 /// > There is a total loss of integrity, or a complete loss of protection.
47 /// > For example, the attacker is able to modify any/all files protected by
48 /// > the Subsequent System. Alternatively, only some files can be modified,
49 /// > but malicious modification would present a direct, serious consequence
50 /// > to the Subsequent System.
51 High,
52
53 /// Safety (S)
54 Safety,
55 }
56
57 impl Default for ModifiedIntegrityImpactToTheSubsequentSystem {
58 fn default() -> Self {
59 Self::NotDefined
60 }
61 }
62
63 impl Metric for ModifiedIntegrityImpactToTheSubsequentSystem {
64 const TYPE: MetricType = MetricType::MSI;
65
66 fn as_str(self) -> &'static str {
67 match self {
68 ModifiedIntegrityImpactToTheSubsequentSystem::NotDefined => "X",
69 ModifiedIntegrityImpactToTheSubsequentSystem::Negligible => "N",
70 ModifiedIntegrityImpactToTheSubsequentSystem::Low => "L",
71 ModifiedIntegrityImpactToTheSubsequentSystem::High => "H",
72 ModifiedIntegrityImpactToTheSubsequentSystem::Safety => "S",
73 }
74 }
75 }
76
77 impl fmt::Display for ModifiedIntegrityImpactToTheSubsequentSystem {
78 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79 write!(f, "{}:{}", Self::name(), self.as_str())
80 }
81 }
82
83 impl FromStr for ModifiedIntegrityImpactToTheSubsequentSystem {
84 type Err = Error;
85
86 fn from_str(s: &str) -> Result<Self> {
87 match s {
88 "X" => Ok(ModifiedIntegrityImpactToTheSubsequentSystem::NotDefined),
89 "N" => Ok(ModifiedIntegrityImpactToTheSubsequentSystem::Negligible),
90 "L" => Ok(ModifiedIntegrityImpactToTheSubsequentSystem::Low),
91 "H" => Ok(ModifiedIntegrityImpactToTheSubsequentSystem::High),
92 "S" => Ok(ModifiedIntegrityImpactToTheSubsequentSystem::Safety),
93 _ => Err(Error::InvalidMetricV4 {
94 metric_type: Self::TYPE,
95 value: s.to_owned(),
96 }),
97 }
98 }
99 }