Debian Codegraph @

src/v4/metric/environmental/mvi.rs

raw symbols SCIP
1 //! Integrity Impact to the Vulnerable System (MVI)
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 Vulnerable System (MVI) - 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 ModifiedIntegrityImpactToTheVulnerableSystem {
25 /// Not Defined (X)
26 ///
27 /// > The metric has not been evaluated.
28 NotDefined,
29 /// None (N)
30 ///
31 /// > There is no loss of integrity within the Vulnerable System.
32 None,
33 /// Low (L)
34 ///
35 /// > Modification of data is possible, but the attacker does not have
36 /// > control over the consequence of a modification, or the amount of
37 /// > modification is limited. The data modification does not have a direct,
38 /// > serious impact to the Vulnerable System.
39 Low,
40 /// High (H)
41 ///
42 /// > There is a total loss of integrity, or a complete loss of protection.
43 /// > For example, the attacker is able to modify any/all files protected by
44 /// > the Vulnerable System. Alternatively, only some files can be modified,
45 /// > but malicious modification would present a direct, serious consequence
46 /// > to the Vulnerable System.
47 High,
48 }
49
50 impl Default for ModifiedIntegrityImpactToTheVulnerableSystem {
51 fn default() -> Self {
52 Self::NotDefined
53 }
54 }
55
56 impl Metric for ModifiedIntegrityImpactToTheVulnerableSystem {
57 const TYPE: MetricType = MetricType::MVI;
58
59 fn as_str(self) -> &'static str {
60 match self {
61 ModifiedIntegrityImpactToTheVulnerableSystem::NotDefined => "X",
62 ModifiedIntegrityImpactToTheVulnerableSystem::None => "N",
63 ModifiedIntegrityImpactToTheVulnerableSystem::Low => "L",
64 ModifiedIntegrityImpactToTheVulnerableSystem::High => "H",
65 }
66 }
67 }
68
69 impl fmt::Display for ModifiedIntegrityImpactToTheVulnerableSystem {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 write!(f, "{}:{}", Self::name(), self.as_str())
72 }
73 }
74
75 impl FromStr for ModifiedIntegrityImpactToTheVulnerableSystem {
76 type Err = Error;
77
78 fn from_str(s: &str) -> Result<Self> {
79 match s {
80 "X" => Ok(ModifiedIntegrityImpactToTheVulnerableSystem::NotDefined),
81 "N" => Ok(ModifiedIntegrityImpactToTheVulnerableSystem::None),
82 "L" => Ok(ModifiedIntegrityImpactToTheVulnerableSystem::Low),
83 "H" => Ok(ModifiedIntegrityImpactToTheVulnerableSystem::High),
84 _ => Err(Error::InvalidMetricV4 {
85 metric_type: Self::TYPE,
86 value: s.to_owned(),
87 }),
88 }
89 }
90 }