feat(vex): VEX status on CVE alerts, OpenVEX and CycloneDX VEX, a valid CycloneDX SBOM (#498, 1/4) (#502)
This commit was merged in pull request #502.
This commit is contained in:
1 parent
b7dbd8f196
commit
9bf7aad5b1
26 files changed
+6472
-41
No files matched your search
Generated
+183
@@ -52,6 +52,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"getrandom 0.3.4",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
@@ -294,6 +295,21 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.11.0"
|
||||
@@ -402,6 +418,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "borrow-or-share"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c"
|
||||
|
||||
[[package]]
|
||||
name = "bson"
|
||||
version = "2.15.0"
|
||||
@@ -432,6 +454,12 @@ version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
@@ -724,6 +752,7 @@ dependencies = [
|
||||
"bson",
|
||||
"chrono",
|
||||
"hex",
|
||||
"jsonschema",
|
||||
"jsonwebtoken",
|
||||
"mongodb",
|
||||
"opentelemetry",
|
||||
@@ -2077,6 +2106,15 @@ version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "email_address"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.35"
|
||||
@@ -2145,6 +2183,17 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastdivide"
|
||||
version = "0.4.2"
|
||||
@@ -2230,6 +2279,17 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fluent-uri"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1918b65d96df47d3591bed19c5cca17e3fa5d0707318e4b5ef2eae01764df7e5"
|
||||
dependencies = [
|
||||
"borrow-or-share",
|
||||
"ref-cast",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
@@ -2272,6 +2332,16 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fraction"
|
||||
version = "0.15.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e076045bb43dac435333ed5f04caf35c7463631d0dae2deb2638d94dd0a5b872"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs4"
|
||||
version = "0.13.1"
|
||||
@@ -3187,6 +3257,32 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonschema"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d46662859bc5f60a145b75f4632fbadc84e829e45df6c5de74cfc8e05acb96b5"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"base64",
|
||||
"bytecount",
|
||||
"email_address",
|
||||
"fancy-regex",
|
||||
"fraction",
|
||||
"idna",
|
||||
"itoa",
|
||||
"num-cmp",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"referencing",
|
||||
"regex",
|
||||
"regex-syntax",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"uuid-simd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonwebtoken"
|
||||
version = "9.3.1"
|
||||
@@ -3799,6 +3895,20 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-complex",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
@@ -3809,6 +3919,21 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-cmp"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa"
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.0"
|
||||
@@ -3835,6 +3960,27 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -4078,6 +4224,12 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "outref"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e"
|
||||
|
||||
[[package]]
|
||||
name = "ownedbytes"
|
||||
version = "0.9.0"
|
||||
@@ -4605,6 +4757,20 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "referencing"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e9c261f7ce75418b3beadfb3f0eb1299fe8eb9640deba45ffa2cb783098697d"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"fluent-uri",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"percent-encoding",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.3"
|
||||
@@ -6553,6 +6719,17 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid-simd"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8"
|
||||
dependencies = [
|
||||
"outref",
|
||||
"uuid",
|
||||
"vsimd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.1"
|
||||
@@ -6571,6 +6748,12 @@ version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vsimd"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
|
||||
@@ -84,6 +84,7 @@ async fn load_inputs(
|
||||
.map_err(load_err)?,
|
||||
catalog: crate::controls::cra_catalog(&agent.config).await,
|
||||
target,
|
||||
author: String::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -180,7 +181,8 @@ pub async fn evidence_pack(
|
||||
Path(id): Path<String>,
|
||||
) -> Result<impl IntoResponse, StatusCode> {
|
||||
let db = tenant_db(&agent, &tenant).await?;
|
||||
let inputs = load_inputs(&agent, &db, &id).await?;
|
||||
let mut inputs = load_inputs(&agent, &db, &id).await?;
|
||||
inputs.author = tenant.0.tenant_slug.clone();
|
||||
|
||||
let now = chrono::Utc::now();
|
||||
let (zip, _files) = tokio::task::spawn_blocking(move || build_pack(&inputs, now))
|
||||
|
||||
@@ -191,18 +191,18 @@ pub async fn get_finding(
|
||||
/// that needs a reason (an accepted risk, a wrong CRA mapping) comes without
|
||||
/// one.
|
||||
/// Who changes a finding, as its history records it.
|
||||
struct Actor<'a> {
|
||||
pub(crate) struct Actor<'a> {
|
||||
/// The Keycloak user id.
|
||||
id: &'a str,
|
||||
pub id: &'a str,
|
||||
/// The name the customer reads; "BreakPilot-Support (name)" for support.
|
||||
name: Option<String>,
|
||||
pub name: Option<String>,
|
||||
/// BreakPilot support rather than one of the tenant's users.
|
||||
support: bool,
|
||||
pub support: bool,
|
||||
}
|
||||
|
||||
impl<'a> Actor<'a> {
|
||||
/// The requester of `ctx`.
|
||||
fn of(ctx: &'a compliance_core::TenantContext) -> Self {
|
||||
pub(crate) fn of(ctx: &'a compliance_core::TenantContext) -> Self {
|
||||
Self {
|
||||
id: &ctx.user_id,
|
||||
name: match &ctx.staff {
|
||||
|
||||
@@ -24,6 +24,7 @@ pub mod sbom;
|
||||
pub mod scans;
|
||||
pub mod support;
|
||||
pub mod target_input;
|
||||
pub mod vex;
|
||||
pub mod werkbank_jobs;
|
||||
|
||||
// Re-export all handler functions so routes.rs can use `handlers::function_name`
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
//! VEX for a target's CVE alerts (#498): list them, state their status, and
|
||||
//! export the statements as OpenVEX or CycloneDX VEX.
|
||||
|
||||
use axum::extract::{Extension, Path, Query};
|
||||
use axum::http::{header, HeaderValue, StatusCode};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::Json;
|
||||
use mongodb::bson::{doc, oid::ObjectId};
|
||||
use serde::Deserialize;
|
||||
|
||||
use compliance_core::models::{CveAlert, SbomEntry, VexAssessment, VexJustification, VexStatus};
|
||||
use compliance_core::tenant_ctx::TenantCtx;
|
||||
use compliance_core::vex_docs::{self, VexInput};
|
||||
|
||||
use super::dto::{collect_cursor_async, tenant_db, AgentExt, ApiResponse, ApiResult};
|
||||
use super::findings::Actor;
|
||||
|
||||
/// GET /api/v1/targets/{id}/cves — the target's CVE alerts with their VEX
|
||||
/// statements, newest first.
|
||||
#[tracing::instrument(skip_all, fields(target_id = %id))]
|
||||
pub async fn list_target_cves(
|
||||
Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
Path(id): Path<String>,
|
||||
) -> ApiResult<Vec<CveAlert>> {
|
||||
let db = tenant_db(&agent, &tenant).await?;
|
||||
let alerts: Vec<CveAlert> = match db
|
||||
.cve_alerts()
|
||||
.find(doc! { "repo_id": &id })
|
||||
.sort(doc! { "created_at": -1 })
|
||||
.await
|
||||
{
|
||||
Ok(cursor) => collect_cursor_async(cursor).await,
|
||||
Err(e) => {
|
||||
tracing::warn!("Failed to list CVE alerts: {e}");
|
||||
Vec::new()
|
||||
}
|
||||
};
|
||||
Ok(Json(ApiResponse {
|
||||
total: Some(alerts.len() as u64),
|
||||
data: alerts,
|
||||
page: None,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The body of [`set_cve_vex`].
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct VexRequest {
|
||||
pub status: VexStatus,
|
||||
#[serde(default)]
|
||||
pub justification: Option<VexJustification>,
|
||||
#[serde(default)]
|
||||
pub impact_statement: Option<String>,
|
||||
#[serde(default)]
|
||||
pub action_statement: Option<String>,
|
||||
}
|
||||
|
||||
/// The statement `req` asks for, by the requester of `tenant`.
|
||||
fn statement(req: VexRequest, tenant: &TenantCtx) -> VexAssessment {
|
||||
let actor = Actor::of(&tenant.0);
|
||||
let text = |s: Option<String>| s.map(|t| t.trim().to_string()).filter(|t| !t.is_empty());
|
||||
VexAssessment {
|
||||
status: req.status,
|
||||
justification: req.justification,
|
||||
impact_statement: text(req.impact_statement),
|
||||
action_statement: text(req.action_statement),
|
||||
by: actor.id.to_string(),
|
||||
by_name: actor.name,
|
||||
at: chrono::Utc::now(),
|
||||
by_scan: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// PATCH /api/v1/cves/{id}/vex — state the VEX status of an alert. 422 with
|
||||
/// the reason when a `not_affected` comes without a justification or impact
|
||||
/// statement, or an `affected` without an action statement.
|
||||
#[tracing::instrument(skip_all, fields(alert_id = %id))]
|
||||
pub async fn set_cve_vex(
|
||||
Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
Path(id): Path<String>,
|
||||
Json(req): Json<VexRequest>,
|
||||
) -> Result<Json<serde_json::Value>, (StatusCode, Json<serde_json::Value>)> {
|
||||
let fail = |code: StatusCode, error: &str| (code, Json(serde_json::json!({ "error": error })));
|
||||
let oid = ObjectId::parse_str(&id).map_err(|_| fail(StatusCode::BAD_REQUEST, "bad id"))?;
|
||||
let vex = statement(req, &tenant);
|
||||
vex.validate()
|
||||
.map_err(|e| fail(StatusCode::UNPROCESSABLE_ENTITY, &e.to_string()))?;
|
||||
let db = tenant_db(&agent, &tenant)
|
||||
.await
|
||||
.map_err(|code| fail(code, "tenant"))?;
|
||||
let vex_bson = mongodb::bson::to_bson(&vex)
|
||||
.map_err(|_| fail(StatusCode::INTERNAL_SERVER_ERROR, "encode"))?;
|
||||
let result = db
|
||||
.cve_alerts()
|
||||
.update_one(doc! { "_id": oid }, doc! { "$set": { "vex": vex_bson } })
|
||||
.await
|
||||
.map_err(|_| fail(StatusCode::INTERNAL_SERVER_ERROR, "store"))?;
|
||||
if result.matched_count == 0 {
|
||||
return Err(fail(StatusCode::NOT_FOUND, "no such alert"));
|
||||
}
|
||||
Ok(Json(serde_json::json!({ "status": "updated", "vex": vex })))
|
||||
}
|
||||
|
||||
/// The query of [`export_vex`].
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct VexExportQuery {
|
||||
/// `openvex` (default) or `cyclonedx`.
|
||||
#[serde(default)]
|
||||
pub format: Option<String>,
|
||||
}
|
||||
|
||||
/// GET /api/v1/targets/{id}/vex?format=openvex|cyclonedx — the target's VEX
|
||||
/// statements as a document to download.
|
||||
#[tracing::instrument(skip_all, fields(target_id = %id))]
|
||||
pub async fn export_vex(
|
||||
Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
Path(id): Path<String>,
|
||||
Query(query): Query<VexExportQuery>,
|
||||
) -> Result<impl IntoResponse, StatusCode> {
|
||||
let oid = ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?;
|
||||
let db = tenant_db(&agent, &tenant).await?;
|
||||
let target = db
|
||||
.onboarded_targets()
|
||||
.find_one(doc! { "_id": oid })
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?
|
||||
.ok_or(StatusCode::NOT_FOUND)?;
|
||||
let by_target = doc! { "repo_id": &id };
|
||||
let components = db
|
||||
.sbom_entries()
|
||||
.count_documents(by_target.clone())
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
if components > super::sbom::MAX_EXPORT_COMPONENTS {
|
||||
return Err(StatusCode::PAYLOAD_TOO_LARGE);
|
||||
}
|
||||
let alerts: Vec<CveAlert> = collect_cursor_async(
|
||||
db.cve_alerts()
|
||||
.find(by_target.clone())
|
||||
.sort(doc! { "cve_id": 1 })
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?,
|
||||
)
|
||||
.await;
|
||||
let sbom: Vec<SbomEntry> = collect_cursor_async(
|
||||
db.sbom_entries()
|
||||
.find(by_target)
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?,
|
||||
)
|
||||
.await;
|
||||
let tooling = format!("Prüfwerk {}", super::platform::BUILD_VERSION);
|
||||
let author = if tenant.0.tenant_slug.is_empty() {
|
||||
tenant.0.tenant_id.clone()
|
||||
} else {
|
||||
tenant.0.tenant_slug.clone()
|
||||
};
|
||||
let input = VexInput {
|
||||
subject: &target.name,
|
||||
author: &author,
|
||||
tooling: &tooling,
|
||||
alerts: &alerts,
|
||||
sbom: &sbom,
|
||||
now: chrono::Utc::now(),
|
||||
};
|
||||
let cyclonedx = query.format.as_deref() == Some("cyclonedx");
|
||||
let body = if cyclonedx {
|
||||
vex_docs::cyclonedx_vex(&input)
|
||||
} else {
|
||||
vex_docs::openvex(&input)
|
||||
};
|
||||
let json =
|
||||
serde_json::to_string_pretty(&body).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
let filename = format!(
|
||||
"vex-{id}-{}.json",
|
||||
if cyclonedx { "cyclonedx" } else { "openvex" }
|
||||
);
|
||||
let disposition = HeaderValue::from_str(&format!("attachment; filename=\"{filename}\""))
|
||||
.unwrap_or_else(|_| HeaderValue::from_static("attachment"));
|
||||
Ok((
|
||||
[
|
||||
(
|
||||
header::CONTENT_TYPE,
|
||||
HeaderValue::from_static("application/json"),
|
||||
),
|
||||
(header::CONTENT_DISPOSITION, disposition),
|
||||
],
|
||||
json,
|
||||
))
|
||||
}
|
||||
@@ -98,6 +98,13 @@ pub fn build_router() -> Router {
|
||||
"/api/v1/findings/{id}/feedback",
|
||||
patch(handlers::update_finding_feedback),
|
||||
)
|
||||
// VEX on a target's CVE alerts (#498).
|
||||
.route(
|
||||
"/api/v1/targets/{id}/cves",
|
||||
get(handlers::vex::list_target_cves),
|
||||
)
|
||||
.route("/api/v1/targets/{id}/vex", get(handlers::vex::export_vex))
|
||||
.route("/api/v1/cves/{id}/vex", patch(handlers::vex::set_cve_vex))
|
||||
.route(
|
||||
"/api/v1/targets/{id}/evidence-pack",
|
||||
get(handlers::evidence::evidence_pack),
|
||||
|
||||
@@ -17,7 +17,7 @@ use sha2::{Digest, Sha256};
|
||||
|
||||
use compliance_core::models::oscal_assessment::assess;
|
||||
use compliance_core::models::{CveAlert, Finding, OnboardedTarget, SbomEntry, ScanRun, SkipCode};
|
||||
use compliance_core::sbom_docs;
|
||||
use compliance_core::{sbom_docs, vex_docs};
|
||||
|
||||
use crate::error::AgentError;
|
||||
|
||||
@@ -34,6 +34,8 @@ pub struct EvidenceInputs {
|
||||
pub last_run: Option<ScanRun>,
|
||||
/// The CRA catalog's controls by id, for their ratings; empty without one.
|
||||
pub catalog: std::collections::HashMap<String, compliance_core::traits::Control>,
|
||||
/// Who states the VEX (the workspace); the target's name when empty.
|
||||
pub author: String,
|
||||
}
|
||||
|
||||
/// One file of the pack, as `manifest.json` lists it.
|
||||
@@ -69,6 +71,20 @@ pub fn build_pack(
|
||||
at: DateTime<Utc>,
|
||||
) -> Result<(Vec<u8>, Vec<ManifestFile>), AgentError> {
|
||||
let subject = inputs.target.name.as_str();
|
||||
let tooling = format!("Prüfwerk {}", env!("CARGO_PKG_VERSION"));
|
||||
// The VEX statements on the CVE alerts (#498).
|
||||
let vex = vex_docs::VexInput {
|
||||
subject,
|
||||
author: if inputs.author.is_empty() {
|
||||
subject
|
||||
} else {
|
||||
&inputs.author
|
||||
},
|
||||
tooling: &tooling,
|
||||
alerts: &inputs.cves,
|
||||
sbom: &inputs.sbom,
|
||||
now: at,
|
||||
};
|
||||
let files: Vec<(&str, Vec<u8>)> = vec![
|
||||
(
|
||||
"oscal-assessment-results.json",
|
||||
@@ -85,6 +101,8 @@ pub fn build_pack(
|
||||
("findings.json", json(&inputs.findings)?),
|
||||
("findings.csv", findings_csv(&inputs.findings).into_bytes()),
|
||||
("cve-alerts.json", json(&inputs.cves)?),
|
||||
("vex.openvex.json", json(&vex_docs::openvex(&vex))?),
|
||||
("vex.cdx.json", json(&vex_docs::cyclonedx_vex(&vex))?),
|
||||
("cra-compliance.json", json(&compliance_of(inputs))?),
|
||||
];
|
||||
let listed: Vec<ManifestFile> = files
|
||||
@@ -300,6 +318,7 @@ mod tests {
|
||||
cves: vec![],
|
||||
last_run: None,
|
||||
catalog: Default::default(),
|
||||
author: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +340,8 @@ mod tests {
|
||||
"oscal-assessment-results.json",
|
||||
"sbom.cdx.json",
|
||||
"sbom.spdx.json",
|
||||
"vex.cdx.json",
|
||||
"vex.openvex.json",
|
||||
]
|
||||
);
|
||||
for file in &listed {
|
||||
|
||||
@@ -40,3 +40,4 @@ mod tracker_dispatch;
|
||||
pub(crate) mod unity_settings;
|
||||
pub mod variants;
|
||||
pub mod vendor;
|
||||
pub mod vex_lifecycle;
|
||||
@@ -824,6 +824,16 @@ impl PipelineOrchestrator {
|
||||
{
|
||||
tracing::warn!("[{repo_id}] Issue creation failed: {e}");
|
||||
}
|
||||
if let Err(e) = crate::pipeline::vex_lifecycle::resolve_gone(
|
||||
&self.db,
|
||||
&repo_id,
|
||||
&cve_alerts,
|
||||
cve_complete,
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::warn!("[{repo_id}] Marking resolved CVE alerts failed: {e}");
|
||||
}
|
||||
if let Err(e) = self
|
||||
.sync_cve_issues(repo, &repo_id, &cve_alerts, cve_complete)
|
||||
.await
|
||||
@@ -1518,15 +1528,7 @@ impl PipelineOrchestrator {
|
||||
|
||||
let mut new_notif = 0u32;
|
||||
for alert in alerts {
|
||||
let filter = doc! { "cve_id": &alert.cve_id, "repo_id": &alert.repo_id };
|
||||
let update = mongodb::bson::to_document(alert)
|
||||
.map(|d| doc! { "$set": d })
|
||||
.unwrap_or_else(|_| doc! {});
|
||||
self.db
|
||||
.cve_alerts()
|
||||
.update_one(filter, update)
|
||||
.upsert(true)
|
||||
.await?;
|
||||
crate::pipeline::vex_lifecycle::upsert_reported(&self.db, alert).await?;
|
||||
|
||||
// Dedup notifications by cve + repo + package + version.
|
||||
let notif_filter = doc! {
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
//! The life of a stored CVE alert and its VEX status (#498).
|
||||
//!
|
||||
//! An alert is stored once per CVE and target. Reported again, it is updated
|
||||
//! and counts as open: a `fixed` the scan had stated is withdrawn. When a
|
||||
//! complete lookup no longer reports it (the component removed or updated
|
||||
//! past the fix), it is marked resolved, and one nobody assessed, or
|
||||
//! assessed as affected, gets the VEX status `fixed` from the scan. A
|
||||
//! person's `not_affected` or `fixed` is never changed by a scan.
|
||||
|
||||
use mongodb::bson::doc;
|
||||
|
||||
use compliance_core::models::{CveAlert, StatusChange, VexAssessment, VexStatus};
|
||||
|
||||
use crate::database::Database;
|
||||
use crate::error::AgentError;
|
||||
|
||||
/// Store `alert` as reported by this scan.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// A database error.
|
||||
pub async fn upsert_reported(db: &Database, alert: &CveAlert) -> Result<(), AgentError> {
|
||||
let filter = doc! { "cve_id": &alert.cve_id, "repo_id": &alert.repo_id };
|
||||
// The alert as found now; a VEX statement on it is left as it is (the
|
||||
// alert carries none), and it is reported again.
|
||||
let found = mongodb::bson::to_document(alert)
|
||||
.map_err(|e| AgentError::Other(format!("encode CVE alert: {e}")))?;
|
||||
db.cve_alerts()
|
||||
.update_one(
|
||||
filter.clone(),
|
||||
doc! { "$set": found, "$unset": { "resolved_at": "" } },
|
||||
)
|
||||
.upsert(true)
|
||||
.await?;
|
||||
let mut scan_fixed = filter;
|
||||
scan_fixed.insert("vex.by_scan", true);
|
||||
scan_fixed.insert("vex.status", "fixed");
|
||||
db.cve_alerts()
|
||||
.update_one(scan_fixed, doc! { "$unset": { "vex": "" } })
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Mark resolved the stored alerts of `repo_id` a complete lookup
|
||||
/// (`complete`) no longer reports in `current`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// How many were resolved.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// A database error.
|
||||
pub async fn resolve_gone(
|
||||
db: &Database,
|
||||
repo_id: &str,
|
||||
current: &[CveAlert],
|
||||
complete: bool,
|
||||
) -> Result<u64, AgentError> {
|
||||
if !complete {
|
||||
return Ok(0);
|
||||
}
|
||||
let now = mongodb::bson::DateTime::now();
|
||||
let seen: Vec<&str> = current.iter().map(|a| a.cve_id.as_str()).collect();
|
||||
let gone = doc! {
|
||||
"repo_id": repo_id,
|
||||
"cve_id": { "$nin": seen },
|
||||
"resolved_at": { "$exists": false },
|
||||
};
|
||||
let fixed = VexAssessment {
|
||||
status: VexStatus::Fixed,
|
||||
justification: None,
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
by: StatusChange::SCAN_ACTOR.to_string(),
|
||||
by_name: None,
|
||||
at: chrono::Utc::now(),
|
||||
by_scan: true,
|
||||
};
|
||||
let fixed = mongodb::bson::to_bson(&fixed)
|
||||
.map_err(|e| AgentError::Other(format!("encode VEX: {e}")))?;
|
||||
let mut unassessed = gone.clone();
|
||||
unassessed.insert(
|
||||
"$or",
|
||||
mongodb::bson::bson!([
|
||||
{ "vex": { "$exists": false } },
|
||||
{ "vex.status": { "$in": ["under_investigation", "affected"] } },
|
||||
]),
|
||||
);
|
||||
let became_fixed = db
|
||||
.cve_alerts()
|
||||
.update_many(
|
||||
unassessed,
|
||||
doc! { "$set": { "resolved_at": now, "vex": fixed } },
|
||||
)
|
||||
.await?;
|
||||
let resolved = db
|
||||
.cve_alerts()
|
||||
.update_many(gone, doc! { "$set": { "resolved_at": now } })
|
||||
.await?;
|
||||
let total = became_fixed.modified_count + resolved.modified_count;
|
||||
if total > 0 {
|
||||
tracing::info!(
|
||||
repo_id,
|
||||
resolved = total,
|
||||
fixed_by_scan = became_fixed.modified_count,
|
||||
"CVE alerts no longer found marked resolved"
|
||||
);
|
||||
}
|
||||
Ok(total)
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
//! #498: a CVE alert's VEX status follows the scans. Gone after a complete
|
||||
//! lookup, an unassessed or affected alert is `fixed` by the scan, a
|
||||
//! person's `not_affected` stays; reported again, the scan's `fixed` is
|
||||
//! withdrawn. Runs against a live Mongo (`TEST_MONGODB_URI`) and skips
|
||||
//! cleanly without one.
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
use compliance_agent::database::{Database, DatabasePool};
|
||||
use compliance_agent::pipeline::vex_lifecycle::{resolve_gone, upsert_reported};
|
||||
use compliance_core::models::{CveAlert, CveSource, VexAssessment, VexJustification, VexStatus};
|
||||
use mongodb::bson::doc;
|
||||
|
||||
const TARGET: &str = "target-1";
|
||||
|
||||
fn alert(id: &str) -> CveAlert {
|
||||
CveAlert::new(
|
||||
id.into(),
|
||||
TARGET.into(),
|
||||
"lib".into(),
|
||||
"1.0".into(),
|
||||
CveSource::Osv,
|
||||
)
|
||||
}
|
||||
|
||||
fn by_person(status: VexStatus) -> VexAssessment {
|
||||
VexAssessment {
|
||||
status,
|
||||
justification: Some(VexJustification::VulnerableCodeNotPresent),
|
||||
impact_statement: None,
|
||||
action_statement: Some("Update.".into()),
|
||||
by: "u1".into(),
|
||||
by_name: Some("Erika".into()),
|
||||
at: chrono::Utc::now(),
|
||||
by_scan: false,
|
||||
}
|
||||
}
|
||||
|
||||
async fn stored(db: &Database, id: &str) -> CveAlert {
|
||||
db.cve_alerts()
|
||||
.find_one(doc! { "repo_id": TARGET, "cve_id": id })
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn vex_status_follows_the_scans_but_never_overrides_a_person() {
|
||||
let uri = std::env::var("TEST_MONGODB_URI")
|
||||
.unwrap_or_else(|_| "mongodb://root:example@localhost:27017/?authSource=admin".into());
|
||||
let prefix = format!(
|
||||
"vexlife_{}",
|
||||
&uuid::Uuid::new_v4().simple().to_string()[..10]
|
||||
);
|
||||
let Ok(pool) = DatabasePool::connect(&uri, &prefix).await else {
|
||||
eprintln!("SKIP vex_lifecycle: no MongoDB reachable at {uri}");
|
||||
return;
|
||||
};
|
||||
let tenant = "vex-lifecycle";
|
||||
let Ok(db) = pool.for_tenant_id(tenant).await else {
|
||||
eprintln!("SKIP vex_lifecycle: MongoDB at {uri} not usable");
|
||||
return;
|
||||
};
|
||||
|
||||
// Arrange: four alerts reported; a person assessed two of them.
|
||||
for id in ["CVE-1", "CVE-2", "CVE-3", "CVE-4"] {
|
||||
upsert_reported(&db, &alert(id)).await.unwrap();
|
||||
}
|
||||
for (id, status) in [
|
||||
("CVE-2", VexStatus::NotAffected),
|
||||
("CVE-3", VexStatus::Affected),
|
||||
] {
|
||||
let vex = mongodb::bson::to_bson(&by_person(status)).unwrap();
|
||||
db.cve_alerts()
|
||||
.update_one(doc! { "cve_id": id }, doc! { "$set": { "vex": vex } })
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// An incomplete lookup resolves nothing.
|
||||
assert_eq!(
|
||||
resolve_gone(&db, TARGET, &[alert("CVE-4")], false)
|
||||
.await
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
|
||||
// Act: a complete scan reports only CVE-4.
|
||||
let resolved = resolve_gone(&db, TARGET, &[alert("CVE-4")], true)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Assert: three resolved; the unassessed and the affected one are fixed
|
||||
// by the scan, the person's not_affected stays.
|
||||
assert_eq!(resolved, 3);
|
||||
let one = stored(&db, "CVE-1").await;
|
||||
assert!(one.resolved_at.is_some());
|
||||
assert_eq!(
|
||||
one.vex.as_ref().map(|v| (v.status, v.by_scan)),
|
||||
Some((VexStatus::Fixed, true))
|
||||
);
|
||||
let two = stored(&db, "CVE-2").await;
|
||||
assert!(two.resolved_at.is_some());
|
||||
assert_eq!(
|
||||
two.vex.as_ref().map(|v| v.status),
|
||||
Some(VexStatus::NotAffected)
|
||||
);
|
||||
assert_eq!(
|
||||
stored(&db, "CVE-3").await.vex.map(|v| v.status),
|
||||
Some(VexStatus::Fixed)
|
||||
);
|
||||
assert!(stored(&db, "CVE-4").await.resolved_at.is_none());
|
||||
|
||||
// Reported again: open, and the scan's `fixed` is withdrawn; the
|
||||
// person's statement is kept.
|
||||
upsert_reported(&db, &alert("CVE-1")).await.unwrap();
|
||||
upsert_reported(&db, &alert("CVE-2")).await.unwrap();
|
||||
let one = stored(&db, "CVE-1").await;
|
||||
assert!(one.resolved_at.is_none());
|
||||
assert!(one.vex.is_none());
|
||||
let two = stored(&db, "CVE-2").await;
|
||||
assert!(two.resolved_at.is_none());
|
||||
assert_eq!(two.vex.map(|v| v.status), Some(VexStatus::NotAffected));
|
||||
|
||||
pool.drop_tenant(tenant).await.ok();
|
||||
}
|
||||
@@ -68,3 +68,5 @@ base64 = { workspace = true, optional = true }
|
||||
[dev-dependencies]
|
||||
# Parse the declarative TOML job specs in the Werkbank contract tests.
|
||||
toml = "0.8"
|
||||
# Check the SBOM and VEX documents against the vendored official schemas.
|
||||
jsonschema = { version = "0.33", default-features = false }
|
||||
@@ -0,0 +1,12 @@
|
||||
# Vendored schemas
|
||||
|
||||
Official schemas the documents Prüfwerk writes are checked against (#498):
|
||||
`spdx.schema.json` is also read at run time, for the SPDX license ids a
|
||||
CycloneDX `license.id` may carry.
|
||||
|
||||
| File | Source | Licence |
|
||||
|---|---|---|
|
||||
| `bom-1.5.schema.json`, `spdx.schema.json`, `jsf-0.82.schema.json` | CycloneDX specification, tag 1.5 (`github.com/CycloneDX/specification/schema/`) | Apache-2.0 |
|
||||
| `openvex-0.2.0.schema.json` | OpenVEX specification (`github.com/openvex/spec`, `openvex_json_schema.json`) | CC0-1.0 |
|
||||
|
||||
Unchanged copies; update them only by copying the upstream file again.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://cyclonedx.org/schema/jsf-0.82.schema.json",
|
||||
"type": "object",
|
||||
"title": "JSON Signature Format (JSF) standard",
|
||||
"$comment" : "JSON Signature Format schema is published under the terms of the Apache License 2.0. JSF was developed by Anders Rundgren (anders.rundgren.net@gmail.com) as a part of the OpenKeyStore project. This schema supports the entirely of the JSF standard excluding 'extensions'.",
|
||||
"definitions": {
|
||||
"signature": {
|
||||
"type": "object",
|
||||
"title": "Signature",
|
||||
"oneOf": [
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"signers": {
|
||||
"type": "array",
|
||||
"title": "Signature",
|
||||
"description": "Unique top level property for Multiple Signatures. (multisignature)",
|
||||
"items": {"$ref": "#/definitions/signer"}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"chain": {
|
||||
"type": "array",
|
||||
"title": "Signature",
|
||||
"description": "Unique top level property for Signature Chains. (signaturechain)",
|
||||
"items": {"$ref": "#/definitions/signer"}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "Signature",
|
||||
"description": "Unique top level property for simple signatures. (signaturecore)",
|
||||
"$ref": "#/definitions/signer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"signer": {
|
||||
"type": "object",
|
||||
"title": "Signature",
|
||||
"required": [
|
||||
"algorithm",
|
||||
"value"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"algorithm": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"title": "Algorithm",
|
||||
"description": "Signature algorithm. The currently recognized JWA [RFC7518] and RFC8037 [RFC8037] asymmetric key algorithms. Note: Unlike RFC8037 [RFC8037] JSF requires explicit Ed* algorithm names instead of \"EdDSA\".",
|
||||
"enum": [
|
||||
"RS256",
|
||||
"RS384",
|
||||
"RS512",
|
||||
"PS256",
|
||||
"PS384",
|
||||
"PS512",
|
||||
"ES256",
|
||||
"ES384",
|
||||
"ES512",
|
||||
"Ed25519",
|
||||
"Ed448",
|
||||
"HS256",
|
||||
"HS384",
|
||||
"HS512"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"title": "Algorithm",
|
||||
"description": "Signature algorithm. Note: If proprietary signature algorithms are added, they must be expressed as URIs.",
|
||||
"format": "uri"
|
||||
}
|
||||
]
|
||||
},
|
||||
"keyId": {
|
||||
"type": "string",
|
||||
"title": "Key ID",
|
||||
"description": "Optional. Application specific string identifying the signature key."
|
||||
},
|
||||
"publicKey": {
|
||||
"title": "Public key",
|
||||
"description": "Optional. Public key object.",
|
||||
"$ref": "#/definitions/publicKey"
|
||||
},
|
||||
"certificatePath": {
|
||||
"type": "array",
|
||||
"title": "Certificate path",
|
||||
"description": "Optional. Sorted array of X.509 [RFC5280] certificates, where the first element must contain the signature certificate. The certificate path must be contiguous but is not required to be complete.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"excludes": {
|
||||
"type": "array",
|
||||
"title": "Excludes",
|
||||
"description": "Optional. Array holding the names of one or more application level properties that must be excluded from the signature process. Note that the \"excludes\" property itself, must also be excluded from the signature process. Since both the \"excludes\" property and the associated data it points to are unsigned, a conforming JSF implementation must provide options for specifying which properties to accept.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"title": "Signature",
|
||||
"description": "The signature data. Note that the binary representation must follow the JWA [RFC7518] specifications."
|
||||
}
|
||||
}
|
||||
},
|
||||
"keyType": {
|
||||
"type": "string",
|
||||
"title": "Key type",
|
||||
"description": "Key type indicator.",
|
||||
"enum": [
|
||||
"EC",
|
||||
"OKP",
|
||||
"RSA"
|
||||
]
|
||||
},
|
||||
"publicKey": {
|
||||
"title": "Public key",
|
||||
"description": "Optional. Public key object.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kty"
|
||||
],
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"kty": {
|
||||
"$ref": "#/definitions/keyType"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": { "kty": { "const": "EC" } }
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"kty",
|
||||
"crv",
|
||||
"x",
|
||||
"y"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kty": {
|
||||
"$ref": "#/definitions/keyType"
|
||||
},
|
||||
"crv": {
|
||||
"type": "string",
|
||||
"title": "Curve name",
|
||||
"description": "EC curve name.",
|
||||
"enum": [
|
||||
"P-256",
|
||||
"P-384",
|
||||
"P-521"
|
||||
]
|
||||
},
|
||||
"x": {
|
||||
"type": "string",
|
||||
"title": "Coordinate",
|
||||
"description": "EC curve point X. The length of this field must be the full size of a coordinate for the curve specified in the \"crv\" parameter. For example, if the value of \"crv\" is \"P-521\", the decoded argument must be 66 bytes."
|
||||
},
|
||||
"y": {
|
||||
"type": "string",
|
||||
"title": "Coordinate",
|
||||
"description": "EC curve point Y. The length of this field must be the full size of a coordinate for the curve specified in the \"crv\" parameter. For example, if the value of \"crv\" is \"P-256\", the decoded argument must be 32 bytes."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": { "kty": { "const": "OKP" } }
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"kty",
|
||||
"crv",
|
||||
"x"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kty": {
|
||||
"$ref": "#/definitions/keyType"
|
||||
},
|
||||
"crv": {
|
||||
"type": "string",
|
||||
"title": "Curve name",
|
||||
"description": "EdDSA curve name.",
|
||||
"enum": [
|
||||
"Ed25519",
|
||||
"Ed448"
|
||||
]
|
||||
},
|
||||
"x": {
|
||||
"type": "string",
|
||||
"title": "Coordinate",
|
||||
"description": "EdDSA curve point X. The length of this field must be the full size of a coordinate for the curve specified in the \"crv\" parameter. For example, if the value of \"crv\" is \"Ed25519\", the decoded argument must be 32 bytes."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": { "kty": { "const": "RSA" } }
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"kty",
|
||||
"n",
|
||||
"e"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kty": {
|
||||
"$ref": "#/definitions/keyType"
|
||||
},
|
||||
"n": {
|
||||
"type": "string",
|
||||
"title": "Modulus",
|
||||
"description": "RSA modulus."
|
||||
},
|
||||
"e": {
|
||||
"type": "string",
|
||||
"title": "Exponent",
|
||||
"description": "RSA exponent."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://github.com/openvex/spec/openvex_json_schema_0.2.0.json",
|
||||
"title": "OpenVEX",
|
||||
"description": "OpenVEX is an implementation of the Vulnerability Exploitability Exchange (VEX for short) that is designed to be minimal, compliant, interoperable, and embeddable.",
|
||||
"type": "object",
|
||||
"$defs": {
|
||||
"vulnerability": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@id": {
|
||||
"type": "string",
|
||||
"format": "iri",
|
||||
"description": "An Internationalized Resource Identifier (IRI) identifying the struct."
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "A string with the main identifier used to name the vulnerability."
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Optional free form text describing the vulnerability."
|
||||
},
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A list of strings enumerating other names under which the vulnerability may be known."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"identifiers": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"purl": {
|
||||
"type": "string",
|
||||
"description": "Package URL"
|
||||
},
|
||||
"cpe22": {
|
||||
"type": "string",
|
||||
"description": "Common Platform Enumeration v2.2"
|
||||
},
|
||||
"cpe23": {
|
||||
"type": "string",
|
||||
"description": "Common Platform Enumeration v2.3"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"anyOf": [
|
||||
{ "required": ["purl"] },
|
||||
{ "required": ["cpe22"] },
|
||||
{ "required": ["cpe23"] }
|
||||
]
|
||||
},
|
||||
"hashes": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"md5": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha1": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha-256": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha-384": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha-512": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha3-224": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha3-256": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha3-384": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha3-512": {
|
||||
"type": "string"
|
||||
},
|
||||
"blake2s-256": {
|
||||
"type": "string"
|
||||
},
|
||||
"blake2b-256": {
|
||||
"type": "string"
|
||||
},
|
||||
"blake2b-512": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"subcomponent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@id": {
|
||||
"type": "string",
|
||||
"format": "iri",
|
||||
"description": "Optional IRI identifying the component to make it externally referenceable."
|
||||
},
|
||||
"identifiers": {
|
||||
"$ref": "#/$defs/identifiers",
|
||||
"description": "Optional IRI identifying the component to make it externally referenceable."
|
||||
},
|
||||
"hashes": {
|
||||
"$ref": "#/$defs/hashes",
|
||||
"description": "Map of cryptographic hashes of the component."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"anyOf": [
|
||||
{ "required": ["@id"] },
|
||||
{ "required": ["identifiers"] }
|
||||
]
|
||||
},
|
||||
"component": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@id": {
|
||||
"type": "string",
|
||||
"format": "iri",
|
||||
"description": "Optional IRI identifying the component to make it externally referenceable."
|
||||
},
|
||||
"identifiers": {
|
||||
"$ref": "#/$defs/identifiers",
|
||||
"description": "A map of software identifiers where the key is the type and the value the identifier."
|
||||
},
|
||||
"hashes": {
|
||||
"$ref": "#/$defs/hashes",
|
||||
"description": "Map of cryptographic hashes of the component."
|
||||
},
|
||||
"subcomponents": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"description": "List of subcomponent structs describing the subcomponents subject of the VEX statement.",
|
||||
"items": {
|
||||
"$ref": "#/$defs/subcomponent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"anyOf": [
|
||||
{ "required": ["@id"] },
|
||||
{ "required": ["identifiers"] }
|
||||
]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"@context": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "The URL linking to the OpenVEX context definition."
|
||||
},
|
||||
"@id": {
|
||||
"type": "string",
|
||||
"format": "iri",
|
||||
"description": "The IRI identifying the VEX document."
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"description": "Author is the identifier for the author of the VEX statement."
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"description": "Role describes the role of the document author."
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Timestamp defines the time at which the document was issued."
|
||||
},
|
||||
"last_updated": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Date of last modification to the document."
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "Version is the document version."
|
||||
},
|
||||
"tooling": {
|
||||
"type": "string",
|
||||
"description": "Tooling expresses how the VEX document and contained VEX statements were generated."
|
||||
},
|
||||
"statements": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"minItems": 1,
|
||||
"description": "A statement is an assertion made by the document's author about the impact a vulnerability has on one or more software 'products'.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@id": {
|
||||
"type": "string",
|
||||
"format": "iri",
|
||||
"description": "Optional IRI identifying the statement to make it externally referenceable."
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "Optional integer representing the statement's version number."
|
||||
},
|
||||
"vulnerability": {
|
||||
"$ref": "#/$defs/vulnerability",
|
||||
"description": "A struct identifying the vulnerability."
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Timestamp is the time at which the information expressed in the statement was known to be true."
|
||||
},
|
||||
"last_updated": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Timestamp when the statement was last updated."
|
||||
},
|
||||
"products": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"description": "List of product structs that the statement applies to.",
|
||||
"items": {
|
||||
"$ref": "#/$defs/component"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"not_affected",
|
||||
"affected",
|
||||
"fixed",
|
||||
"under_investigation"
|
||||
],
|
||||
"description": "A VEX statement MUST provide the status of the vulnerabilities with respect to the products and components listed in the statement."
|
||||
},
|
||||
"supplier": {
|
||||
"type": "string",
|
||||
"description": "Supplier of the product or subcomponent."
|
||||
},
|
||||
"status_notes": {
|
||||
"type": "string",
|
||||
"description": "A statement MAY convey information about how status was determined and MAY reference other VEX information."
|
||||
},
|
||||
"justification": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"component_not_present",
|
||||
"vulnerable_code_not_present",
|
||||
"vulnerable_code_not_in_execute_path",
|
||||
"vulnerable_code_cannot_be_controlled_by_adversary",
|
||||
"inline_mitigations_already_exist"
|
||||
],
|
||||
"description": "For statements conveying a not_affected status, a VEX statement MUST include either a status justification or an impact_statement informing why the product is not affected by the vulnerability."
|
||||
},
|
||||
"impact_statement": {
|
||||
"type": "string",
|
||||
"description": "For statements conveying a not_affected status, a VEX statement MUST include either a status justification or an impact_statement informing why the product is not affected by the vulnerability."
|
||||
},
|
||||
"action_statement": {
|
||||
"type": "string",
|
||||
"description": "For a statement with affected status, a VEX statement MUST include a statement that SHOULD describe actions to remediate or mitigate the vulnerability."
|
||||
},
|
||||
"action_statement_timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "The timestamp when the action statement was issued."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"vulnerability",
|
||||
"status"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": { "status": { "const": "not_affected" }}
|
||||
},
|
||||
"then": {
|
||||
"anyOf": [
|
||||
{ "required": ["justification"]},
|
||||
{ "required": ["impact_statement"]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": { "status": { "const": "affected" }}
|
||||
},
|
||||
"then": {
|
||||
"required": ["action_statement"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"@context",
|
||||
"@id",
|
||||
"author",
|
||||
"timestamp",
|
||||
"version",
|
||||
"statements"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -0,0 +1,621 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://cyclonedx.org/schema/spdx.schema.json",
|
||||
"$comment": "v1.0-3.21",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"0BSD",
|
||||
"AAL",
|
||||
"Abstyles",
|
||||
"AdaCore-doc",
|
||||
"Adobe-2006",
|
||||
"Adobe-Glyph",
|
||||
"ADSL",
|
||||
"AFL-1.1",
|
||||
"AFL-1.2",
|
||||
"AFL-2.0",
|
||||
"AFL-2.1",
|
||||
"AFL-3.0",
|
||||
"Afmparse",
|
||||
"AGPL-1.0",
|
||||
"AGPL-1.0-only",
|
||||
"AGPL-1.0-or-later",
|
||||
"AGPL-3.0",
|
||||
"AGPL-3.0-only",
|
||||
"AGPL-3.0-or-later",
|
||||
"Aladdin",
|
||||
"AMDPLPA",
|
||||
"AML",
|
||||
"AMPAS",
|
||||
"ANTLR-PD",
|
||||
"ANTLR-PD-fallback",
|
||||
"Apache-1.0",
|
||||
"Apache-1.1",
|
||||
"Apache-2.0",
|
||||
"APAFML",
|
||||
"APL-1.0",
|
||||
"App-s2p",
|
||||
"APSL-1.0",
|
||||
"APSL-1.1",
|
||||
"APSL-1.2",
|
||||
"APSL-2.0",
|
||||
"Arphic-1999",
|
||||
"Artistic-1.0",
|
||||
"Artistic-1.0-cl8",
|
||||
"Artistic-1.0-Perl",
|
||||
"Artistic-2.0",
|
||||
"ASWF-Digital-Assets-1.0",
|
||||
"ASWF-Digital-Assets-1.1",
|
||||
"Baekmuk",
|
||||
"Bahyph",
|
||||
"Barr",
|
||||
"Beerware",
|
||||
"Bitstream-Charter",
|
||||
"Bitstream-Vera",
|
||||
"BitTorrent-1.0",
|
||||
"BitTorrent-1.1",
|
||||
"blessing",
|
||||
"BlueOak-1.0.0",
|
||||
"Boehm-GC",
|
||||
"Borceux",
|
||||
"Brian-Gladman-3-Clause",
|
||||
"BSD-1-Clause",
|
||||
"BSD-2-Clause",
|
||||
"BSD-2-Clause-FreeBSD",
|
||||
"BSD-2-Clause-NetBSD",
|
||||
"BSD-2-Clause-Patent",
|
||||
"BSD-2-Clause-Views",
|
||||
"BSD-3-Clause",
|
||||
"BSD-3-Clause-Attribution",
|
||||
"BSD-3-Clause-Clear",
|
||||
"BSD-3-Clause-LBNL",
|
||||
"BSD-3-Clause-Modification",
|
||||
"BSD-3-Clause-No-Military-License",
|
||||
"BSD-3-Clause-No-Nuclear-License",
|
||||
"BSD-3-Clause-No-Nuclear-License-2014",
|
||||
"BSD-3-Clause-No-Nuclear-Warranty",
|
||||
"BSD-3-Clause-Open-MPI",
|
||||
"BSD-4-Clause",
|
||||
"BSD-4-Clause-Shortened",
|
||||
"BSD-4-Clause-UC",
|
||||
"BSD-4.3RENO",
|
||||
"BSD-4.3TAHOE",
|
||||
"BSD-Advertising-Acknowledgement",
|
||||
"BSD-Attribution-HPND-disclaimer",
|
||||
"BSD-Protection",
|
||||
"BSD-Source-Code",
|
||||
"BSL-1.0",
|
||||
"BUSL-1.1",
|
||||
"bzip2-1.0.5",
|
||||
"bzip2-1.0.6",
|
||||
"C-UDA-1.0",
|
||||
"CAL-1.0",
|
||||
"CAL-1.0-Combined-Work-Exception",
|
||||
"Caldera",
|
||||
"CATOSL-1.1",
|
||||
"CC-BY-1.0",
|
||||
"CC-BY-2.0",
|
||||
"CC-BY-2.5",
|
||||
"CC-BY-2.5-AU",
|
||||
"CC-BY-3.0",
|
||||
"CC-BY-3.0-AT",
|
||||
"CC-BY-3.0-DE",
|
||||
"CC-BY-3.0-IGO",
|
||||
"CC-BY-3.0-NL",
|
||||
"CC-BY-3.0-US",
|
||||
"CC-BY-4.0",
|
||||
"CC-BY-NC-1.0",
|
||||
"CC-BY-NC-2.0",
|
||||
"CC-BY-NC-2.5",
|
||||
"CC-BY-NC-3.0",
|
||||
"CC-BY-NC-3.0-DE",
|
||||
"CC-BY-NC-4.0",
|
||||
"CC-BY-NC-ND-1.0",
|
||||
"CC-BY-NC-ND-2.0",
|
||||
"CC-BY-NC-ND-2.5",
|
||||
"CC-BY-NC-ND-3.0",
|
||||
"CC-BY-NC-ND-3.0-DE",
|
||||
"CC-BY-NC-ND-3.0-IGO",
|
||||
"CC-BY-NC-ND-4.0",
|
||||
"CC-BY-NC-SA-1.0",
|
||||
"CC-BY-NC-SA-2.0",
|
||||
"CC-BY-NC-SA-2.0-DE",
|
||||
"CC-BY-NC-SA-2.0-FR",
|
||||
"CC-BY-NC-SA-2.0-UK",
|
||||
"CC-BY-NC-SA-2.5",
|
||||
"CC-BY-NC-SA-3.0",
|
||||
"CC-BY-NC-SA-3.0-DE",
|
||||
"CC-BY-NC-SA-3.0-IGO",
|
||||
"CC-BY-NC-SA-4.0",
|
||||
"CC-BY-ND-1.0",
|
||||
"CC-BY-ND-2.0",
|
||||
"CC-BY-ND-2.5",
|
||||
"CC-BY-ND-3.0",
|
||||
"CC-BY-ND-3.0-DE",
|
||||
"CC-BY-ND-4.0",
|
||||
"CC-BY-SA-1.0",
|
||||
"CC-BY-SA-2.0",
|
||||
"CC-BY-SA-2.0-UK",
|
||||
"CC-BY-SA-2.1-JP",
|
||||
"CC-BY-SA-2.5",
|
||||
"CC-BY-SA-3.0",
|
||||
"CC-BY-SA-3.0-AT",
|
||||
"CC-BY-SA-3.0-DE",
|
||||
"CC-BY-SA-3.0-IGO",
|
||||
"CC-BY-SA-4.0",
|
||||
"CC-PDDC",
|
||||
"CC0-1.0",
|
||||
"CDDL-1.0",
|
||||
"CDDL-1.1",
|
||||
"CDL-1.0",
|
||||
"CDLA-Permissive-1.0",
|
||||
"CDLA-Permissive-2.0",
|
||||
"CDLA-Sharing-1.0",
|
||||
"CECILL-1.0",
|
||||
"CECILL-1.1",
|
||||
"CECILL-2.0",
|
||||
"CECILL-2.1",
|
||||
"CECILL-B",
|
||||
"CECILL-C",
|
||||
"CERN-OHL-1.1",
|
||||
"CERN-OHL-1.2",
|
||||
"CERN-OHL-P-2.0",
|
||||
"CERN-OHL-S-2.0",
|
||||
"CERN-OHL-W-2.0",
|
||||
"CFITSIO",
|
||||
"checkmk",
|
||||
"ClArtistic",
|
||||
"Clips",
|
||||
"CMU-Mach",
|
||||
"CNRI-Jython",
|
||||
"CNRI-Python",
|
||||
"CNRI-Python-GPL-Compatible",
|
||||
"COIL-1.0",
|
||||
"Community-Spec-1.0",
|
||||
"Condor-1.1",
|
||||
"copyleft-next-0.3.0",
|
||||
"copyleft-next-0.3.1",
|
||||
"Cornell-Lossless-JPEG",
|
||||
"CPAL-1.0",
|
||||
"CPL-1.0",
|
||||
"CPOL-1.02",
|
||||
"Crossword",
|
||||
"CrystalStacker",
|
||||
"CUA-OPL-1.0",
|
||||
"Cube",
|
||||
"curl",
|
||||
"D-FSL-1.0",
|
||||
"diffmark",
|
||||
"DL-DE-BY-2.0",
|
||||
"DOC",
|
||||
"Dotseqn",
|
||||
"DRL-1.0",
|
||||
"DSDP",
|
||||
"dtoa",
|
||||
"dvipdfm",
|
||||
"ECL-1.0",
|
||||
"ECL-2.0",
|
||||
"eCos-2.0",
|
||||
"EFL-1.0",
|
||||
"EFL-2.0",
|
||||
"eGenix",
|
||||
"Elastic-2.0",
|
||||
"Entessa",
|
||||
"EPICS",
|
||||
"EPL-1.0",
|
||||
"EPL-2.0",
|
||||
"ErlPL-1.1",
|
||||
"etalab-2.0",
|
||||
"EUDatagrid",
|
||||
"EUPL-1.0",
|
||||
"EUPL-1.1",
|
||||
"EUPL-1.2",
|
||||
"Eurosym",
|
||||
"Fair",
|
||||
"FDK-AAC",
|
||||
"Frameworx-1.0",
|
||||
"FreeBSD-DOC",
|
||||
"FreeImage",
|
||||
"FSFAP",
|
||||
"FSFUL",
|
||||
"FSFULLR",
|
||||
"FSFULLRWD",
|
||||
"FTL",
|
||||
"GD",
|
||||
"GFDL-1.1",
|
||||
"GFDL-1.1-invariants-only",
|
||||
"GFDL-1.1-invariants-or-later",
|
||||
"GFDL-1.1-no-invariants-only",
|
||||
"GFDL-1.1-no-invariants-or-later",
|
||||
"GFDL-1.1-only",
|
||||
"GFDL-1.1-or-later",
|
||||
"GFDL-1.2",
|
||||
"GFDL-1.2-invariants-only",
|
||||
"GFDL-1.2-invariants-or-later",
|
||||
"GFDL-1.2-no-invariants-only",
|
||||
"GFDL-1.2-no-invariants-or-later",
|
||||
"GFDL-1.2-only",
|
||||
"GFDL-1.2-or-later",
|
||||
"GFDL-1.3",
|
||||
"GFDL-1.3-invariants-only",
|
||||
"GFDL-1.3-invariants-or-later",
|
||||
"GFDL-1.3-no-invariants-only",
|
||||
"GFDL-1.3-no-invariants-or-later",
|
||||
"GFDL-1.3-only",
|
||||
"GFDL-1.3-or-later",
|
||||
"Giftware",
|
||||
"GL2PS",
|
||||
"Glide",
|
||||
"Glulxe",
|
||||
"GLWTPL",
|
||||
"gnuplot",
|
||||
"GPL-1.0",
|
||||
"GPL-1.0+",
|
||||
"GPL-1.0-only",
|
||||
"GPL-1.0-or-later",
|
||||
"GPL-2.0",
|
||||
"GPL-2.0+",
|
||||
"GPL-2.0-only",
|
||||
"GPL-2.0-or-later",
|
||||
"GPL-2.0-with-autoconf-exception",
|
||||
"GPL-2.0-with-bison-exception",
|
||||
"GPL-2.0-with-classpath-exception",
|
||||
"GPL-2.0-with-font-exception",
|
||||
"GPL-2.0-with-GCC-exception",
|
||||
"GPL-3.0",
|
||||
"GPL-3.0+",
|
||||
"GPL-3.0-only",
|
||||
"GPL-3.0-or-later",
|
||||
"GPL-3.0-with-autoconf-exception",
|
||||
"GPL-3.0-with-GCC-exception",
|
||||
"Graphics-Gems",
|
||||
"gSOAP-1.3b",
|
||||
"HaskellReport",
|
||||
"Hippocratic-2.1",
|
||||
"HP-1986",
|
||||
"HPND",
|
||||
"HPND-export-US",
|
||||
"HPND-Markus-Kuhn",
|
||||
"HPND-sell-variant",
|
||||
"HPND-sell-variant-MIT-disclaimer",
|
||||
"HTMLTIDY",
|
||||
"IBM-pibs",
|
||||
"ICU",
|
||||
"IEC-Code-Components-EULA",
|
||||
"IJG",
|
||||
"IJG-short",
|
||||
"ImageMagick",
|
||||
"iMatix",
|
||||
"Imlib2",
|
||||
"Info-ZIP",
|
||||
"Inner-Net-2.0",
|
||||
"Intel",
|
||||
"Intel-ACPI",
|
||||
"Interbase-1.0",
|
||||
"IPA",
|
||||
"IPL-1.0",
|
||||
"ISC",
|
||||
"Jam",
|
||||
"JasPer-2.0",
|
||||
"JPL-image",
|
||||
"JPNIC",
|
||||
"JSON",
|
||||
"Kazlib",
|
||||
"Knuth-CTAN",
|
||||
"LAL-1.2",
|
||||
"LAL-1.3",
|
||||
"Latex2e",
|
||||
"Latex2e-translated-notice",
|
||||
"Leptonica",
|
||||
"LGPL-2.0",
|
||||
"LGPL-2.0+",
|
||||
"LGPL-2.0-only",
|
||||
"LGPL-2.0-or-later",
|
||||
"LGPL-2.1",
|
||||
"LGPL-2.1+",
|
||||
"LGPL-2.1-only",
|
||||
"LGPL-2.1-or-later",
|
||||
"LGPL-3.0",
|
||||
"LGPL-3.0+",
|
||||
"LGPL-3.0-only",
|
||||
"LGPL-3.0-or-later",
|
||||
"LGPLLR",
|
||||
"Libpng",
|
||||
"libpng-2.0",
|
||||
"libselinux-1.0",
|
||||
"libtiff",
|
||||
"libutil-David-Nugent",
|
||||
"LiLiQ-P-1.1",
|
||||
"LiLiQ-R-1.1",
|
||||
"LiLiQ-Rplus-1.1",
|
||||
"Linux-man-pages-1-para",
|
||||
"Linux-man-pages-copyleft",
|
||||
"Linux-man-pages-copyleft-2-para",
|
||||
"Linux-man-pages-copyleft-var",
|
||||
"Linux-OpenIB",
|
||||
"LOOP",
|
||||
"LPL-1.0",
|
||||
"LPL-1.02",
|
||||
"LPPL-1.0",
|
||||
"LPPL-1.1",
|
||||
"LPPL-1.2",
|
||||
"LPPL-1.3a",
|
||||
"LPPL-1.3c",
|
||||
"LZMA-SDK-9.11-to-9.20",
|
||||
"LZMA-SDK-9.22",
|
||||
"MakeIndex",
|
||||
"Martin-Birgmeier",
|
||||
"metamail",
|
||||
"Minpack",
|
||||
"MirOS",
|
||||
"MIT",
|
||||
"MIT-0",
|
||||
"MIT-advertising",
|
||||
"MIT-CMU",
|
||||
"MIT-enna",
|
||||
"MIT-feh",
|
||||
"MIT-Festival",
|
||||
"MIT-Modern-Variant",
|
||||
"MIT-open-group",
|
||||
"MIT-Wu",
|
||||
"MITNFA",
|
||||
"Motosoto",
|
||||
"mpi-permissive",
|
||||
"mpich2",
|
||||
"MPL-1.0",
|
||||
"MPL-1.1",
|
||||
"MPL-2.0",
|
||||
"MPL-2.0-no-copyleft-exception",
|
||||
"mplus",
|
||||
"MS-LPL",
|
||||
"MS-PL",
|
||||
"MS-RL",
|
||||
"MTLL",
|
||||
"MulanPSL-1.0",
|
||||
"MulanPSL-2.0",
|
||||
"Multics",
|
||||
"Mup",
|
||||
"NAIST-2003",
|
||||
"NASA-1.3",
|
||||
"Naumen",
|
||||
"NBPL-1.0",
|
||||
"NCGL-UK-2.0",
|
||||
"NCSA",
|
||||
"Net-SNMP",
|
||||
"NetCDF",
|
||||
"Newsletr",
|
||||
"NGPL",
|
||||
"NICTA-1.0",
|
||||
"NIST-PD",
|
||||
"NIST-PD-fallback",
|
||||
"NIST-Software",
|
||||
"NLOD-1.0",
|
||||
"NLOD-2.0",
|
||||
"NLPL",
|
||||
"Nokia",
|
||||
"NOSL",
|
||||
"Noweb",
|
||||
"NPL-1.0",
|
||||
"NPL-1.1",
|
||||
"NPOSL-3.0",
|
||||
"NRL",
|
||||
"NTP",
|
||||
"NTP-0",
|
||||
"Nunit",
|
||||
"O-UDA-1.0",
|
||||
"OCCT-PL",
|
||||
"OCLC-2.0",
|
||||
"ODbL-1.0",
|
||||
"ODC-By-1.0",
|
||||
"OFFIS",
|
||||
"OFL-1.0",
|
||||
"OFL-1.0-no-RFN",
|
||||
"OFL-1.0-RFN",
|
||||
"OFL-1.1",
|
||||
"OFL-1.1-no-RFN",
|
||||
"OFL-1.1-RFN",
|
||||
"OGC-1.0",
|
||||
"OGDL-Taiwan-1.0",
|
||||
"OGL-Canada-2.0",
|
||||
"OGL-UK-1.0",
|
||||
"OGL-UK-2.0",
|
||||
"OGL-UK-3.0",
|
||||
"OGTSL",
|
||||
"OLDAP-1.1",
|
||||
"OLDAP-1.2",
|
||||
"OLDAP-1.3",
|
||||
"OLDAP-1.4",
|
||||
"OLDAP-2.0",
|
||||
"OLDAP-2.0.1",
|
||||
"OLDAP-2.1",
|
||||
"OLDAP-2.2",
|
||||
"OLDAP-2.2.1",
|
||||
"OLDAP-2.2.2",
|
||||
"OLDAP-2.3",
|
||||
"OLDAP-2.4",
|
||||
"OLDAP-2.5",
|
||||
"OLDAP-2.6",
|
||||
"OLDAP-2.7",
|
||||
"OLDAP-2.8",
|
||||
"OLFL-1.3",
|
||||
"OML",
|
||||
"OpenPBS-2.3",
|
||||
"OpenSSL",
|
||||
"OPL-1.0",
|
||||
"OPL-UK-3.0",
|
||||
"OPUBL-1.0",
|
||||
"OSET-PL-2.1",
|
||||
"OSL-1.0",
|
||||
"OSL-1.1",
|
||||
"OSL-2.0",
|
||||
"OSL-2.1",
|
||||
"OSL-3.0",
|
||||
"Parity-6.0.0",
|
||||
"Parity-7.0.0",
|
||||
"PDDL-1.0",
|
||||
"PHP-3.0",
|
||||
"PHP-3.01",
|
||||
"Plexus",
|
||||
"PolyForm-Noncommercial-1.0.0",
|
||||
"PolyForm-Small-Business-1.0.0",
|
||||
"PostgreSQL",
|
||||
"PSF-2.0",
|
||||
"psfrag",
|
||||
"psutils",
|
||||
"Python-2.0",
|
||||
"Python-2.0.1",
|
||||
"Qhull",
|
||||
"QPL-1.0",
|
||||
"QPL-1.0-INRIA-2004",
|
||||
"Rdisc",
|
||||
"RHeCos-1.1",
|
||||
"RPL-1.1",
|
||||
"RPL-1.5",
|
||||
"RPSL-1.0",
|
||||
"RSA-MD",
|
||||
"RSCPL",
|
||||
"Ruby",
|
||||
"SAX-PD",
|
||||
"Saxpath",
|
||||
"SCEA",
|
||||
"SchemeReport",
|
||||
"Sendmail",
|
||||
"Sendmail-8.23",
|
||||
"SGI-B-1.0",
|
||||
"SGI-B-1.1",
|
||||
"SGI-B-2.0",
|
||||
"SGP4",
|
||||
"SHL-0.5",
|
||||
"SHL-0.51",
|
||||
"SimPL-2.0",
|
||||
"SISSL",
|
||||
"SISSL-1.2",
|
||||
"Sleepycat",
|
||||
"SMLNJ",
|
||||
"SMPPL",
|
||||
"SNIA",
|
||||
"snprintf",
|
||||
"Spencer-86",
|
||||
"Spencer-94",
|
||||
"Spencer-99",
|
||||
"SPL-1.0",
|
||||
"SSH-OpenSSH",
|
||||
"SSH-short",
|
||||
"SSPL-1.0",
|
||||
"StandardML-NJ",
|
||||
"SugarCRM-1.1.3",
|
||||
"SunPro",
|
||||
"SWL",
|
||||
"Symlinks",
|
||||
"TAPR-OHL-1.0",
|
||||
"TCL",
|
||||
"TCP-wrappers",
|
||||
"TermReadKey",
|
||||
"TMate",
|
||||
"TORQUE-1.1",
|
||||
"TOSL",
|
||||
"TPDL",
|
||||
"TPL-1.0",
|
||||
"TTWL",
|
||||
"TU-Berlin-1.0",
|
||||
"TU-Berlin-2.0",
|
||||
"UCAR",
|
||||
"UCL-1.0",
|
||||
"Unicode-DFS-2015",
|
||||
"Unicode-DFS-2016",
|
||||
"Unicode-TOU",
|
||||
"UnixCrypt",
|
||||
"Unlicense",
|
||||
"UPL-1.0",
|
||||
"Vim",
|
||||
"VOSTROM",
|
||||
"VSL-1.0",
|
||||
"W3C",
|
||||
"W3C-19980720",
|
||||
"W3C-20150513",
|
||||
"w3m",
|
||||
"Watcom-1.0",
|
||||
"Widget-Workshop",
|
||||
"Wsuipa",
|
||||
"WTFPL",
|
||||
"wxWindows",
|
||||
"X11",
|
||||
"X11-distribute-modifications-variant",
|
||||
"Xdebug-1.03",
|
||||
"Xerox",
|
||||
"Xfig",
|
||||
"XFree86-1.1",
|
||||
"xinetd",
|
||||
"xlock",
|
||||
"Xnet",
|
||||
"xpp",
|
||||
"XSkat",
|
||||
"YPL-1.0",
|
||||
"YPL-1.1",
|
||||
"Zed",
|
||||
"Zend-2.0",
|
||||
"Zimbra-1.3",
|
||||
"Zimbra-1.4",
|
||||
"Zlib",
|
||||
"zlib-acknowledgement",
|
||||
"ZPL-1.1",
|
||||
"ZPL-2.0",
|
||||
"ZPL-2.1",
|
||||
"389-exception",
|
||||
"Asterisk-exception",
|
||||
"Autoconf-exception-2.0",
|
||||
"Autoconf-exception-3.0",
|
||||
"Autoconf-exception-generic",
|
||||
"Autoconf-exception-macro",
|
||||
"Bison-exception-2.2",
|
||||
"Bootloader-exception",
|
||||
"Classpath-exception-2.0",
|
||||
"CLISP-exception-2.0",
|
||||
"cryptsetup-OpenSSL-exception",
|
||||
"DigiRule-FOSS-exception",
|
||||
"eCos-exception-2.0",
|
||||
"Fawkes-Runtime-exception",
|
||||
"FLTK-exception",
|
||||
"Font-exception-2.0",
|
||||
"freertos-exception-2.0",
|
||||
"GCC-exception-2.0",
|
||||
"GCC-exception-3.1",
|
||||
"GNAT-exception",
|
||||
"gnu-javamail-exception",
|
||||
"GPL-3.0-interface-exception",
|
||||
"GPL-3.0-linking-exception",
|
||||
"GPL-3.0-linking-source-exception",
|
||||
"GPL-CC-1.0",
|
||||
"GStreamer-exception-2005",
|
||||
"GStreamer-exception-2008",
|
||||
"i2p-gpl-java-exception",
|
||||
"KiCad-libraries-exception",
|
||||
"LGPL-3.0-linking-exception",
|
||||
"libpri-OpenH323-exception",
|
||||
"Libtool-exception",
|
||||
"Linux-syscall-note",
|
||||
"LLGPL",
|
||||
"LLVM-exception",
|
||||
"LZMA-exception",
|
||||
"mif-exception",
|
||||
"Nokia-Qt-exception-1.1",
|
||||
"OCaml-LGPL-linking-exception",
|
||||
"OCCT-exception-1.0",
|
||||
"OpenJDK-assembly-exception-1.0",
|
||||
"openvpn-openssl-exception",
|
||||
"PS-or-PDF-font-exception-20170817",
|
||||
"QPL-1.0-INRIA-2004-exception",
|
||||
"Qt-GPL-exception-1.0",
|
||||
"Qt-LGPL-exception-1.1",
|
||||
"Qwt-exception-1.0",
|
||||
"SHL-2.0",
|
||||
"SHL-2.1",
|
||||
"SWI-exception",
|
||||
"Swift-exception",
|
||||
"u-boot-exception-2.0",
|
||||
"Universal-FOSS-exception-1.0",
|
||||
"vsftpd-openssl-exception",
|
||||
"WxWindows-exception-3.1",
|
||||
"x11vnc-openssl-exception"
|
||||
]
|
||||
}
|
||||
@@ -13,6 +13,7 @@ pub mod scan_matrix;
|
||||
pub mod telemetry;
|
||||
pub mod tenant;
|
||||
pub mod traits;
|
||||
pub mod vex_docs;
|
||||
|
||||
#[cfg(feature = "axum")]
|
||||
pub mod auth;
|
||||
|
||||
@@ -87,6 +87,17 @@ pub struct CveAlert {
|
||||
/// CISA Vulnrichment SSVC); `None` when it was not looked up.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub exploitation: Option<Exploitation>,
|
||||
/// The VEX statement on it (#498); none until someone states one.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub vex: Option<super::vex::VexAssessment>,
|
||||
/// When a complete scan last found it gone (the component removed or
|
||||
/// past a fixed version); `None` while it is reported.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "super::serde_helpers::opt_bson_datetime"
|
||||
)]
|
||||
pub resolved_at: Option<DateTime<Utc>>,
|
||||
#[serde(with = "super::serde_helpers::bson_datetime")]
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -126,6 +137,8 @@ impl CveAlert {
|
||||
aliases: Vec::new(),
|
||||
fixed_versions: Vec::new(),
|
||||
exploitation: None,
|
||||
vex: None,
|
||||
resolved_at: None,
|
||||
created_at: Utc::now(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ pub mod repository;
|
||||
pub mod sbom;
|
||||
pub mod scan;
|
||||
pub(crate) mod serde_helpers;
|
||||
pub mod vex;
|
||||
pub mod werkbank;
|
||||
|
||||
pub use auth::{AuthInfo, SupportTenant};
|
||||
@@ -62,6 +63,7 @@ pub use sbom::{SbomEntry, VulnRef};
|
||||
pub use scan::{
|
||||
RunErrorCode, ScanPhase, ScanRun, ScanRunStatus, ScanStep, ScanType, SkipCode, SkippedStage,
|
||||
};
|
||||
pub use vex::{VexAssessment, VexError, VexJustification, VexStatus};
|
||||
pub use werkbank::{
|
||||
CompleteRequest, CompleteResponse, DastCollect, Executor, HeartbeatAck, HeartbeatRequest,
|
||||
InputRef, Job, JobCollect, JobRecord, JobResult, JobRuntime, JobStatus, JobType, LeaseRequest,
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
//! What a manufacturer states about a known vulnerability in its product
|
||||
//! (VEX, #498): whether the product is affected, and why not or what to do.
|
||||
//!
|
||||
//! The vocabulary is OpenVEX's (CISA's minimum VEX requirements); the
|
||||
//! CycloneDX export maps it onto CycloneDX's own terms (see
|
||||
//! [`crate::vex_docs`]).
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The VEX status of a vulnerability in the product.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum VexStatus {
|
||||
/// Not assessed yet (every alert starts here).
|
||||
#[default]
|
||||
UnderInvestigation,
|
||||
/// The product is affected; `action_statement` says what to do.
|
||||
Affected,
|
||||
/// The product is not affected; `justification` or `impact_statement`
|
||||
/// says why.
|
||||
NotAffected,
|
||||
/// The product no longer contains the vulnerable component or version.
|
||||
Fixed,
|
||||
}
|
||||
|
||||
/// Why the product is not affected (OpenVEX's five justifications).
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum VexJustification {
|
||||
ComponentNotPresent,
|
||||
VulnerableCodeNotPresent,
|
||||
VulnerableCodeNotInExecutePath,
|
||||
VulnerableCodeCannotBeControlledByAdversary,
|
||||
InlineMitigationsAlreadyExist,
|
||||
}
|
||||
|
||||
/// One VEX statement on an alert: the status, its reasons, and who made it.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct VexAssessment {
|
||||
pub status: VexStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub justification: Option<VexJustification>,
|
||||
/// Why the product is not affected, in words.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub impact_statement: Option<String>,
|
||||
/// What users of an affected product must do.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub action_statement: Option<String>,
|
||||
/// The user id of whoever stated it, or the scan's actor.
|
||||
pub by: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub by_name: Option<String>,
|
||||
#[serde(with = "super::serde_helpers::bson_datetime")]
|
||||
pub at: DateTime<Utc>,
|
||||
/// Set by a scan (a `fixed` because the component is gone), not a person.
|
||||
#[serde(default)]
|
||||
pub by_scan: bool,
|
||||
}
|
||||
|
||||
/// Why a VEX statement cannot be stored.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
||||
pub enum VexError {
|
||||
#[error("not_affected needs a justification or an impact statement")]
|
||||
NotAffectedWithoutReason,
|
||||
#[error("affected needs an action statement saying what users must do")]
|
||||
AffectedWithoutAction,
|
||||
}
|
||||
|
||||
impl VexAssessment {
|
||||
/// Check what OpenVEX requires of a statement: a reason for
|
||||
/// `not_affected`, and (stricter than OpenVEX, as CISA recommends) an
|
||||
/// action for `affected`.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// The [`VexError`] naming what is missing.
|
||||
pub fn validate(&self) -> Result<(), VexError> {
|
||||
let has = |s: &Option<String>| s.as_deref().is_some_and(|t| !t.trim().is_empty());
|
||||
match self.status {
|
||||
VexStatus::NotAffected
|
||||
if self.justification.is_none() && !has(&self.impact_statement) =>
|
||||
{
|
||||
Err(VexError::NotAffectedWithoutReason)
|
||||
}
|
||||
VexStatus::Affected if !has(&self.action_statement) => {
|
||||
Err(VexError::AffectedWithoutAction)
|
||||
}
|
||||
VexStatus::UnderInvestigation
|
||||
| VexStatus::Affected
|
||||
| VexStatus::NotAffected
|
||||
| VexStatus::Fixed => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn statement(status: VexStatus) -> VexAssessment {
|
||||
VexAssessment {
|
||||
status,
|
||||
justification: None,
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
by: "u1".into(),
|
||||
by_name: None,
|
||||
at: Utc::now(),
|
||||
by_scan: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn statements_carry_their_reasons() {
|
||||
assert_eq!(
|
||||
statement(VexStatus::NotAffected).validate(),
|
||||
Err(VexError::NotAffectedWithoutReason)
|
||||
);
|
||||
let mut justified = statement(VexStatus::NotAffected);
|
||||
justified.justification = Some(VexJustification::VulnerableCodeNotInExecutePath);
|
||||
assert_eq!(justified.validate(), Ok(()));
|
||||
assert_eq!(
|
||||
statement(VexStatus::Affected).validate(),
|
||||
Err(VexError::AffectedWithoutAction)
|
||||
);
|
||||
assert_eq!(statement(VexStatus::UnderInvestigation).validate(), Ok(()));
|
||||
assert_eq!(
|
||||
serde_json::to_value(VexJustification::VulnerableCodeCannotBeControlledByAdversary)
|
||||
.ok(),
|
||||
Some(serde_json::json!(
|
||||
"vulnerable_code_cannot_be_controlled_by_adversary"
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,92 @@
|
||||
//! SBOM documents in the two exchange formats: CycloneDX 1.5 and SPDX 2.3.
|
||||
//! Shared by the agent's SBOM export and evidence pack and by the MCP server,
|
||||
//! so all of them say the same.
|
||||
//! so all of them say the same. The CycloneDX parts are shared with the VEX
|
||||
//! documents (see [`crate::vex_docs`]), which refer to the same `bom-ref`s.
|
||||
|
||||
use crate::models::SbomEntry;
|
||||
|
||||
/// A CycloneDX 1.5 document for `entries`, named after `subject`.
|
||||
pub fn cyclonedx(entries: &[SbomEntry], subject: &str) -> serde_json::Value {
|
||||
let components: Vec<serde_json::Value> = entries
|
||||
/// The `bom-ref` of a component, which a VEX statement refers to: its purl,
|
||||
/// or `<package manager>:<name>@<version>` without one.
|
||||
pub fn component_ref(entry: &SbomEntry) -> String {
|
||||
entry
|
||||
.purl
|
||||
.clone()
|
||||
.unwrap_or_else(|| format!("{}:{}@{}", entry.package_manager, entry.name, entry.version))
|
||||
}
|
||||
|
||||
/// The identifier of the product (the target) the SBOM and the VEX describe:
|
||||
/// `pkg:generic/<name>`, the name percent-encoded as a purl requires.
|
||||
pub fn product_ref(subject: &str) -> String {
|
||||
let encoded: String = subject
|
||||
.bytes()
|
||||
.map(|b| match b {
|
||||
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'.' | b'-' | b'_' | b'~' => {
|
||||
(b as char).to_string()
|
||||
}
|
||||
_ => format!("%{b:02X}"),
|
||||
})
|
||||
.collect();
|
||||
format!("pkg:generic/{encoded}")
|
||||
}
|
||||
|
||||
/// The SPDX license ids CycloneDX accepts as `license.id` (its own copy of
|
||||
/// the SPDX list).
|
||||
fn spdx_ids() -> &'static std::collections::HashSet<String> {
|
||||
static IDS: std::sync::LazyLock<std::collections::HashSet<String>> =
|
||||
std::sync::LazyLock::new(|| {
|
||||
serde_json::from_str::<serde_json::Value>(include_str!("../schemas/spdx.schema.json"))
|
||||
.ok()
|
||||
.and_then(|schema| {
|
||||
schema["enum"].as_array().map(|ids| {
|
||||
ids.iter()
|
||||
.filter_map(|id| id.as_str().map(str::to_string))
|
||||
.collect()
|
||||
})
|
||||
})
|
||||
.unwrap_or_default()
|
||||
});
|
||||
&IDS
|
||||
}
|
||||
|
||||
/// A license as CycloneDX writes it: an SPDX id it knows, an SPDX expression
|
||||
/// (`MIT OR Apache-2.0`), or a named license.
|
||||
fn license_choice(license: &str) -> serde_json::Value {
|
||||
let license = license.trim();
|
||||
if spdx_ids().contains(license) {
|
||||
serde_json::json!([{ "license": { "id": license } }])
|
||||
} else if [" OR ", " AND ", " WITH "]
|
||||
.iter()
|
||||
.any(|op| license.contains(op))
|
||||
{
|
||||
serde_json::json!([{ "expression": license }])
|
||||
} else {
|
||||
serde_json::json!([{ "license": { "name": license } }])
|
||||
}
|
||||
}
|
||||
|
||||
/// A CycloneDX severity from an advisory's (`HIGH`, `MODERATE`, `critical`).
|
||||
pub fn cdx_severity(severity: &str) -> &'static str {
|
||||
match severity.trim().to_ascii_lowercase().as_str() {
|
||||
"critical" => "critical",
|
||||
"high" => "high",
|
||||
"medium" | "moderate" => "medium",
|
||||
"low" => "low",
|
||||
"info" | "informational" => "info",
|
||||
"none" => "none",
|
||||
_ => "unknown",
|
||||
}
|
||||
}
|
||||
|
||||
/// The components of a CycloneDX document, each with its `bom-ref`.
|
||||
pub fn cdx_components(entries: &[SbomEntry]) -> Vec<serde_json::Value> {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
entries
|
||||
.iter()
|
||||
.filter(|e| seen.insert(component_ref(e)))
|
||||
.map(|e| {
|
||||
let mut comp = serde_json::json!({
|
||||
"type": "library",
|
||||
"bom-ref": component_ref(e),
|
||||
"name": e.name,
|
||||
"version": e.version,
|
||||
"group": e.package_manager,
|
||||
@@ -18,39 +94,86 @@ pub fn cyclonedx(entries: &[SbomEntry], subject: &str) -> serde_json::Value {
|
||||
if let Some(purl) = &e.purl {
|
||||
comp["purl"] = serde_json::Value::String(purl.clone());
|
||||
}
|
||||
if let Some(license) = &e.license {
|
||||
comp["licenses"] = serde_json::json!([{ "license": { "id": license } }]);
|
||||
}
|
||||
if !e.known_vulnerabilities.is_empty() {
|
||||
comp["vulnerabilities"] = serde_json::json!(e
|
||||
.known_vulnerabilities
|
||||
.iter()
|
||||
.map(|v| serde_json::json!({
|
||||
"id": v.id,
|
||||
"source": { "name": v.source },
|
||||
"ratings": v
|
||||
.severity
|
||||
.as_ref()
|
||||
.map(|s| vec![serde_json::json!({ "severity": s })])
|
||||
.unwrap_or_default(),
|
||||
}))
|
||||
.collect::<Vec<_>>());
|
||||
if let Some(license) = e.license.as_deref().filter(|l| !l.trim().is_empty()) {
|
||||
comp["licenses"] = license_choice(license);
|
||||
}
|
||||
comp
|
||||
})
|
||||
.collect();
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The frame of a CycloneDX 1.5 document about `subject`: a fresh serial
|
||||
/// number and the product as `metadata.component`.
|
||||
pub fn cdx_frame(subject: &str) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"bomFormat": "CycloneDX",
|
||||
"specVersion": "1.5",
|
||||
"serialNumber": format!("urn:uuid:{}", uuid::Uuid::new_v4()),
|
||||
"version": 1,
|
||||
"metadata": {
|
||||
"component": { "type": "application", "name": subject }
|
||||
"timestamp": chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
|
||||
"tools": { "components": [{ "type": "application", "name": "Prüfwerk" }] },
|
||||
"component": {
|
||||
"type": "application",
|
||||
"bom-ref": product_ref(subject),
|
||||
"name": subject,
|
||||
}
|
||||
},
|
||||
"components": components,
|
||||
})
|
||||
}
|
||||
|
||||
/// A CycloneDX 1.5 document for `entries`, named after `subject`. The known
|
||||
/// vulnerabilities of the components are listed at the top level, each
|
||||
/// naming the components it affects by `bom-ref` (CycloneDX keeps them out of
|
||||
/// the components).
|
||||
pub fn cyclonedx(entries: &[SbomEntry], subject: &str) -> serde_json::Value {
|
||||
let mut doc = cdx_frame(subject);
|
||||
doc["components"] = serde_json::Value::Array(cdx_components(entries));
|
||||
// One vulnerability per advisory, affecting every component it was
|
||||
// found in.
|
||||
let mut vulns: Vec<(String, String, Option<String>, Vec<String>)> = Vec::new();
|
||||
for e in entries {
|
||||
for v in &e.known_vulnerabilities {
|
||||
let reference = component_ref(e);
|
||||
match vulns
|
||||
.iter_mut()
|
||||
.find(|(id, source, ..)| *id == v.id && *source == v.source)
|
||||
{
|
||||
Some((.., refs)) => {
|
||||
if !refs.contains(&reference) {
|
||||
refs.push(reference);
|
||||
}
|
||||
}
|
||||
None => vulns.push((
|
||||
v.id.clone(),
|
||||
v.source.clone(),
|
||||
v.severity.clone(),
|
||||
vec![reference],
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
if !vulns.is_empty() {
|
||||
doc["vulnerabilities"] = serde_json::Value::Array(
|
||||
vulns
|
||||
.into_iter()
|
||||
.map(|(id, source, severity, refs)| {
|
||||
let mut v = serde_json::json!({
|
||||
"id": id,
|
||||
"source": { "name": source },
|
||||
"affects": refs.into_iter().map(|r| serde_json::json!({ "ref": r })).collect::<Vec<_>>(),
|
||||
});
|
||||
if let Some(severity) = severity {
|
||||
v["ratings"] = serde_json::json!([{ "severity": cdx_severity(&severity) }]);
|
||||
}
|
||||
v
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
doc
|
||||
}
|
||||
|
||||
/// An SPDX 2.3 document for `entries`, named after `subject`.
|
||||
pub fn spdx(entries: &[SbomEntry], subject: &str) -> serde_json::Value {
|
||||
let packages: Vec<serde_json::Value> = entries
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
//! VEX documents for a target (#498): what its manufacturer states about each
|
||||
//! known vulnerability of its components, in OpenVEX 0.2.0 and in CycloneDX
|
||||
//! 1.5 (the SBOM with its vulnerabilities and their analysis).
|
||||
//!
|
||||
//! An alert nobody assessed is `under_investigation`; one a complete scan no
|
||||
//! longer finds is `fixed`. The CycloneDX analysis uses CycloneDX's terms:
|
||||
//!
|
||||
//! | OpenVEX | CycloneDX |
|
||||
//! |---|---|
|
||||
//! | `under_investigation` | `in_triage` |
|
||||
//! | `affected` | `exploitable` |
|
||||
//! | `not_affected` | `not_affected` |
|
||||
//! | `fixed` | `resolved` |
|
||||
//! | `component_not_present`, `vulnerable_code_not_present` | `code_not_present` |
|
||||
//! | `vulnerable_code_not_in_execute_path` | `code_not_reachable` |
|
||||
//! | `vulnerable_code_cannot_be_controlled_by_adversary` | `requires_environment` |
|
||||
//! | `inline_mitigations_already_exist` | `protected_by_mitigating_control` |
|
||||
|
||||
use chrono::{DateTime, SecondsFormat, Utc};
|
||||
|
||||
use crate::models::{CveAlert, SbomEntry, VexJustification, VexStatus};
|
||||
use crate::sbom_docs::{cdx_components, cdx_frame, cdx_severity, component_ref, product_ref};
|
||||
|
||||
/// What a VEX document is built from.
|
||||
pub struct VexInput<'a> {
|
||||
/// The product: the target's name.
|
||||
pub subject: &'a str,
|
||||
/// Who states it (the manufacturer: the workspace's name).
|
||||
pub author: &'a str,
|
||||
/// The tool and version that wrote it (`Prüfwerk 0.4.5`).
|
||||
pub tooling: &'a str,
|
||||
pub alerts: &'a [CveAlert],
|
||||
pub sbom: &'a [SbomEntry],
|
||||
pub now: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// The status an alert is stated with: its VEX statement's, `fixed` once a
|
||||
/// complete scan found it gone, else `under_investigation`.
|
||||
pub fn status_of(alert: &CveAlert) -> VexStatus {
|
||||
match (&alert.vex, alert.resolved_at) {
|
||||
(Some(vex), _) => vex.status,
|
||||
(None, Some(_)) => VexStatus::Fixed,
|
||||
(None, None) => VexStatus::UnderInvestigation,
|
||||
}
|
||||
}
|
||||
|
||||
/// The SBOM entry an alert is about, if it is in the SBOM.
|
||||
fn entry_of<'a>(alert: &CveAlert, sbom: &'a [SbomEntry]) -> Option<&'a SbomEntry> {
|
||||
sbom.iter().find(|e| {
|
||||
e.name.eq_ignore_ascii_case(&alert.affected_package) && e.version == alert.affected_version
|
||||
})
|
||||
}
|
||||
|
||||
/// The identifier of the component an alert is about: the SBOM's `bom-ref`
|
||||
/// (its purl), or a generic purl of the package and version.
|
||||
fn component_id(alert: &CveAlert, sbom: &[SbomEntry]) -> String {
|
||||
entry_of(alert, sbom).map_or_else(
|
||||
|| {
|
||||
let mut name = product_ref(&alert.affected_package);
|
||||
name.push('@');
|
||||
name.push_str(&alert.affected_version);
|
||||
name
|
||||
},
|
||||
component_ref,
|
||||
)
|
||||
}
|
||||
|
||||
fn rfc3339(at: DateTime<Utc>) -> String {
|
||||
at.to_rfc3339_opts(SecondsFormat::Secs, true)
|
||||
}
|
||||
|
||||
/// An OpenVEX 0.2.0 document: one statement per alert, about the product
|
||||
/// with the affected component as its subcomponent.
|
||||
pub fn openvex(input: &VexInput<'_>) -> serde_json::Value {
|
||||
let product = product_ref(input.subject);
|
||||
let statements: Vec<serde_json::Value> = input
|
||||
.alerts
|
||||
.iter()
|
||||
.map(|alert| {
|
||||
let component = component_id(alert, input.sbom);
|
||||
let mut subcomponent = serde_json::json!({ "@id": component });
|
||||
if component.starts_with("pkg:") {
|
||||
subcomponent["identifiers"] = serde_json::json!({ "purl": component });
|
||||
}
|
||||
let mut vulnerability = serde_json::json!({ "name": alert.cve_id });
|
||||
if !alert.aliases.is_empty() {
|
||||
vulnerability["aliases"] = serde_json::json!(alert.aliases);
|
||||
}
|
||||
let status = status_of(alert);
|
||||
let mut statement = serde_json::json!({
|
||||
"vulnerability": vulnerability,
|
||||
"products": [{
|
||||
"@id": product,
|
||||
"identifiers": { "purl": product },
|
||||
"subcomponents": [subcomponent],
|
||||
}],
|
||||
"status": status,
|
||||
});
|
||||
if let Some(vex) = &alert.vex {
|
||||
statement["timestamp"] = serde_json::json!(rfc3339(vex.at));
|
||||
if let Some(j) = vex.justification {
|
||||
statement["justification"] = serde_json::json!(j);
|
||||
}
|
||||
if let Some(text) = vex.impact_statement.as_deref() {
|
||||
statement["impact_statement"] = serde_json::json!(text);
|
||||
}
|
||||
if let Some(text) = vex.action_statement.as_deref() {
|
||||
statement["action_statement"] = serde_json::json!(text);
|
||||
}
|
||||
} else if status == VexStatus::Fixed {
|
||||
statement["status_notes"] =
|
||||
serde_json::json!("The component or version is no longer in the product.");
|
||||
}
|
||||
statement
|
||||
})
|
||||
.collect();
|
||||
serde_json::json!({
|
||||
"@context": "https://openvex.dev/ns/v0.2.0",
|
||||
"@id": format!("urn:uuid:{}", uuid::Uuid::new_v4()),
|
||||
"author": input.author,
|
||||
"timestamp": rfc3339(input.now),
|
||||
"version": 1,
|
||||
"tooling": input.tooling,
|
||||
"statements": statements,
|
||||
})
|
||||
}
|
||||
|
||||
/// CycloneDX's analysis state for a VEX status.
|
||||
fn cdx_state(status: VexStatus) -> &'static str {
|
||||
match status {
|
||||
VexStatus::UnderInvestigation => "in_triage",
|
||||
VexStatus::Affected => "exploitable",
|
||||
VexStatus::NotAffected => "not_affected",
|
||||
VexStatus::Fixed => "resolved",
|
||||
}
|
||||
}
|
||||
|
||||
/// CycloneDX's justification for an OpenVEX one.
|
||||
fn cdx_justification(justification: VexJustification) -> &'static str {
|
||||
match justification {
|
||||
VexJustification::ComponentNotPresent | VexJustification::VulnerableCodeNotPresent => {
|
||||
"code_not_present"
|
||||
}
|
||||
VexJustification::VulnerableCodeNotInExecutePath => "code_not_reachable",
|
||||
VexJustification::VulnerableCodeCannotBeControlledByAdversary => "requires_environment",
|
||||
VexJustification::InlineMitigationsAlreadyExist => "protected_by_mitigating_control",
|
||||
}
|
||||
}
|
||||
|
||||
/// A CycloneDX 1.5 VEX: the SBOM's components, and every alert as a
|
||||
/// vulnerability with its analysis, affecting its component by `bom-ref`.
|
||||
pub fn cyclonedx_vex(input: &VexInput<'_>) -> serde_json::Value {
|
||||
let mut doc = cdx_frame(input.subject);
|
||||
let mut components = cdx_components(input.sbom);
|
||||
let mut refs: std::collections::HashSet<String> = components
|
||||
.iter()
|
||||
.filter_map(|c| c["bom-ref"].as_str().map(str::to_string))
|
||||
.collect();
|
||||
let vulnerabilities: Vec<serde_json::Value> = input
|
||||
.alerts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, alert)| {
|
||||
let component = component_id(alert, input.sbom);
|
||||
// A component the SBOM no longer lists (a fixed one) is still
|
||||
// named, so the reference resolves.
|
||||
if refs.insert(component.clone()) {
|
||||
components.push(serde_json::json!({
|
||||
"type": "library",
|
||||
"bom-ref": component,
|
||||
"name": alert.affected_package,
|
||||
"version": alert.affected_version,
|
||||
}));
|
||||
}
|
||||
let status = status_of(alert);
|
||||
let mut analysis = serde_json::json!({ "state": cdx_state(status) });
|
||||
if let Some(vex) = &alert.vex {
|
||||
if let Some(j) = vex.justification {
|
||||
analysis["justification"] = serde_json::json!(cdx_justification(j));
|
||||
}
|
||||
let detail: Vec<&str> = [
|
||||
vex.impact_statement.as_deref(),
|
||||
vex.action_statement.as_deref(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
if !detail.is_empty() {
|
||||
analysis["detail"] = serde_json::json!(detail.join("\n\n"));
|
||||
}
|
||||
}
|
||||
if status == VexStatus::Affected && !alert.fixed_versions.is_empty() {
|
||||
analysis["response"] = serde_json::json!(["update"]);
|
||||
}
|
||||
let mut v = serde_json::json!({
|
||||
"bom-ref": format!("vex-{i}-{}", alert.cve_id),
|
||||
"id": alert.cve_id,
|
||||
"source": { "name": format!("{:?}", alert.source).to_uppercase() },
|
||||
"analysis": analysis,
|
||||
"affects": [{ "ref": component }],
|
||||
});
|
||||
if let Some(severity) = alert.severity.as_deref() {
|
||||
v["ratings"] = serde_json::json!([{ "severity": cdx_severity(severity) }]);
|
||||
}
|
||||
if let Some(summary) = alert.summary.as_deref() {
|
||||
v["description"] = serde_json::json!(summary);
|
||||
}
|
||||
if !alert.fixed_versions.is_empty() {
|
||||
v["recommendation"] = serde_json::json!(format!(
|
||||
"Update {} to {}.",
|
||||
alert.affected_package,
|
||||
alert.fixed_versions.join(" or ")
|
||||
));
|
||||
}
|
||||
v
|
||||
})
|
||||
.collect();
|
||||
doc["components"] = serde_json::Value::Array(components);
|
||||
doc["vulnerabilities"] = serde_json::Value::Array(vulnerabilities);
|
||||
doc
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
//! The SBOM and VEX documents Prüfwerk writes against the official schemas
|
||||
//! vendored in `schemas/` (#498): CycloneDX 1.5 and OpenVEX 0.2.0.
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
use chrono::Utc;
|
||||
use compliance_core::models::{
|
||||
CveAlert, CveSource, SbomEntry, VexAssessment, VexJustification, VexStatus, VulnRef,
|
||||
};
|
||||
use compliance_core::sbom_docs;
|
||||
use compliance_core::vex_docs::{self, VexInput};
|
||||
|
||||
fn schema(name: &str) -> serde_json::Value {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("schemas")
|
||||
.join(name);
|
||||
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
/// The errors of `doc` against CycloneDX 1.5 (with the SPDX and JSF schemas
|
||||
/// it refers to).
|
||||
fn cyclonedx_errors(doc: &serde_json::Value) -> Vec<String> {
|
||||
let validator = jsonschema::options()
|
||||
.with_resource(
|
||||
"http://cyclonedx.org/schema/spdx.schema.json",
|
||||
jsonschema::Resource::from_contents(schema("spdx.schema.json")).unwrap(),
|
||||
)
|
||||
.with_resource(
|
||||
"http://cyclonedx.org/schema/jsf-0.82.schema.json",
|
||||
jsonschema::Resource::from_contents(schema("jsf-0.82.schema.json")).unwrap(),
|
||||
)
|
||||
.build(&schema("bom-1.5.schema.json"))
|
||||
.unwrap();
|
||||
validator
|
||||
.iter_errors(doc)
|
||||
.map(|e| format!("{} at {}", e, e.instance_path))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn openvex_errors(doc: &serde_json::Value) -> Vec<String> {
|
||||
let validator = jsonschema::validator_for(&schema("openvex-0.2.0.schema.json")).unwrap();
|
||||
validator
|
||||
.iter_errors(doc)
|
||||
.map(|e| format!("{} at {}", e, e.instance_path))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn sbom() -> Vec<SbomEntry> {
|
||||
let mut log4j = SbomEntry::new(
|
||||
"t".into(),
|
||||
"log4j-core".into(),
|
||||
"2.14.1".into(),
|
||||
"maven".into(),
|
||||
);
|
||||
log4j.purl = Some("pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1".into());
|
||||
log4j.license = Some("Apache-2.0".into());
|
||||
log4j.known_vulnerabilities = vec![VulnRef {
|
||||
id: "GHSA-jfh8-c2jp-5v3q".into(),
|
||||
source: "osv".into(),
|
||||
severity: Some("CRITICAL".into()),
|
||||
url: None,
|
||||
exploitation: None,
|
||||
}];
|
||||
let mut lodash = SbomEntry::new("t".into(), "lodash".into(), "4.17.20".into(), "npm".into());
|
||||
lodash.purl = Some("pkg:npm/lodash@4.17.20".into());
|
||||
lodash.license = Some("MIT OR Apache-2.0".into());
|
||||
let mut fw = SbomEntry::new(
|
||||
"t".into(),
|
||||
"PumpSDK".into(),
|
||||
"3.1.0".into(),
|
||||
"carthage".into(),
|
||||
);
|
||||
fw.license = Some("Custom Pump License".into());
|
||||
vec![log4j, lodash, fw]
|
||||
}
|
||||
|
||||
fn alert(id: &str, package: &str, version: &str) -> CveAlert {
|
||||
let mut a = CveAlert::new(
|
||||
id.into(),
|
||||
"t".into(),
|
||||
package.into(),
|
||||
version.into(),
|
||||
CveSource::Osv,
|
||||
);
|
||||
a.severity = Some("HIGH".into());
|
||||
a
|
||||
}
|
||||
|
||||
fn statement(status: VexStatus) -> VexAssessment {
|
||||
VexAssessment {
|
||||
status,
|
||||
justification: None,
|
||||
impact_statement: None,
|
||||
action_statement: None,
|
||||
by: "u1".into(),
|
||||
by_name: Some("Erika".into()),
|
||||
at: Utc::now(),
|
||||
by_scan: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn alerts() -> Vec<CveAlert> {
|
||||
let mut affected = alert("CVE-2021-44228", "log4j-core", "2.14.1");
|
||||
let mut s = statement(VexStatus::Affected);
|
||||
s.action_statement = Some("Update the pump app to 4.2, which ships log4j 2.17.1.".into());
|
||||
affected.vex = Some(s);
|
||||
affected.fixed_versions = vec!["2.17.1".into()];
|
||||
let mut not_affected = alert("CVE-2021-23337", "lodash", "4.17.20");
|
||||
let mut s = statement(VexStatus::NotAffected);
|
||||
s.justification = Some(VexJustification::VulnerableCodeNotInExecutePath);
|
||||
s.impact_statement = Some("template() is never called.".into());
|
||||
not_affected.vex = Some(s);
|
||||
let mut gone = alert("CVE-2020-0001", "zlib", "1.2.11");
|
||||
gone.resolved_at = Some(Utc::now());
|
||||
vec![
|
||||
affected,
|
||||
not_affected,
|
||||
gone,
|
||||
alert("CVE-2024-0002", "PumpSDK", "3.1.0"),
|
||||
]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_cyclonedx_sbom_is_valid_and_its_vulnerabilities_point_at_components() {
|
||||
let doc = sbom_docs::cyclonedx(&sbom(), "Pump Remote");
|
||||
assert_eq!(cyclonedx_errors(&doc), Vec::<String>::new());
|
||||
assert_eq!(
|
||||
doc["metadata"]["component"]["bom-ref"],
|
||||
"pkg:generic/Pump%20Remote"
|
||||
);
|
||||
assert_eq!(
|
||||
doc["vulnerabilities"][0]["affects"][0]["ref"],
|
||||
"pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1"
|
||||
);
|
||||
assert_eq!(
|
||||
doc["components"][1]["licenses"][0]["expression"],
|
||||
"MIT OR Apache-2.0"
|
||||
);
|
||||
assert_eq!(
|
||||
doc["components"][2]["licenses"][0]["license"]["name"],
|
||||
"Custom Pump License"
|
||||
);
|
||||
// The checks catch what was wrong before: vulnerabilities inside a
|
||||
// component, and a license name passed off as an SPDX id.
|
||||
let mut nested = doc.clone();
|
||||
nested["components"][0]["vulnerabilities"] = serde_json::json!([]);
|
||||
assert!(!cyclonedx_errors(&nested).is_empty());
|
||||
let mut bad_id = doc.clone();
|
||||
bad_id["components"][2]["licenses"] =
|
||||
serde_json::json!([{ "license": { "id": "Custom Pump License" } }]);
|
||||
assert!(!cyclonedx_errors(&bad_id).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_vex_documents_are_valid_against_their_schemas() {
|
||||
let sbom = sbom();
|
||||
let alerts = alerts();
|
||||
let input = VexInput {
|
||||
subject: "Pump Remote",
|
||||
author: "Example Pumps GmbH",
|
||||
tooling: "Prüfwerk test",
|
||||
alerts: &alerts,
|
||||
sbom: &sbom,
|
||||
now: Utc::now(),
|
||||
};
|
||||
let openvex = vex_docs::openvex(&input);
|
||||
assert_eq!(openvex_errors(&openvex), Vec::<String>::new());
|
||||
let mut no_status = openvex.clone();
|
||||
no_status["statements"][0]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("status");
|
||||
assert!(!openvex_errors(&no_status).is_empty());
|
||||
let statuses: Vec<&str> = openvex["statements"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|s| s["status"].as_str().unwrap())
|
||||
.collect();
|
||||
assert_eq!(
|
||||
statuses,
|
||||
["affected", "not_affected", "fixed", "under_investigation"]
|
||||
);
|
||||
assert_eq!(
|
||||
openvex["statements"][1]["justification"],
|
||||
"vulnerable_code_not_in_execute_path"
|
||||
);
|
||||
|
||||
let cdx = vex_docs::cyclonedx_vex(&input);
|
||||
assert_eq!(cyclonedx_errors(&cdx), Vec::<String>::new());
|
||||
let states: Vec<&str> = cdx["vulnerabilities"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|v| v["analysis"]["state"].as_str().unwrap())
|
||||
.collect();
|
||||
assert_eq!(
|
||||
states,
|
||||
["exploitable", "not_affected", "resolved", "in_triage"]
|
||||
);
|
||||
assert_eq!(
|
||||
cdx["vulnerabilities"][1]["analysis"]["justification"],
|
||||
"code_not_reachable"
|
||||
);
|
||||
assert_eq!(
|
||||
cdx["vulnerabilities"][0]["analysis"]["response"][0],
|
||||
"update"
|
||||
);
|
||||
}
|
||||
@@ -195,6 +195,60 @@ Copyleft-licensed dependencies can require you to release your source code under
|
||||
|
||||
The evidence pack on the target's page also contains both formats.
|
||||
|
||||
The CycloneDX document follows the CycloneDX 1.5 schema: every component has
|
||||
a `bom-ref` (its purl, or `<package manager>:<name>@<version>`), the product
|
||||
itself is `metadata.component` with the `bom-ref` `pkg:generic/<target name>`,
|
||||
and the known vulnerabilities are listed at the top level, each naming the
|
||||
components it affects. Licenses are an SPDX id, an SPDX expression or a named
|
||||
license, as CycloneDX allows.
|
||||
|
||||
## VEX: the status of each vulnerability
|
||||
|
||||
For each known vulnerability (CVE alert) of a target you state whether the
|
||||
product is affected (VEX, *Vulnerability Exploitability eXchange*), as the CRA
|
||||
expects of a manufacturer handling vulnerabilities:
|
||||
|
||||
| Status | Meaning | Required |
|
||||
|---|---|---|
|
||||
| `under_investigation` | Not assessed yet; every alert starts here | -- |
|
||||
| `affected` | The product is affected | an action statement: what users must do |
|
||||
| `not_affected` | The product is not affected | a justification or an impact statement |
|
||||
| `fixed` | The product no longer contains the vulnerable component or version | -- |
|
||||
|
||||
Justifications for `not_affected` (OpenVEX): `component_not_present`,
|
||||
`vulnerable_code_not_present`, `vulnerable_code_not_in_execute_path`,
|
||||
`vulnerable_code_cannot_be_controlled_by_adversary`,
|
||||
`inline_mitigations_already_exist`. A statement without what its status
|
||||
requires is refused.
|
||||
|
||||
A scan keeps the status current: when a complete CVE check no longer finds an
|
||||
alert (the component was removed or updated past the fix), it is marked
|
||||
resolved, and one nobody assessed, or assessed as affected, becomes `fixed`.
|
||||
A `not_affected` or `fixed` someone stated is never changed by a scan. If the
|
||||
vulnerability comes back, the scan's `fixed` is withdrawn.
|
||||
|
||||
The statements are exported per target as **OpenVEX 0.2.0** and as
|
||||
**CycloneDX 1.5 VEX** (the SBOM with each vulnerability's analysis), both
|
||||
checked against their official schemas, and are part of the evidence pack
|
||||
(`vex.openvex.json`, `vex.cdx.json`). CycloneDX names the statuses
|
||||
differently:
|
||||
|
||||
| OpenVEX | CycloneDX `analysis.state` / `justification` |
|
||||
|---|---|
|
||||
| `under_investigation` | `in_triage` |
|
||||
| `affected` | `exploitable` (`response: update` when a fixed version is known) |
|
||||
| `not_affected` | `not_affected` |
|
||||
| `fixed` | `resolved` |
|
||||
| `component_not_present`, `vulnerable_code_not_present` | `code_not_present` |
|
||||
| `vulnerable_code_not_in_execute_path` | `code_not_reachable` |
|
||||
| `vulnerable_code_cannot_be_controlled_by_adversary` | `requires_environment` |
|
||||
| `inline_mitigations_already_exist` | `protected_by_mitigating_control` |
|
||||
|
||||
API: `GET /api/v1/targets/{id}/cves` lists the alerts with their statements,
|
||||
`PATCH /api/v1/cves/{id}/vex` sets one
|
||||
(`{"status": "not_affected", "justification": "…", "impact_statement": "…"}`),
|
||||
`GET /api/v1/targets/{id}/vex?format=openvex|cyclonedx` downloads the document.
|
||||
|
||||
## Compare Tab
|
||||
|
||||
**Vergleich** compares the SBOMs of two targets, for example two firmware
|
||||
|
||||
@@ -21,6 +21,7 @@ together on stage in one pass before the next prod promotion.
|
||||
| #491 | Findings keyed by the code they flag, not its line number |
|
||||
| #491 (PLC) | PLC findings keyed the same way |
|
||||
| #495 | Binary depth: PE/ELF hardening, signatures, .NET references, CPE/purl candidates, Intel HEX checks |
|
||||
| #498 (1/4) | VEX status on CVE alerts, OpenVEX and CycloneDX VEX, a valid CycloneDX SBOM |
|
||||
|
||||
**Customer-visible on the next prod rescan** is marked **[visible]**: these
|
||||
change what a customer sees on their existing targets, without them doing
|
||||
@@ -356,7 +357,7 @@ target with history (findings, at least one marked by a person, issues).
|
||||
`CVE_ISSUE_EPSS_PERCENTILE` (default `0.95`, `off`) sets the EPSS step-up.
|
||||
- **[visible]** KEV and EPSS badges on the SBOM page; CVE issues for KEV
|
||||
CVEs whatever their severity.
|
||||
||||||| parent of 8c986d6 (feat(plc): PLC findings keyed by what they flag, saved through RunFindings (#491 follow-up))
|
||||
|
||||
### 20. #491 follow-up: PLC findings
|
||||
|
||||
- **Do:** rescan an existing PLC target (e.g. `fixtures/nightly/plc/mixer_ld.xml`
|
||||
@@ -417,6 +418,39 @@ from the nupkg on nuget.org, and any unsigned native DLL you have).
|
||||
findings are not rewritten); grouped ones (#477) and new or changed files
|
||||
show the evidence.
|
||||
|
||||
### 22. #498 part 1: VEX on CVE alerts and valid CycloneDX
|
||||
|
||||
API only for now (the dashboard follows in part 2). Use a target with CVE
|
||||
alerts (e.g. the log4j/gson target of check 19).
|
||||
|
||||
- **Do:** `GET /api/v1/targets/<id>/cves`: every alert, `vex` absent
|
||||
(under investigation). `PATCH /api/v1/cves/<alert id>/vex` with
|
||||
`{"status":"not_affected"}` alone, then with
|
||||
`{"status":"not_affected","justification":"vulnerable_code_not_in_execute_path"}`;
|
||||
`{"status":"affected"}` alone, then with an `action_statement`.
|
||||
- **Expect:** the ones without their reason are refused with 422
|
||||
(`not_affected needs a justification or an impact statement`,
|
||||
`affected needs an action statement …`); the complete ones are stored with
|
||||
who and when.
|
||||
- **Do:** `GET /api/v1/targets/<id>/vex` and `…/vex?format=cyclonedx`;
|
||||
download the evidence pack.
|
||||
- **Expect:** OpenVEX with one statement per alert (status, justification,
|
||||
the product `pkg:generic/<target>` with the component as subcomponent);
|
||||
CycloneDX with the components (`bom-ref`s) and each vulnerability's
|
||||
`analysis` (`in_triage`, `not_affected` + `code_not_reachable`,
|
||||
`exploitable` + `response: update` …); both validate (e.g.
|
||||
`vexctl` / CycloneDX's online validator). The pack holds `vex.openvex.json`
|
||||
and `vex.cdx.json`. The SBOM export (`sbom.cdx.json`) validates against
|
||||
CycloneDX 1.5 now (vulnerabilities at the top level, `bom-ref`s, serial
|
||||
number).
|
||||
- **Do:** update the vulnerable dependency (e.g. log4j-core to 2.17.1), rescan.
|
||||
- **Expect:** CVE-2021-44228's alert gets `resolved_at` and, unless someone
|
||||
stated `not_affected`, the VEX status `fixed` (`by_scan: true`).
|
||||
Log: `CVE alerts no longer found marked resolved`.
|
||||
- **[visible]** customers who download the SBOM get a CycloneDX file that
|
||||
validates (before, vulnerabilities sat inside the components); the
|
||||
evidence pack gains the two VEX files.
|
||||
|
||||
## After the pass
|
||||
|
||||
- The nightly job on `main` is green with the new mobile targets.
|
||||
|
||||
Reference in new issue
Block a user