Skip to content

Commit

Permalink
Loader for the CWE Catalog (.xml.zip)
Browse files Browse the repository at this point in the history
Make format-detection more less-nested.
- Try'em all in-order until we find a match
Wire up endpoints for /api/v1/weakness and /api/v1/weakness/{id}

todo: an importer
  • Loading branch information
Bob McWhirter committed Aug 27, 2024
1 parent b7c0398 commit 2f4268f
Show file tree
Hide file tree
Showing 24 changed files with 977 additions and 65 deletions.
138 changes: 137 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ rand = "0.8.5"
regex = "1.10.3"
reqwest = "0.12"
ring = "0.17.8"
roxmltree = "0.20.0"
rstest = "0.22"
rust-s3 = "0.34"
sbom-walker = { version = "0.9.0", default-features = false, features = ["crypto-openssl", "cyclonedx-bom", "spdx-rs"] }
Expand Down Expand Up @@ -132,6 +133,7 @@ uuid = "1.7.0"
walkdir = "2.5"
walker-common = "0.9.0"
walker-extras = "0.9.0"
zip = "2.2.0"

trustify-auth = { path = "common/auth", features = ["actix", "swagger"] }
trustify-common = { path = "common" }
Expand Down
1 change: 1 addition & 0 deletions entity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ pub mod version_scheme;
pub mod versioned_purl;
pub mod vulnerability;
pub mod vulnerability_description;
pub mod weakness;
24 changes: 24 additions & 0 deletions entity/src/weakness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "weakness")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
pub description: Option<String>,
pub extended_description: Option<String>,
pub child_of: Option<Vec<String>>,
pub parent_of: Option<Vec<String>>,
pub starts_with: Option<Vec<String>>,
pub can_follow: Option<Vec<String>>,
pub can_precede: Option<Vec<String>>,
pub required_by: Option<Vec<String>>,
pub requires: Option<Vec<String>>,
pub can_also_be: Option<Vec<String>>,
pub peer_of: Option<Vec<String>>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
Binary file added etc/test-data/cwec_latest.xml.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mod m0000040_create_vulnerability;
mod m0000050_create_vulnerability_description;
mod m0000060_create_advisory;
mod m0000070_create_cvss3;
mod m0000070_create_cwe;
mod m0000080_create_cvss4;
pub mod m0000090_create_advisory_vulnerability;
mod m0000100_create_package;
Expand Down Expand Up @@ -70,6 +69,7 @@ mod m0000550_create_cpe_license_assertion;
mod m0000560_alter_vulnerability_cwe_column;
mod m0000565_alter_advisory_vulnerability_cwe_column;
mod m0000570_add_import_progress;
mod m0000575_create_weakness;

pub struct Migrator;

Expand Down Expand Up @@ -146,6 +146,7 @@ impl MigratorTrait for Migrator {
Box::new(m0000560_alter_vulnerability_cwe_column::Migration),
Box::new(m0000565_alter_advisory_vulnerability_cwe_column::Migration),
Box::new(m0000570_add_import_progress::Migration),
Box::new(m0000575_create_weakness::Migration),
]
}
}
Expand Down
49 changes: 0 additions & 49 deletions migration/src/m0000070_create_cwe.rs

This file was deleted.

Loading

0 comments on commit 2f4268f

Please sign in to comment.