Skip to content

Commit

Permalink
Zero functional changes, just moving cvss support into another
Browse files Browse the repository at this point in the history
crate to make room for adding CVSS4 support.
  • Loading branch information
Bob McWhirter authored and ctron committed Mar 19, 2024
1 parent 4c41495 commit 541816c
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 57 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"common",
"common/auth",
"common/infrastructure",
"cvss",
"modules/importer",
"entity",
"importer",
Expand Down
3 changes: 2 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
trustify-migration = { path = "../migration" }
trustify-cvss = { path = "../cvss" }

anyhow = "1.0.72"
clap = { version = "4", features = ["derive", "env"] }
Expand All @@ -14,7 +15,7 @@ log = "0.4.19"
native-tls = "0.2"
packageurl = "0.3.0"
pem = "3"
postgresql_embedded = { version = "0.6.2", features = ["blocking", "bundled", "tokio" ] }
postgresql_embedded = { version = "0.6.2", features = ["blocking", "bundled", "tokio"] }
reqwest = { version = "0.11", features = ["native-tls"] }
utoipa = "4"
sea-orm = { version = "0.12", features = ["sea-query-binder", "sqlx-postgres", "runtime-tokio-rustls", "macros"] }
Expand Down
2 changes: 0 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ pub mod purl;
pub mod reqwest;
pub mod sbom;
pub mod tls;

pub mod cvss3;
12 changes: 12 additions & 0 deletions cvss/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "trustify-cvss"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0.183", features = ["derive"] }
thiserror = "1"

[dev-dependencies]
test-log = { version = "0.2.15", features = ["env_logger", "trace"] }
tokio = { version = "1.30.0", features = ["full"] }
File renamed without changes.
1 change: 1 addition & 0 deletions cvss/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod cvss3;
5 changes: 3 additions & 2 deletions entity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ version = "0.1.0"
edition = "2021"

