Debian Codegraph @

src/v4/metric/environmental/mvc.rs

raw symbols SCIP
1 //! Confidentiality Impact to the Vulnerable System (MVC)
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 /// Confidentiality Impact to the Vulnerable System (MVC) - CVSS v4.0
11 /// Environmental Metric Group
12 ///
13 /// Described in CVSS v4.0 Specification: Section 4.2
14 ///
15 /// > This metric measures the impact to the confidentiality of the information
16 /// > managed by the system due to a successfully exploited vulnerability.
17 /// > Confidentiality refers to limiting information access and disclosure to
18 /// > only authorized users, as well as preventing access by, or disclosure to,
19 /// > unauthorized ones. The resulting score is greatest when the loss to the
20 /// > system is highest.
21 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
22 pub enum ModifiedConfidentialityImpactToTheVulnerableSystem {
23 /// Not Defined (X)
24 ///
25 /// > The metric has not been evaluated.
26 NotDefined,
27 /// None (N)
28 ///
29 /// > There is no loss of confidentiality within the Vulnerable System.
30 None,
31 /// Low (L)
32 ///
33 /// > There is some loss of confidentiality. Access to some restricted
34 /// > information is obtained, but the attacker does not have control over
35 /// > what information is obtained, or the amount or kind of loss is
36 /// > limited. The information disclosure does not cause a direct, serious
37 /// > loss to the Vulnerable System.
38 Low,
39 /// High (H)
40 ///
41 /// > There is a total loss of confidentiality, resulting in all information
42 /// > within the Vulnerable System being divulged to the attacker.
43 /// > Alternatively, access to only some restricted information is obtained,
44 /// > but the disclosed information presents a direct, serious impact. For
45 /// > example, an attacker steals the administrator's password, or private
46 /// > encryption keys of a web server.
47 High,
48 }
49
50 impl Default for ModifiedConfidentialityImpactToTheVulnerableSystem {
51 fn default() -> Self {
52 Self::NotDefined
53 }
54 }
55
56 impl Metric for ModifiedConfidentialityImpactToTheVulnerableSystem {
57 const TYPE: MetricType = MetricType::MVC;
58
59 fn as_str(self) -> &'static str {
60 match self {
61 ModifiedConfidentialityImpactToTheVulnerableSystem::NotDefined => "X",
62 ModifiedConfidentialityImpactToTheVulnerableSystem::None => "N",
63 ModifiedConfidentialityImpactToTheVulnerableSystem::Low => "L",
64 ModifiedConfidentialityImpactToTheVulnerableSystem::High => "H",
65 }
66 }
67 }
68
69 impl fmt::Display for ModifiedConfidentialityImpactToTheVulnerableSystem {
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 ModifiedConfidentialityImpactToTheVulnerableSystem {
76 type Err = Error;
77
78 fn from_str(s: &str) -> Result<Self> {
79 match s {
80 "X" => Ok(ModifiedConfidentialityImpactToTheVulnerableSystem::NotDefined),
81 "N" => Ok(ModifiedConfidentialityImpactToTheVulnerableSystem::None),
82 "L" => Ok(ModifiedConfidentialityImpactToTheVulnerableSystem::Low),
83 "H" => Ok(ModifiedConfidentialityImpactToTheVulnerableSystem::High),
84 _ => Err(Error::InvalidMetricV4 {
85 metric_type: Self::TYPE,
86 value: s.to_owned(),
87 }),
88 }
89 }
90 }