pub enum CVSS {
V3(V3Vector),
V2(V2Vector),
}Expand description
Enum type and parser for CVSS of all supported versions.
use cvssrust::CVSS;
let vector = "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N";
match CVSS::parse(vector) {
Ok(CVSS::V3(cvss)) => {
println!("CVSS v3 vector: {}", cvss.to_string());
},
Ok(CVSS::V2(cvss)) => {
println!("CVSS v2 vector: {}", cvss.to_string());
},
_ => println!("Could not parse the CVSS vector"),
}Variants§
Implementations§
Source§impl CVSS
impl CVSS
Sourcepub fn parse<S>(cvss_str: S) -> Result<CVSS, ParseError>
pub fn parse<S>(cvss_str: S) -> Result<CVSS, ParseError>
Examples found in repository?
examples/calc.rs (line 7)
4fn main() {
5 let vector = env::args().skip(1).next().expect("Provide CVSS vector");
6
7 match CVSS::parse(vector.as_str()) {
8 Ok(CVSS::V3(cvss)) => {
9 println!("CVSS v3 vector: {}", cvss.to_string());
10 println!("CVSS Base score: {}", cvss.base_score().value());
11 println!("CVSS Base severity: {}", cvss.base_score().severity());
12 println!("Impact Subscore: {}", cvss.impact_score().value());
13 println!(
14 "Exploitability Subscore: {}",
15 cvss.expoitability_score().value()
16 );
17 println!("CVSS Temporal score: {}", cvss.temporal_score().value());
18 println!(
19 "CVSS Environmental score: {}",
20 cvss.environmental_score().value()
21 );
22 println!(
23 "Modified Impact Subscore: {}",
24 cvss.modified_impact_score().value()
25 );
26 println!(
27 "Modified Exploitability Subscore: {}",
28 cvss.modified_exploitability_score().value()
29 );
30 }
31 Ok(CVSS::V2(cvss)) => {
32 println!("CVSS v2 vector: {}", cvss.to_string());
33 println!("CVSS Base score: {}", cvss.base_score().value());
34 println!("CVSS Base severity: {}", cvss.base_score().severity());
35 println!("Impact Subscore: {}", cvss.impact_score().value());
36 println!(
37 "Exploitability Subscore: {}",
38 cvss.expoitability_score().value()
39 );
40 println!("CVSS Temporal score: {}", cvss.temporal_score().value());
41 println!(
42 "CVSS Environmental score: {}",
43 cvss.environmental_score().value()
44 );
45 }
46 _ => println!("Could not parse the CVSS vector"),
47 }
48}Trait Implementations§
Auto Trait Implementations§
impl Freeze for CVSS
impl RefUnwindSafe for CVSS
impl Send for CVSS
impl Sync for CVSS
impl Unpin for CVSS
impl UnwindSafe for CVSS
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more