nvd_cvss/metric/mod.rs
1//! 7.4. Metric Values
2//!
3//! Each metric value has an associated constant which is used in the formulas, as defined in Table 16.
4//!
5//! **Table 16: Metric values**
6//!
7//!
8//! | Metric | Metric Value | Numerical Value |
9//! | --- | --- | --- |
10//! | Attack Vector / Modified Attack Vector | Network | 0.85 |
11//! | | Adjacent | 0.62 |
12//! | | Local | 0.55 |
13//! | | Physical | 0.2 |
14//! | Attack Complexity / Modified Attack Complexity | Low | 0.77 |
15//! | | High | 0.44 |
16//! | Privileges Required / Modified Privileges Required | None | 0.85 |
17//! | | Low | 0.62 (or 0.68 if Scope / Modified Scope is Changed) |
18//! | | High | 0.27 (or 0.5 if Scope / Modified Scope is Changed) |
19//! | User Interaction / Modified User Interaction | None | 0.85 |
20//! | | Required | 0.62 |
21//! | Confidentiality / Integrity / Availability / Modified Confidentiality / Modified Integrity / Modified Availability | High | 0.56 |
22//! | | Low | 0.22 |
23//! | | None | 0 |
24//! | Exploit Code Maturity | Not Defined | 1 |
25//! | | High | 1 |
26//! | | Functional | 0.97 |
27//! | | Proof of Concept | 0.94 |
28//! | | Unproven | 0.91 |
29//! | Remediation Level | Not Defined | 1 |
30//! | | Unavailable | 1 |
31//! | | Workaround | 0.97 |
32//! | | Temporary Fix | 0.96 |
33//! | | Official Fix | 0.95 |
34//! | Report Confidence | Not Defined | 1 |
35//! | | Confirmed | 1 |
36//! | | Reasonable | 0.96 |
37//! | | Unknown | 0.92 |
38//! | Confidentiality Requirement / Integrity Requirement / Availability Requirement | Not Defined | 1 |
39//! | | High | 1.5 |
40//! | | Medium | 1 |
41//! | | Low | 0.5 |[](#body)
42//!
43mod v2;
44mod v3;
45mod v4;
46
47pub use crate::metric::v2::MetricTypeV2;
48pub use crate::metric::v3::MetricTypeV3;
49pub use crate::metric::v4::MetricTypeV4;
50use serde::{Deserialize, Serialize};
51use std::fmt::{Debug, Display};
52use std::str::FromStr;
53
54// TODO: 改宏定义
55#[derive(Debug, Clone)]
56pub struct Help {
57 pub worth: Worth,
58 pub des: String,
59}
60
61#[derive(Debug, Clone)]
62pub enum Worth {
63 /// 最严重的
64 Worst,
65 /// 比较严重的
66 Worse,
67 /// 坏
68 Bad,
69 /// 还好
70 Good,
71}
72
73pub trait Metric: Clone + Debug + FromStr + Display {
74 const TYPE: MetricType;
75 fn name() -> &'static str {
76 match Self::TYPE {
77 MetricType::V2(v2) => v2.name(),
78 MetricType::V3(v3) => v3.name(),
79 MetricType::V4(v4) => v4.name(),
80 }
81 }
82 fn help(&self) -> Help;
83 fn score(&self) -> f32;
84 fn as_str(&self) -> &'static str;
85}
86
87pub enum MetricType {
88 V2(MetricTypeV2),
89 V3(MetricTypeV3),
90 V4(MetricTypeV4),
91}
92
93#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
94pub enum MetricLevelType {
95 Primary,
96 Secondary,
97}
98
99impl Default for MetricLevelType {
100 fn default() -> Self {
101 Self::Primary
102 }
103}