Debian Codegraph @

src/v4/metric/environmental/msc.rs

raw symbols SCIP
1 //! Confidentiality Impact to the Subsequent System (MSC)
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 Subsequent System (MSC) - 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 ModifiedConfidentialityImpactToTheSubsequentSystem {
23 /// Not Defined (X)
24 ///
25 /// > The metric has not been evaluated.
26 NotDefined,
27
28 /// Negligible (N)
29 ///
30 /// > There is no loss of confidentiality within the Subsequent System or
31 /// > all confidentiality impact is constrained to the Vulnerable System.
32 Negligible,
33
34 /// Low (L)
35 ///
36 /// > There is some loss of confidentiality. Access to some restricted
37 /// > information is obtained, but the attacker does not have control over
38 /// > what information is obtained, or the amount or kind of loss is
39 /// > limited. The information disclosure does not cause a direct, serious
40 /// > loss to the Subsequent System.
41 Low,
42
43 /// High (H)
44 ///
45 /// > There is a total loss of confidentiality, resulting in all resources
46 /// > within the Subsequent System being divulged to the attacker.
47 /// > Alternatively, access to only some restricted information is obtained,
48 /// > but the disclosed information presents a direct, serious impact. For
49 /// > example, an attacker steals the administrator's password, or private
50 /// > encryption keys of a web server.
51 High,
52 }
53
54 impl Default for ModifiedConfidentialityImpactToTheSubsequentSystem {
55 fn default() -> Self {
56 Self::NotDefined
57 }
58 }
59
60 impl Metric for ModifiedConfidentialityImpactToTheSubsequentSystem {
61 const TYPE: MetricType = MetricType::MSC;
62
63 fn as_str(self) -> &'static str {
64 match self {
65 ModifiedConfidentialityImpactToTheSubsequentSystem::NotDefined => "X",
66 ModifiedConfidentialityImpactToTheSubsequentSystem::Negligible => "N",
67 ModifiedConfidentialityImpactToTheSubsequentSystem::Low => "L",
68 ModifiedConfidentialityImpactToTheSubsequentSystem::High => "H",
69 }
70 }
71 }
72
73 impl fmt::Display for ModifiedConfidentialityImpactToTheSubsequentSystem {
74 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75 write!(f, "{}:{}", Self::name(), self.as_str())
76 }
77 }
78
79 impl FromStr for ModifiedConfidentialityImpactToTheSubsequentSystem {
80 type Err = Error;
81
82 fn from_str(s: &str) -> Result<Self> {
83 match s {
84 "X" => Ok(ModifiedConfidentialityImpactToTheSubsequentSystem::NotDefined),
85 "N" => Ok(ModifiedConfidentialityImpactToTheSubsequentSystem::Negligible),
86 "L" => Ok(ModifiedConfidentialityImpactToTheSubsequentSystem::Low),
87 "H" => Ok(ModifiedConfidentialityImpactToTheSubsequentSystem::High),
88 _ => Err(Error::InvalidMetricV4 {
89 metric_type: Self::TYPE,
90 value: s.to_owned(),
91 }),
92 }
93 }
94 }