[dependencies]
sea-orm = { version = "0.12", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros", "with-json" ] }
sea-orm = { version = "0.12", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros", "with-json"] }
serde_json = "1"
time = "0.3"
tokio = { version = "1.30.0", features = ["full"] }
trustify-common = { path = "../common"}
trustify-common = { path = "../common" }
trustify-cvss = { path = "../cvss" }

[dev-dependencies]
anyhow = "1.0.72"
94 changes: 47 additions & 47 deletions entity/src/cvss3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::advisory;
use sea_orm::entity::prelude::*;
use trustify_common::cvss3::Cvss3Base;
use trustify_cvss::cvss3::Cvss3Base;

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cvss3")]
Expand Down Expand Up @@ -67,7 +67,7 @@ pub enum AttackVector {
Physical,
}

impl From<AttackVector> for trustify_common::cvss3::AttackVector {
impl From<AttackVector> for trustify_cvss::cvss3::AttackVector {
fn from(value: AttackVector) -> Self {
match value {
AttackVector::Network => Self::Network,
Expand All @@ -78,13 +78,13 @@ impl From<AttackVector> for trustify_common::cvss3::AttackVector {
}
}

impl From<trustify_common::cvss3::AttackVector> for AttackVector {
fn from(value: trustify_common::cvss3::AttackVector) -> Self {
impl From<trustify_cvss::cvss3::AttackVector> for AttackVector {
fn from(value: trustify_cvss::cvss3::AttackVector) -> Self {
match value {
trustify_common::cvss3::AttackVector::Network => Self::Network,
trustify_common::cvss3::AttackVector::Adjacent => Self::Adjacent,
trustify_common::cvss3::AttackVector::Local => Self::Local,
trustify_common::cvss3::AttackVector::Physical => Self::Physical,
trustify_cvss::cvss3::AttackVector::Network => Self::Network,
trustify_cvss::cvss3::AttackVector::Adjacent => Self::Adjacent,
trustify_cvss::cvss3::AttackVector::Local => Self::Local,
trustify_cvss::cvss3::AttackVector::Physical => Self::Physical,
}
}
}
Expand All @@ -98,7 +98,7 @@ pub enum AttackComplexity {
High,
}

impl From<AttackComplexity> for trustify_common::cvss3::AttackComplexity {
impl From<AttackComplexity> for trustify_cvss::cvss3::AttackComplexity {
fn from(value: AttackComplexity) -> Self {
match value {
AttackComplexity::Low => Self::Low,
Expand All @@ -107,11 +107,11 @@ impl From<AttackComplexity> for trustify_common::cvss3::AttackComplexity {
}
}

impl From<trustify_common::cvss3::AttackComplexity> for AttackComplexity {
fn from(value: trustify_common::cvss3::AttackComplexity) -> Self {
impl From<trustify_cvss::cvss3::AttackComplexity> for AttackComplexity {
fn from(value: trustify_cvss::cvss3::AttackComplexity) -> Self {
match value {
trustify_common::cvss3::AttackComplexity::Low => Self::Low,
trustify_common::cvss3::AttackComplexity::High => Self::High,
trustify_cvss::cvss3::AttackComplexity::Low => Self::Low,
trustify_cvss::cvss3::AttackComplexity::High => Self::High,
}
}
}
Expand All @@ -127,7 +127,7 @@ pub enum PrivilegesRequired {
High,
}

impl From<PrivilegesRequired> for trustify_common::cvss3::PrivilegesRequired {
impl From<PrivilegesRequired> for trustify_cvss::cvss3::PrivilegesRequired {
fn from(value: PrivilegesRequired) -> Self {
match value {
PrivilegesRequired::None => Self::None,
Expand All @@ -137,12 +137,12 @@ impl From<PrivilegesRequired> for trustify_common::cvss3::PrivilegesRequired {
}
}

impl From<trustify_common::cvss3::PrivilegesRequired> for PrivilegesRequired {
fn from(value: trustify_common::cvss3::PrivilegesRequired) -> Self {
impl From<trustify_cvss::cvss3::PrivilegesRequired> for PrivilegesRequired {
fn from(value: trustify_cvss::cvss3::PrivilegesRequired) -> Self {
match value {
trustify_common::cvss3::PrivilegesRequired::None => Self::None,
trustify_common::cvss3::PrivilegesRequired::Low => Self::Low,
trustify_common::cvss3::PrivilegesRequired::High => Self::High,
trustify_cvss::cvss3::PrivilegesRequired::None => Self::None,
trustify_cvss::cvss3::PrivilegesRequired::Low => Self::Low,
trustify_cvss::cvss3::PrivilegesRequired::High => Self::High,
}
}
}
Expand All @@ -156,7 +156,7 @@ pub enum UserInteraction {
Required,
}

impl From<UserInteraction> for trustify_common::cvss3::UserInteraction {
impl From<UserInteraction> for trustify_cvss::cvss3::UserInteraction {
fn from(value: UserInteraction) -> Self {
match value {
UserInteraction::None => Self::None,
Expand All @@ -165,11 +165,11 @@ impl From<UserInteraction> for trustify_common::cvss3::UserInteraction {
}
}

impl From<trustify_common::cvss3::UserInteraction> for UserInteraction {
fn from(value: trustify_common::cvss3::UserInteraction) -> Self {
impl From<trustify_cvss::cvss3::UserInteraction> for UserInteraction {
fn from(value: trustify_cvss::cvss3::UserInteraction) -> Self {
match value {
trustify_common::cvss3::UserInteraction::None => Self::None,
trustify_common::cvss3::UserInteraction::Required => Self::Required,
trustify_cvss::cvss3::UserInteraction::None => Self::None,
trustify_cvss::cvss3::UserInteraction::Required => Self::Required,
}
}
}
Expand All @@ -183,7 +183,7 @@ pub enum Scope {
Changed,
}

impl From<Scope> for trustify_common::cvss3::Scope {
impl From<Scope> for trustify_cvss::cvss3::Scope {
fn from(value: Scope) -> Self {
match value {
Scope::Unchanged => Self::Unchanged,
Expand All @@ -192,11 +192,11 @@ impl From<Scope> for trustify_common::cvss3::Scope {
}
}

impl From<trustify_common::cvss3::Scope> for Scope {
fn from(value: trustify_common::cvss3::Scope) -> Self {
impl From<trustify_cvss::cvss3::Scope> for Scope {
fn from(value: trustify_cvss::cvss3::Scope) -> Self {
match value {
trustify_common::cvss3::Scope::Unchanged => Self::Unchanged,
trustify_common::cvss3::Scope::Changed => Self::Changed,
trustify_cvss::cvss3::Scope::Unchanged => Self::Unchanged,
trustify_cvss::cvss3::Scope::Changed => Self::Changed,
}
}
}
Expand All @@ -212,7 +212,7 @@ pub enum Confidentiality {
High,
}

impl From<Confidentiality> for trustify_common::cvss3::Confidentiality {
impl From<Confidentiality> for trustify_cvss::cvss3::Confidentiality {
fn from(value: Confidentiality) -> Self {
match value {
Confidentiality::None => Self::None,
Expand All @@ -222,12 +222,12 @@ impl From<Confidentiality> for trustify_common::cvss3::Confidentiality {
}
}

impl From<trustify_common::cvss3::Confidentiality> for Confidentiality {
fn from(value: trustify_common::cvss3::Confidentiality) -> Self {
impl From<trustify_cvss::cvss3::Confidentiality> for Confidentiality {
fn from(value: trustify_cvss::cvss3::Confidentiality) -> Self {
match value {
trustify_common::cvss3::Confidentiality::None => Self::None,
trustify_common::cvss3::Confidentiality::Low => Self::Low,
trustify_common::cvss3::Confidentiality::High => Self::High,
trustify_cvss::cvss3::Confidentiality::None => Self::None,
trustify_cvss::cvss3::Confidentiality::Low => Self::Low,
trustify_cvss::cvss3::Confidentiality::High => Self::High,
}
}
}
Expand All @@ -243,7 +243,7 @@ pub enum Integrity {
High,
}

impl From<Integrity> for trustify_common::cvss3::Integrity {
impl From<Integrity> for trustify_cvss::cvss3::Integrity {
fn from(value: Integrity) -> Self {
match value {
Integrity::None => Self::None,
Expand All @@ -253,12 +253,12 @@ impl From<Integrity> for trustify_common::cvss3::Integrity {
}
}

impl From<trustify_common::cvss3::Integrity> for Integrity {
fn from(value: trustify_common::cvss3::Integrity) -> Self {
impl From<trustify_cvss::cvss3::Integrity> for Integrity {
fn from(value: trustify_cvss::cvss3::Integrity) -> Self {
match value {
trustify_common::cvss3::Integrity::None => Self::None,
trustify_common::cvss3::Integrity::Low => Self::Low,
trustify_common::cvss3::Integrity::High => Self::High,
trustify_cvss::cvss3::Integrity::None => Self::None,
trustify_cvss::cvss3::Integrity::Low => Self::Low,
trustify_cvss::cvss3::Integrity::High => Self::High,
}
}
}
Expand All @@ -274,7 +274,7 @@ pub enum Availability {
High,
}

impl From<Availability> for trustify_common::cvss3::Availability {
impl From<Availability> for trustify_cvss::cvss3::Availability {
fn from(value: Availability) -> Self {
match value {
Availability::None => Self::None,
Expand All @@ -284,12 +284,12 @@ impl From<Availability> for trustify_common::cvss3::Availability {
}
}

impl From<trustify_common::cvss3::Availability> for Availability {
fn from(value: trustify_common::cvss3::Availability) -> Self {
impl From<trustify_cvss::cvss3::Availability> for Availability {
fn from(value: trustify_cvss::cvss3::Availability) -> Self {
match value {
trustify_common::cvss3::Availability::None => Self::None,
trustify_common::cvss3::Availability::Low => Self::Low,
trustify_common::cvss3::Availability::High => Self::High,
trustify_cvss::cvss3::Availability::None => Self::None,
trustify_cvss::cvss3::Availability::Low => Self::Low,
trustify_cvss::cvss3::Availability::High => Self::High,
}
}
}
7 changes: 4 additions & 3 deletions graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
trustify-entity = { path = "../entity"}
trustify-entity = { path = "../entity" }
trustify-common = { path = "../common" }
trustify-migration = { path = "../migration" }
trustify-cvss = { path = "../cvss" }

sea-orm = { version = "0.12", features = [ "sea-query-binder", "sqlx-postgres", "runtime-tokio-rustls", "macros", "debug-print" ] }
sea-orm = { version = "0.12", features = ["sea-query-binder", "sqlx-postgres", "runtime-tokio-rustls", "macros", "debug-print"] }
sea-query = "0.30.0"
sea-orm-migration = "0.12.2"
tokio = { version = "1.30.0", features = ["full"] }
Expand All @@ -26,7 +27,7 @@ csaf = "0.5"
async-trait = "0.1.74"
lenient_semver = "0.4.2"
cpe = "0.1.3"
postgresql_embedded = { version = "0.6.2", features = ["blocking", "bundled", "tokio" ] }
postgresql_embedded = { version = "0.6.2", features = ["blocking", "bundled", "tokio"] }
tempfile = "3"


Expand Down
2 changes: 1 addition & 1 deletion graph/src/graph/advisory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::cmp::min;
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use trustify_common::advisory::{AdvisoryVulnerabilityAssertions, Assertion};
use trustify_common::cvss3::Cvss3Base;
use trustify_common::db::Transactional;
use trustify_common::purl::Purl;
use trustify_cvss::cvss3::Cvss3Base;
use trustify_entity as entity;

pub mod advisory_vulnerability;
Expand Down
1 change: 1 addition & 0 deletions ingestors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ publish = false
trustify-common = { path = "../common"}
trustify-graph = { path = "../graph"}
trustify-entity = { path = "../entity" }
trustify-cvss = { path = "../cvss" }

serde = { version = "1.0.183", features = ["derive"] }
serde_json = "1.0.114"
Expand Down
2 changes: 1 addition & 1 deletion ingestors/src/advisory/osv/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::advisory::osv::schema::SeverityType;
use crate::advisory::osv::schema::{Event, Package, Vulnerability};
use crate::hashing::HashingRead;
use crate::Error;
use trustify_common::cvss3::Cvss3Base;
use trustify_cvss::cvss3::Cvss3Base;

pub struct OsvLoader<'g> {
graph: &'g Graph,
Expand Down

0 comments on commit 541816c

Please sign in to comment.