CVSS

Enum CVSS 

Source
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

Source

pub fn parse<S>(cvss_str: S) -> Result<CVSS, ParseError>
where S: AsRef<str>,

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§

Source§

impl Debug for CVSS

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.