feat(sbom): CycloneDX 1.6 export with BSI TR-03183-2 properties (#508, part A)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m13s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m13s
- CycloneDX 1.6 for the SBOM and the CycloneDX VEX, validated against the vendored 1.6 schema (replaces 1.5; the 1.6 SPDX licence list). - metadata.manufacturer: BreakPilot GmbH, kontakt@breakpilot.com, the SBOM's creator (decided by the user). metadata.component: the target by its name (the export used repo-<id>), with a purl and, as its version, when its SBOM data was last compiled (the TR's rule for a component without a version). - Registry packages get bsi:component:filename from their purl (npm, Maven with type/classifier, NuGet, Cargo, gems, Hex) and executable/archive/ structured as for the TR's rpm example. Others get none. - Dependency graph: the product depends on every component, each has its own entry; compositions states it incomplete (the SBOM is flat). - Licences carry acknowledgement "declared". group is the purl namespace, not the package manager. - compliance_core::purl: a small purl parser. - Tests: schema validation with the new fields; an #[ignore] test scoring the document with sbomqs (bsi-v2.1: 0.93 F before #498, 6.67 D now). - Docs: the export's fields and what stays open and why. Test plan check 27. Still open (part B): component creator URLs, SHA-512 deployable hashes and download URLs from lockfiles, committed binaries. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
4448a5394f
commit
4c9ea58fe9
18 files changed
+2708
-273
No files matched your search
@@ -165,11 +165,21 @@ pub async fn export_sbom(
|
||||
}
|
||||
};
|
||||
|
||||
let subject = format!("repo-{}", params.repo_id);
|
||||
let body = if params.format == "spdx" {
|
||||
compliance_core::sbom_docs::spdx(&entries, ¶ms.repo_id)
|
||||
} else {
|
||||
compliance_core::sbom_docs::cyclonedx(&entries, &subject)
|
||||
// The product is the target, by its name as in the evidence pack.
|
||||
let target = match mongodb::bson::oid::ObjectId::parse_str(¶ms.repo_id) {
|
||||
Ok(oid) => db
|
||||
.onboarded_targets()
|
||||
.find_one(doc! { "_id": oid })
|
||||
.await
|
||||
.ok()
|
||||
.flatten(),
|
||||
Err(_) => None,
|
||||
};
|
||||
let name = target.map_or_else(|| format!("repo-{}", params.repo_id), |t| t.name);
|
||||
compliance_core::sbom_docs::cyclonedx(&entries, &name)
|
||||
};
|
||||
|
||||
let json_str =
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Vendored schemas
|
||||
|
||||
Official schemas the documents Prüfwerk writes are checked against (#498):
|
||||
Official schemas the documents Prüfwerk writes are checked against (#498,
|
||||
#508):
|
||||
`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 |
|
||||
| `bom-1.6.schema.json`, `spdx.schema.json`, `jsf-0.82.schema.json` | CycloneDX specification, tag 1.6 (`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.
|
||||
+2102
-229
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://cyclonedx.org/schema/spdx.schema.json",
|
||||
"$comment": "v1.0-3.21",
|
||||
"$comment": "v1.0-3.23",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"0BSD",
|
||||
@@ -9,7 +9,9 @@
|
||||
"Abstyles",
|
||||
"AdaCore-doc",
|
||||
"Adobe-2006",
|
||||
"Adobe-Display-PostScript",
|
||||
"Adobe-Glyph",
|
||||
"Adobe-Utopia",
|
||||
"ADSL",
|
||||
"AFL-1.1",
|
||||
"AFL-1.2",
|
||||
@@ -26,6 +28,7 @@
|
||||
"Aladdin",
|
||||
"AMDPLPA",
|
||||
"AML",
|
||||
"AML-glslang",
|
||||
"AMPAS",
|
||||
"ANTLR-PD",
|
||||
"ANTLR-PD-fallback",
|
||||
@@ -49,6 +52,7 @@
|
||||
"Baekmuk",
|
||||
"Bahyph",
|
||||
"Barr",
|
||||
"bcrypt-Solar-Designer",
|
||||
"Beerware",
|
||||
"Bitstream-Charter",
|
||||
"Bitstream-Vera",
|
||||
@@ -58,16 +62,21 @@
|
||||
"BlueOak-1.0.0",
|
||||
"Boehm-GC",
|
||||
"Borceux",
|
||||
"Brian-Gladman-2-Clause",
|
||||
"Brian-Gladman-3-Clause",
|
||||
"BSD-1-Clause",
|
||||
"BSD-2-Clause",
|
||||
"BSD-2-Clause-Darwin",
|
||||
"BSD-2-Clause-FreeBSD",
|
||||
"BSD-2-Clause-NetBSD",
|
||||
"BSD-2-Clause-Patent",
|
||||
"BSD-2-Clause-Views",
|
||||
"BSD-3-Clause",
|
||||
"BSD-3-Clause-acpica",
|
||||
"BSD-3-Clause-Attribution",
|
||||
"BSD-3-Clause-Clear",
|
||||
"BSD-3-Clause-flex",
|
||||
"BSD-3-Clause-HP",
|
||||
"BSD-3-Clause-LBNL",
|
||||
"BSD-3-Clause-Modification",
|
||||
"BSD-3-Clause-No-Military-License",
|
||||
@@ -75,6 +84,7 @@
|
||||
"BSD-3-Clause-No-Nuclear-License-2014",
|
||||
"BSD-3-Clause-No-Nuclear-Warranty",
|
||||
"BSD-3-Clause-Open-MPI",
|
||||
"BSD-3-Clause-Sun",
|
||||
"BSD-4-Clause",
|
||||
"BSD-4-Clause-Shortened",
|
||||
"BSD-4-Clause-UC",
|
||||
@@ -82,8 +92,12 @@
|
||||
"BSD-4.3TAHOE",
|
||||
"BSD-Advertising-Acknowledgement",
|
||||
"BSD-Attribution-HPND-disclaimer",
|
||||
"BSD-Inferno-Nettverk",
|
||||
"BSD-Protection",
|
||||
"BSD-Source-beginning-file",
|
||||
"BSD-Source-Code",
|
||||
"BSD-Systemics",
|
||||
"BSD-Systemics-W3Works",
|
||||
"BSL-1.0",
|
||||
"BUSL-1.1",
|
||||
"bzip2-1.0.5",
|
||||
@@ -92,6 +106,7 @@
|
||||
"CAL-1.0",
|
||||
"CAL-1.0-Combined-Work-Exception",
|
||||
"Caldera",
|
||||
"Caldera-no-preamble",
|
||||
"CATOSL-1.1",
|
||||
"CC-BY-1.0",
|
||||
"CC-BY-2.0",
|
||||
@@ -99,6 +114,7 @@
|
||||
"CC-BY-2.5-AU",
|
||||
"CC-BY-3.0",
|
||||
"CC-BY-3.0-AT",
|
||||
"CC-BY-3.0-AU",
|
||||
"CC-BY-3.0-DE",
|
||||
"CC-BY-3.0-IGO",
|
||||
"CC-BY-3.0-NL",
|
||||
@@ -163,10 +179,12 @@
|
||||
"CERN-OHL-S-2.0",
|
||||
"CERN-OHL-W-2.0",
|
||||
"CFITSIO",
|
||||
"check-cvs",
|
||||
"checkmk",
|
||||
"ClArtistic",
|
||||
"Clips",
|
||||
"CMU-Mach",
|
||||
"CMU-Mach-nodoc",
|
||||
"CNRI-Jython",
|
||||
"CNRI-Python",
|
||||
"CNRI-Python-GPL-Compatible",
|
||||
@@ -179,17 +197,21 @@
|
||||
"CPAL-1.0",
|
||||
"CPL-1.0",
|
||||
"CPOL-1.02",
|
||||
"Cronyx",
|
||||
"Crossword",
|
||||
"CrystalStacker",
|
||||
"CUA-OPL-1.0",
|
||||
"Cube",
|
||||
"curl",
|
||||
"D-FSL-1.0",
|
||||
"DEC-3-Clause",
|
||||
"diffmark",
|
||||
"DL-DE-BY-2.0",
|
||||
"DL-DE-ZERO-2.0",
|
||||
"DOC",
|
||||
"Dotseqn",
|
||||
"DRL-1.0",
|
||||
"DRL-1.1",
|
||||
"DSDP",
|
||||
"dtoa",
|
||||
"dvipdfm",
|
||||
@@ -212,15 +234,21 @@
|
||||
"EUPL-1.2",
|
||||
"Eurosym",
|
||||
"Fair",
|
||||
"FBM",
|
||||
"FDK-AAC",
|
||||
"Ferguson-Twofish",
|
||||
"Frameworx-1.0",
|
||||
"FreeBSD-DOC",
|
||||
"FreeImage",
|
||||
"FSFAP",
|
||||
"FSFAP-no-warranty-disclaimer",
|
||||
"FSFUL",
|
||||
"FSFULLR",
|
||||
"FSFULLRWD",
|
||||
"FTL",
|
||||
"Furuseth",
|
||||
"fwlw",
|
||||
"GCR-docs",
|
||||
"GD",
|
||||
"GFDL-1.1",
|
||||
"GFDL-1.1-invariants-only",
|
||||
@@ -270,14 +298,29 @@
|
||||
"GPL-3.0-with-GCC-exception",
|
||||
"Graphics-Gems",
|
||||
"gSOAP-1.3b",
|
||||
"gtkbook",
|
||||
"HaskellReport",
|
||||
"hdparm",
|
||||
"Hippocratic-2.1",
|
||||
"HP-1986",
|
||||
"HP-1989",
|
||||
"HPND",
|
||||
"HPND-DEC",
|
||||
"HPND-doc",
|
||||
"HPND-doc-sell",
|
||||
"HPND-export-US",
|
||||
"HPND-export-US-modify",
|
||||
"HPND-Fenneberg-Livingston",
|
||||
"HPND-INRIA-IMAG",
|
||||
"HPND-Kevlin-Henney",
|
||||
"HPND-Markus-Kuhn",
|
||||
"HPND-MIT-disclaimer",
|
||||
"HPND-Pbmplus",
|
||||
"HPND-sell-MIT-disclaimer-xserver",
|
||||
"HPND-sell-regexpr",
|
||||
"HPND-sell-variant",
|
||||
"HPND-sell-variant-MIT-disclaimer",
|
||||
"HPND-UC",
|
||||
"HTMLTIDY",
|
||||
"IBM-pibs",
|
||||
"ICU",
|
||||
@@ -295,11 +338,13 @@
|
||||
"IPA",
|
||||
"IPL-1.0",
|
||||
"ISC",
|
||||
"ISC-Veillard",
|
||||
"Jam",
|
||||
"JasPer-2.0",
|
||||
"JPL-image",
|
||||
"JPNIC",
|
||||
"JSON",
|
||||
"Kastrup",
|
||||
"Kazlib",
|
||||
"Knuth-CTAN",
|
||||
"LAL-1.2",
|
||||
@@ -334,6 +379,7 @@
|
||||
"Linux-man-pages-copyleft-var",
|
||||
"Linux-OpenIB",
|
||||
"LOOP",
|
||||
"LPD-document",
|
||||
"LPL-1.0",
|
||||
"LPL-1.02",
|
||||
"LPPL-1.0",
|
||||
@@ -341,10 +387,17 @@
|
||||
"LPPL-1.2",
|
||||
"LPPL-1.3a",
|
||||
"LPPL-1.3c",
|
||||
"lsof",
|
||||
"Lucida-Bitmap-Fonts",
|
||||
"LZMA-SDK-9.11-to-9.20",
|
||||
"LZMA-SDK-9.22",
|
||||
"Mackerras-3-Clause",
|
||||
"Mackerras-3-Clause-acknowledgment",
|
||||
"magaz",
|
||||
"mailprio",
|
||||
"MakeIndex",
|
||||
"Martin-Birgmeier",
|
||||
"McPhee-slideshow",
|
||||
"metamail",
|
||||
"Minpack",
|
||||
"MirOS",
|
||||
@@ -357,9 +410,12 @@
|
||||
"MIT-Festival",
|
||||
"MIT-Modern-Variant",
|
||||
"MIT-open-group",
|
||||
"MIT-testregex",
|
||||
"MIT-Wu",
|
||||
"MITNFA",
|
||||
"MMIXware",
|
||||
"Motosoto",
|
||||
"MPEG-SSG",
|
||||
"mpi-permissive",
|
||||
"mpich2",
|
||||
"MPL-1.0",
|
||||
@@ -441,6 +497,8 @@
|
||||
"OML",
|
||||
"OpenPBS-2.3",
|
||||
"OpenSSL",
|
||||
"OpenSSL-standalone",
|
||||
"OpenVision",
|
||||
"OPL-1.0",
|
||||
"OPL-UK-3.0",
|
||||
"OPUBL-1.0",
|
||||
@@ -450,12 +508,15 @@
|
||||
"OSL-2.0",
|
||||
"OSL-2.1",
|
||||
"OSL-3.0",
|
||||
"PADL",
|
||||
"Parity-6.0.0",
|
||||
"Parity-7.0.0",
|
||||
"PDDL-1.0",
|
||||
"PHP-3.0",
|
||||
"PHP-3.01",
|
||||
"Pixar",
|
||||
"Plexus",
|
||||
"pnmstitch",
|
||||
"PolyForm-Noncommercial-1.0.0",
|
||||
"PolyForm-Small-Business-1.0.0",
|
||||
"PostgreSQL",
|
||||
@@ -464,9 +525,11 @@
|
||||
"psutils",
|
||||
"Python-2.0",
|
||||
"Python-2.0.1",
|
||||
"python-ldap",
|
||||
"Qhull",
|
||||
"QPL-1.0",
|
||||
"QPL-1.0-INRIA-2004",
|
||||
"radvd",
|
||||
"Rdisc",
|
||||
"RHeCos-1.1",
|
||||
"RPL-1.1",
|
||||
@@ -476,6 +539,7 @@
|
||||
"RSCPL",
|
||||
"Ruby",
|
||||
"SAX-PD",
|
||||
"SAX-PD-2.0",
|
||||
"Saxpath",
|
||||
"SCEA",
|
||||
"SchemeReport",
|
||||
@@ -484,49 +548,63 @@
|
||||
"SGI-B-1.0",
|
||||
"SGI-B-1.1",
|
||||
"SGI-B-2.0",
|
||||
"SGI-OpenGL",
|
||||
"SGP4",
|
||||
"SHL-0.5",
|
||||
"SHL-0.51",
|
||||
"SimPL-2.0",
|
||||
"SISSL",
|
||||
"SISSL-1.2",
|
||||
"SL",
|
||||
"Sleepycat",
|
||||
"SMLNJ",
|
||||
"SMPPL",
|
||||
"SNIA",
|
||||
"snprintf",
|
||||
"softSurfer",
|
||||
"Soundex",
|
||||
"Spencer-86",
|
||||
"Spencer-94",
|
||||
"Spencer-99",
|
||||
"SPL-1.0",
|
||||
"ssh-keyscan",
|
||||
"SSH-OpenSSH",
|
||||
"SSH-short",
|
||||
"SSLeay-standalone",
|
||||
"SSPL-1.0",
|
||||
"StandardML-NJ",
|
||||
"SugarCRM-1.1.3",
|
||||
"Sun-PPP",
|
||||
"SunPro",
|
||||
"SWL",
|
||||
"swrule",
|
||||
"Symlinks",
|
||||
"TAPR-OHL-1.0",
|
||||
"TCL",
|
||||
"TCP-wrappers",
|
||||
"TermReadKey",
|
||||
"TGPPL-1.0",
|
||||
"TMate",
|
||||
"TORQUE-1.1",
|
||||
"TOSL",
|
||||
"TPDL",
|
||||
"TPL-1.0",
|
||||
"TTWL",
|
||||
"TTYP0",
|
||||
"TU-Berlin-1.0",
|
||||
"TU-Berlin-2.0",
|
||||
"UCAR",
|
||||
"UCL-1.0",
|
||||
"ulem",
|
||||
"UMich-Merit",
|
||||
"Unicode-3.0",
|
||||
"Unicode-DFS-2015",
|
||||
"Unicode-DFS-2016",
|
||||
"Unicode-TOU",
|
||||
"UnixCrypt",
|
||||
"Unlicense",
|
||||
"UPL-1.0",
|
||||
"URT-RLE",
|
||||
"Vim",
|
||||
"VOSTROM",
|
||||
"VSL-1.0",
|
||||
@@ -546,6 +624,7 @@
|
||||
"Xfig",
|
||||
"XFree86-1.1",
|
||||
"xinetd",
|
||||
"xkeyboard-config-Zinoviev",
|
||||
"xlock",
|
||||
"Xnet",
|
||||
"xpp",
|
||||
@@ -553,6 +632,7 @@
|
||||
"YPL-1.0",
|
||||
"YPL-1.1",
|
||||
"Zed",
|
||||
"Zeeff",
|
||||
"Zend-2.0",
|
||||
"Zimbra-1.3",
|
||||
"Zimbra-1.4",
|
||||
@@ -566,7 +646,9 @@
|
||||
"Autoconf-exception-2.0",
|
||||
"Autoconf-exception-3.0",
|
||||
"Autoconf-exception-generic",
|
||||
"Autoconf-exception-generic-3.0",
|
||||
"Autoconf-exception-macro",
|
||||
"Bison-exception-1.24",
|
||||
"Bison-exception-2.2",
|
||||
"Bootloader-exception",
|
||||
"Classpath-exception-2.0",
|
||||
@@ -576,11 +658,16 @@
|
||||
"eCos-exception-2.0",
|
||||
"Fawkes-Runtime-exception",
|
||||
"FLTK-exception",
|
||||
"fmt-exception",
|
||||
"Font-exception-2.0",
|
||||
"freertos-exception-2.0",
|
||||
"GCC-exception-2.0",
|
||||
"GCC-exception-2.0-note",
|
||||
"GCC-exception-3.1",
|
||||
"Gmsh-exception",
|
||||
"GNAT-exception",
|
||||
"GNOME-examples-exception",
|
||||
"GNU-compiler-exception",
|
||||
"gnu-javamail-exception",
|
||||
"GPL-3.0-interface-exception",
|
||||
"GPL-3.0-linking-exception",
|
||||
@@ -608,11 +695,15 @@
|
||||
"Qt-GPL-exception-1.0",
|
||||
"Qt-LGPL-exception-1.1",
|
||||
"Qwt-exception-1.0",
|
||||
"SANE-exception",
|
||||
"SHL-2.0",
|
||||
"SHL-2.1",
|
||||
"stunnel-exception",
|
||||
"SWI-exception",
|
||||
"Swift-exception",
|
||||
"Texinfo-exception",
|
||||
"u-boot-exception-2.0",
|
||||
"UBDL-exception",
|
||||
"Universal-FOSS-exception-1.0",
|
||||
"vsftpd-openssl-exception",
|
||||
"WxWindows-exception-3.1",
|
||||
|
||||
@@ -7,6 +7,7 @@ pub mod exec_policy;
|
||||
pub mod guarded_net;
|
||||
pub mod models;
|
||||
pub mod net_guard;
|
||||
pub mod purl;
|
||||
pub mod sbom_docs;
|
||||
pub mod scan_matrix;
|
||||
#[cfg(feature = "telemetry")]
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
//! The parts of a package URL (purl), as far as the SBOM documents need them:
|
||||
//! `pkg:type/namespace/name@version?qualifiers#subpath`
|
||||
//! (<https://github.com/package-url/purl-spec>).
|
||||
|
||||
/// A parsed purl. Every part is percent-decoded.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Purl {
|
||||
/// The package type, lowercased (`npm`, `maven`, `nuget`).
|
||||
pub ty: String,
|
||||
/// The namespace: a Maven group id, an npm scope (`@angular`).
|
||||
pub namespace: Option<String>,
|
||||
pub name: String,
|
||||
pub version: Option<String>,
|
||||
/// The qualifiers in their order (`type=jar`, `classifier=sources`).
|
||||
pub qualifiers: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl Purl {
|
||||
/// Parse `purl`; `None` for anything that is not a `pkg:` URL with a type
|
||||
/// and a name.
|
||||
pub fn parse(purl: &str) -> Option<Self> {
|
||||
let rest = purl.strip_prefix("pkg:")?.trim_start_matches('/');
|
||||
// The subpath is not needed; the qualifiers end where it starts.
|
||||
let rest = rest.split('#').next().unwrap_or(rest);
|
||||
let (rest, qualifiers) = match rest.split_once('?') {
|
||||
Some((rest, query)) => (rest, query),
|
||||
None => (rest, ""),
|
||||
};
|
||||
let (path, version) = match rest.rsplit_once('@') {
|
||||
// An `@` in the path is an encoded npm scope (`%40angular`), so the
|
||||
// version separator is the last one, after the last `/`.
|
||||
Some((path, version)) if !version.contains('/') => (path, Some(decode(version))),
|
||||
_ => (rest, None),
|
||||
};
|
||||
let (ty, path) = path.split_once('/')?;
|
||||
let (namespace, name) = match path.rsplit_once('/') {
|
||||
Some((namespace, name)) => (Some(namespace), name),
|
||||
None => (None, path),
|
||||
};
|
||||
if ty.is_empty() || name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
ty: ty.to_ascii_lowercase(),
|
||||
namespace: namespace
|
||||
.filter(|n| !n.is_empty())
|
||||
.map(|n| n.split('/').map(decode).collect::<Vec<_>>().join("/")),
|
||||
name: decode(name),
|
||||
version: version.filter(|v| !v.is_empty()),
|
||||
qualifiers: qualifiers
|
||||
.split('&')
|
||||
.filter_map(|pair| pair.split_once('='))
|
||||
.map(|(k, v)| (k.to_ascii_lowercase(), decode(v)))
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
/// The value of qualifier `key`, if given.
|
||||
pub fn qualifier(&self, key: &str) -> Option<&str> {
|
||||
self.qualifiers
|
||||
.iter()
|
||||
.find(|(k, _)| k == key)
|
||||
.map(|(_, v)| v.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
/// `text` with its `%XX` escapes decoded; an invalid escape is kept as is.
|
||||
fn decode(text: &str) -> String {
|
||||
let bytes = text.as_bytes();
|
||||
let mut out = Vec::with_capacity(bytes.len());
|
||||
let mut i = 0;
|
||||
while i < bytes.len() {
|
||||
let escaped = (bytes[i] == b'%')
|
||||
.then(|| text.get(i + 1..i + 3))
|
||||
.flatten()
|
||||
.and_then(|hex| u8::from_str_radix(hex, 16).ok());
|
||||
match escaped {
|
||||
Some(byte) => {
|
||||
out.push(byte);
|
||||
i += 3;
|
||||
}
|
||||
None => {
|
||||
out.push(bytes[i]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
String::from_utf8_lossy(&out).into_owned()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_parts_are_read_and_decoded() {
|
||||
let p = Purl::parse("pkg:npm/%40angular/core@16.2.0").unwrap();
|
||||
assert_eq!(p.ty, "npm");
|
||||
assert_eq!(p.namespace.as_deref(), Some("@angular"));
|
||||
assert_eq!(p.name, "core");
|
||||
assert_eq!(p.version.as_deref(), Some("16.2.0"));
|
||||
|
||||
let p = Purl::parse(
|
||||
"pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1?classifier=tests&type=test-jar",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(p.namespace.as_deref(), Some("org.apache.logging.log4j"));
|
||||
assert_eq!(p.qualifier("type"), Some("test-jar"));
|
||||
assert_eq!(p.qualifier("classifier"), Some("tests"));
|
||||
|
||||
let p = Purl::parse("pkg:golang/github.com/gin-gonic/gin@v1.9.1").unwrap();
|
||||
assert_eq!(p.namespace.as_deref(), Some("github.com/gin-gonic"));
|
||||
assert_eq!(p.name, "gin");
|
||||
|
||||
let p = Purl::parse("pkg:nuget/Newtonsoft.Json").unwrap();
|
||||
assert_eq!((p.namespace, p.version), (None, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_is_not_a_purl_is_refused() {
|
||||
assert_eq!(Purl::parse("npm:lodash@4.17.20"), None);
|
||||
assert_eq!(Purl::parse("pkg:npm"), None);
|
||||
assert_eq!(Purl::parse("pkg:/lodash"), None);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
//! SBOM documents in the two exchange formats: CycloneDX 1.5 and SPDX 2.3.
|
||||
//! SBOM documents in the two exchange formats: CycloneDX 1.6 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. The CycloneDX parts are shared with the VEX
|
||||
//! documents (see [`crate::vex_docs`]), which refer to the same `bom-ref`s.
|
||||
//!
|
||||
//! The CycloneDX document follows BSI TR-03183-2 v2.1 (#508) as far as
|
||||
//! Prüfwerk knows the data: the `bsi:component:*` properties of the registry
|
||||
//! packages, a dependency graph whose completeness is stated, and licences as
|
||||
//! the suppliers declare them.
|
||||
|
||||
use crate::models::SbomEntry;
|
||||
use crate::purl::Purl;
|
||||
|
||||
/// The `bom-ref` of a component, which a VEX statement refers to: its purl,
|
||||
/// or `<package manager>:<name>@<version>` without one.
|
||||
@@ -49,21 +55,62 @@ fn spdx_ids() -> &'static std::collections::HashSet<String> {
|
||||
}
|
||||
|
||||
/// A license as CycloneDX writes it: an SPDX id it knows, an SPDX expression
|
||||
/// (`MIT OR Apache-2.0`), or a named license.
|
||||
/// (`MIT OR Apache-2.0`), or a named license. It is the license the supplier
|
||||
/// declares (registry or lockfile metadata): Prüfwerk has not concluded it.
|
||||
fn license_choice(license: &str) -> serde_json::Value {
|
||||
let license = license.trim();
|
||||
if spdx_ids().contains(license) {
|
||||
serde_json::json!([{ "license": { "id": license } }])
|
||||
serde_json::json!([{ "license": { "id": license, "acknowledgement": "declared" } }])
|
||||
} else if [" OR ", " AND ", " WITH "]
|
||||
.iter()
|
||||
.any(|op| license.contains(op))
|
||||
{
|
||||
serde_json::json!([{ "expression": license }])
|
||||
serde_json::json!([{ "expression": license, "acknowledgement": "declared" }])
|
||||
} else {
|
||||
serde_json::json!([{ "license": { "name": license } }])
|
||||
serde_json::json!([{ "license": { "name": license, "acknowledgement": "declared" } }])
|
||||
}
|
||||
}
|
||||
|
||||
/// The file a registry package is distributed as (`log4j-core-2.14.1.jar`),
|
||||
/// where its purl determines it. `None` for a package type whose file the
|
||||
/// purl does not name (PyPI wheel or sdist, Go modules) and without a version.
|
||||
fn package_filename(purl: &Purl) -> Option<String> {
|
||||
let version = purl.version.as_deref()?;
|
||||
let name = &purl.name;
|
||||
Some(match purl.ty.as_str() {
|
||||
// The registry tarball is named after the unscoped name.
|
||||
"npm" => format!("{name}-{version}.tgz"),
|
||||
"maven" => {
|
||||
let extension = purl.qualifier("type").unwrap_or("jar");
|
||||
match purl.qualifier("classifier") {
|
||||
Some(classifier) => format!("{name}-{version}-{classifier}.{extension}"),
|
||||
None => format!("{name}-{version}.{extension}"),
|
||||
}
|
||||
}
|
||||
"nuget" => format!("{}.{}.nupkg", name.to_lowercase(), version.to_lowercase()),
|
||||
"cargo" => format!("{name}-{version}.crate"),
|
||||
"gem" => match purl.qualifier("platform") {
|
||||
Some(platform) => format!("{name}-{version}-{platform}.gem"),
|
||||
None => format!("{name}-{version}.gem"),
|
||||
},
|
||||
"hex" => format!("{name}-{version}.tar"),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The `bsi:component:*` properties of a registry package: its file, and that
|
||||
/// it is a package archive. A package archive is described like the TR's rpm
|
||||
/// example (Table 7): not executable itself, an archive, structured.
|
||||
fn bsi_properties(purl: &Purl) -> Option<serde_json::Value> {
|
||||
let filename = package_filename(purl)?;
|
||||
Some(serde_json::json!([
|
||||
{ "name": "bsi:component:filename", "value": filename },
|
||||
{ "name": "bsi:component:executable", "value": "non-executable" },
|
||||
{ "name": "bsi:component:archive", "value": "archive" },
|
||||
{ "name": "bsi:component:structured", "value": "structured" },
|
||||
]))
|
||||
}
|
||||
|
||||
/// 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() {
|
||||
@@ -89,10 +136,19 @@ pub fn cdx_components(entries: &[SbomEntry]) -> Vec<serde_json::Value> {
|
||||
"bom-ref": component_ref(e),
|
||||
"name": e.name,
|
||||
"version": e.version,
|
||||
"group": e.package_manager,
|
||||
});
|
||||
if let Some(purl) = &e.purl {
|
||||
comp["purl"] = serde_json::Value::String(purl.clone());
|
||||
if let Some(parsed) = Purl::parse(purl) {
|
||||
// CycloneDX's group is the namespace (a Maven group id,
|
||||
// an npm scope), not the package manager.
|
||||
if let Some(namespace) = &parsed.namespace {
|
||||
comp["group"] = serde_json::Value::String(namespace.clone());
|
||||
}
|
||||
if let Some(properties) = bsi_properties(&parsed) {
|
||||
comp["properties"] = properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(license) = e.license.as_deref().filter(|l| !l.trim().is_empty()) {
|
||||
comp["licenses"] = license_choice(license);
|
||||
@@ -102,33 +158,79 @@ pub fn cdx_components(entries: &[SbomEntry]) -> Vec<serde_json::Value> {
|
||||
.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!({
|
||||
/// Who creates Prüfwerk's SBOM documents, as BSI TR-03183-2 asks for the
|
||||
/// "creator of the SBOM": its name and email address (`metadata.manufacturer`).
|
||||
const CREATOR_NAME: &str = "BreakPilot GmbH";
|
||||
const CREATOR_EMAIL: &str = "kontakt@breakpilot.com";
|
||||
|
||||
/// The product's version: when its SBOM data was last compiled, as an
|
||||
/// RFC 3339 date-time. A target has no version of its own, and BSI
|
||||
/// TR-03183-2 names the modification date for a component without one.
|
||||
fn product_version(entries: &[SbomEntry]) -> Option<String> {
|
||||
entries
|
||||
.iter()
|
||||
.map(|e| e.updated_at)
|
||||
.max()
|
||||
.map(|at| at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true))
|
||||
}
|
||||
|
||||
/// The frame of a CycloneDX 1.6 document about `subject`, whose components
|
||||
/// are `entries`: a fresh serial number, the creator and the product as
|
||||
/// `metadata.component`.
|
||||
pub fn cdx_frame(subject: &str, entries: &[SbomEntry]) -> serde_json::Value {
|
||||
let mut doc = serde_json::json!({
|
||||
"bomFormat": "CycloneDX",
|
||||
"specVersion": "1.5",
|
||||
"specVersion": "1.6",
|
||||
"serialNumber": format!("urn:uuid:{}", uuid::Uuid::new_v4()),
|
||||
"version": 1,
|
||||
"metadata": {
|
||||
"timestamp": chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
|
||||
"tools": { "components": [{ "type": "application", "name": "Prüfwerk" }] },
|
||||
"manufacturer": {
|
||||
"name": CREATOR_NAME,
|
||||
"contact": [{ "email": CREATOR_EMAIL }],
|
||||
},
|
||||
"component": {
|
||||
"type": "application",
|
||||
"bom-ref": product_ref(subject),
|
||||
"purl": product_ref(subject),
|
||||
"name": subject,
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
if let Some(version) = product_version(entries) {
|
||||
doc["metadata"]["component"]["version"] = serde_json::Value::String(version);
|
||||
}
|
||||
doc
|
||||
}
|
||||
|
||||
/// A CycloneDX 1.5 document for `entries`, named after `subject`. The known
|
||||
/// The dependency graph of a document whose product contains `components`,
|
||||
/// and its completeness. The SBOM is flat: the product depends on every
|
||||
/// component, directly or through another one, and which of them depend on
|
||||
/// which is not known. So every component gets an empty entry, as CycloneDX
|
||||
/// asks for one without dependencies, and the graph is stated `incomplete`.
|
||||
fn cdx_dependencies(doc: &mut serde_json::Value, components: &[serde_json::Value]) {
|
||||
let product = doc["metadata"]["component"]["bom-ref"].clone();
|
||||
let refs: Vec<serde_json::Value> = components.iter().map(|c| c["bom-ref"].clone()).collect();
|
||||
let mut dependencies = Vec::with_capacity(refs.len() + 1);
|
||||
dependencies.push(serde_json::json!({ "ref": product, "dependsOn": refs }));
|
||||
dependencies.extend(refs.iter().map(|r| serde_json::json!({ "ref": r })));
|
||||
doc["dependencies"] = serde_json::Value::Array(dependencies);
|
||||
doc["compositions"] = serde_json::json!([{
|
||||
"aggregate": "incomplete",
|
||||
"dependencies": [product],
|
||||
}]);
|
||||
}
|
||||
|
||||
/// A CycloneDX 1.6 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));
|
||||
let mut doc = cdx_frame(subject, entries);
|
||||
let components = cdx_components(entries);
|
||||
cdx_dependencies(&mut doc, &components);
|
||||
doc["components"] = serde_json::Value::Array(components);
|
||||
// One vulnerability per advisory, affecting every component it was
|
||||
// found in.
|
||||
let mut vulns: Vec<(String, String, Option<String>, Vec<String>)> = Vec::new();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! 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).
|
||||
//! 1.6 (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:
|
||||
@@ -147,10 +147,10 @@ fn cdx_justification(justification: VexJustification) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// A CycloneDX 1.5 VEX: the SBOM's components, and every alert as a
|
||||
/// A CycloneDX 1.6 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 doc = cdx_frame(input.subject, input.sbom);
|
||||
let mut components = cdx_components(input.sbom);
|
||||
let mut refs: std::collections::HashSet<String> = components
|
||||
.iter()
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
//! The CycloneDX SBOM scored by sbomqs against BSI TR-03183-2 v2.1 (#508).
|
||||
//! Needs the sbomqs binary (`SBOMQS`, else `sbomqs` on PATH), so it is
|
||||
//! ignored by default: `cargo test -p compliance-core --test sbom_bsi --
|
||||
//! --ignored --nocapture`. Prints every check and asserts the ones the
|
||||
//! document's shape meets; the rest need data the SBOM does not have (#508
|
||||
//! lists them).
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
use compliance_core::models::SbomEntry;
|
||||
use compliance_core::sbom_docs;
|
||||
|
||||
/// One registry package per ecosystem whose file its purl names.
|
||||
fn entries() -> Vec<SbomEntry> {
|
||||
[
|
||||
(
|
||||
"log4j-core",
|
||||
"2.17.1",
|
||||
"maven",
|
||||
"pkg:maven/org.apache.logging.log4j/log4j-core@2.17.1",
|
||||
"Apache-2.0",
|
||||
),
|
||||
(
|
||||
"core",
|
||||
"16.2.0",
|
||||
"npm",
|
||||
"pkg:npm/%40angular/core@16.2.0",
|
||||
"MIT",
|
||||
),
|
||||
(
|
||||
"Newtonsoft.Json",
|
||||
"13.0.3",
|
||||
"nuget",
|
||||
"pkg:nuget/Newtonsoft.Json@13.0.3",
|
||||
"MIT",
|
||||
),
|
||||
(
|
||||
"serde",
|
||||
"1.0.200",
|
||||
"cargo",
|
||||
"pkg:cargo/serde@1.0.200",
|
||||
"MIT OR Apache-2.0",
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(name, version, manager, purl, license)| {
|
||||
let mut e = SbomEntry::new("t".into(), name.into(), version.into(), manager.into());
|
||||
e.purl = Some(purl.into());
|
||||
e.license = Some(license.into());
|
||||
e
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "needs the sbomqs binary"]
|
||||
fn the_document_shape_meets_the_bsi_checks_it_can() {
|
||||
let sbomqs = std::env::var("SBOMQS").unwrap_or_else(|_| "sbomqs".into());
|
||||
let dir = std::env::temp_dir().join(format!("sbom-bsi-{}", uuid::Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("sbom.cdx.json");
|
||||
let doc = sbom_docs::cyclonedx(&entries(), "Pump Remote");
|
||||
std::fs::write(&path, serde_json::to_vec_pretty(&doc).unwrap()).unwrap();
|
||||
let output = std::process::Command::new(&sbomqs)
|
||||
.args(["score", "--json", "--profile", "bsi-v2.1"])
|
||||
.arg(&path)
|
||||
.output()
|
||||
.expect("sbomqs runs");
|
||||
std::fs::remove_dir_all(&dir).ok();
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let out: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
let profile = &out["files"][0]["profiles"][0];
|
||||
println!(
|
||||
"{} {} {}",
|
||||
profile["profile"], profile["score"], profile["grade"]
|
||||
);
|
||||
let mut scores = std::collections::HashMap::new();
|
||||
for f in profile["features"].as_array().unwrap() {
|
||||
println!(
|
||||
"{:>5} {:<28} required={:<5} {}",
|
||||
f["score"],
|
||||
f["key"].as_str().unwrap(),
|
||||
f["required"],
|
||||
f["description"]
|
||||
);
|
||||
scores.insert(
|
||||
f["key"].as_str().unwrap().to_string(),
|
||||
f["score"].as_f64().unwrap(),
|
||||
);
|
||||
}
|
||||
for key in [
|
||||
"sbom_spec_version",
|
||||
"sbom_creator",
|
||||
"sbom_timestamp",
|
||||
"sbom_uri",
|
||||
"comp_name",
|
||||
"comp_version",
|
||||
"comp_depth",
|
||||
"comp_other_identifiers",
|
||||
] {
|
||||
assert_eq!(scores.get(key).copied(), Some(10.0), "{key}");
|
||||
}
|
||||
// Met by every component but the product. The product is a logical
|
||||
// component in the TR's terms (section 3.2.2): it has no file, so no
|
||||
// filename or file properties, and Prüfwerk does not know its licence.
|
||||
// sbomqs 2.1.2 counts it like the others.
|
||||
for key in [
|
||||
"comp_filename",
|
||||
"comp_executable_prop",
|
||||
"comp_archive_prop",
|
||||
"comp_structured_prop",
|
||||
"comp_original_licenses",
|
||||
] {
|
||||
assert_eq!(scores.get(key).copied(), Some(8.0), "{key}");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! The SBOM and VEX documents Prüfwerk writes against the official schemas
|
||||
//! vendored in `schemas/` (#498): CycloneDX 1.5 and OpenVEX 0.2.0.
|
||||
//! vendored in `schemas/` (#498, #508): CycloneDX 1.6 and OpenVEX 0.2.0.
|
||||
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
|
||||
@@ -17,7 +17,7 @@ fn schema(name: &str) -> serde_json::Value {
|
||||
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
|
||||
/// The errors of `doc` against CycloneDX 1.6 (with the SPDX and JSF schemas
|
||||
/// it refers to).
|
||||
fn cyclonedx_errors(doc: &serde_json::Value) -> Vec<String> {
|
||||
let validator = jsonschema::options()
|
||||
@@ -29,7 +29,7 @@ fn cyclonedx_errors(doc: &serde_json::Value) -> Vec<String> {
|
||||
"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"))
|
||||
.build(&schema("bom-1.6.schema.json"))
|
||||
.unwrap();
|
||||
validator
|
||||
.iter_errors(doc)
|
||||
@@ -124,6 +124,17 @@ fn alerts() -> Vec<CveAlert> {
|
||||
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["specVersion"], "1.6");
|
||||
assert_eq!(doc["metadata"]["manufacturer"]["name"], "BreakPilot GmbH");
|
||||
assert_eq!(
|
||||
doc["metadata"]["manufacturer"]["contact"][0]["email"],
|
||||
"kontakt@breakpilot.com"
|
||||
);
|
||||
// The product's version is when its SBOM data was compiled.
|
||||
assert!(doc["metadata"]["component"]["version"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.ends_with('Z'));
|
||||
assert_eq!(
|
||||
doc["metadata"]["component"]["bom-ref"],
|
||||
"pkg:generic/Pump%20Remote"
|
||||
@@ -140,6 +151,42 @@ fn the_cyclonedx_sbom_is_valid_and_its_vulnerabilities_point_at_components() {
|
||||
doc["components"][2]["licenses"][0]["license"]["name"],
|
||||
"Custom Pump License"
|
||||
);
|
||||
// BSI TR-03183-2: registry packages name their file and describe it;
|
||||
// a component without a purl gets none of the properties.
|
||||
let property = |i: usize, name: &str| {
|
||||
doc["components"][i]["properties"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.find(|p| p["name"] == name)
|
||||
.map(|p| p["value"].as_str().unwrap().to_string())
|
||||
};
|
||||
assert_eq!(
|
||||
property(0, "bsi:component:filename").as_deref(),
|
||||
Some("log4j-core-2.14.1.jar")
|
||||
);
|
||||
assert_eq!(
|
||||
property(1, "bsi:component:filename").as_deref(),
|
||||
Some("lodash-4.17.20.tgz")
|
||||
);
|
||||
assert_eq!(
|
||||
property(1, "bsi:component:executable").as_deref(),
|
||||
Some("non-executable")
|
||||
);
|
||||
assert_eq!(property(2, "bsi:component:filename"), None);
|
||||
assert_eq!(doc["components"][0]["group"], "org.apache.logging.log4j");
|
||||
assert!(doc["components"][2].get("group").is_none());
|
||||
assert_eq!(
|
||||
doc["components"][0]["licenses"][0]["license"]["acknowledgement"],
|
||||
"declared"
|
||||
);
|
||||
// The product depends on every component; each has its own entry, and
|
||||
// the graph says it is incomplete (the SBOM is flat).
|
||||
let dependencies = doc["dependencies"].as_array().unwrap();
|
||||
assert_eq!(dependencies.len(), 4);
|
||||
assert_eq!(dependencies[0]["ref"], "pkg:generic/Pump%20Remote");
|
||||
assert_eq!(dependencies[0]["dependsOn"].as_array().unwrap().len(), 3);
|
||||
assert_eq!(doc["compositions"][0]["aggregate"], "incomplete");
|
||||
// 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();
|
||||
|
||||
@@ -218,7 +218,7 @@ pub fn SbomPage() -> Element {
|
||||
class: "sbom-filter-select",
|
||||
value: "{export_format}",
|
||||
onchange: move |e| export_format.set(e.value()),
|
||||
option { value: "cyclonedx", "CycloneDX 1.5" }
|
||||
option { value: "cyclonedx", "CycloneDX 1.6" }
|
||||
option { value: "spdx", "SPDX 2.3" }
|
||||
}
|
||||
button {
|
||||
|
||||
@@ -135,7 +135,7 @@ impl ComplianceMcpServer {
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "Get a target's whole SBOM as one CycloneDX 1.5 (default) or SPDX 2.3 document"
|
||||
description = "Get a target's whole SBOM as one CycloneDX 1.6 (default) or SPDX 2.3 document"
|
||||
)]
|
||||
async fn get_sbom(
|
||||
&self,
|
||||
|
||||
@@ -192,7 +192,7 @@ pub async fn sbom_vuln_report(
|
||||
#[derive(Debug, Clone, Copy, Default, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum SbomFormat {
|
||||
/// CycloneDX 1.5 (the default).
|
||||
/// CycloneDX 1.6 (the default).
|
||||
#[default]
|
||||
Cyclonedx,
|
||||
/// SPDX 2.3.
|
||||
|
||||
@@ -87,7 +87,7 @@ manifest of sha256 checksums) is also served as one ZIP at
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `get_sbom` | A target's whole SBOM as one CycloneDX 1.5 (default) or SPDX 2.3 document, the same the API exports. |
|
||||
| `get_sbom` | A target's whole SBOM as one CycloneDX 1.6 (default) or SPDX 2.3 document, the same the API exports. |
|
||||
| `list_sbom_packages` | List SBOM packages with filters for repository, vulnerabilities, package manager, and license. |
|
||||
| `sbom_vuln_report` | Generate a vulnerability report for a repository showing all packages with known CVEs. |
|
||||
|
||||
|
||||
+45
-12
@@ -189,18 +189,39 @@ Copyleft-licensed dependencies can require you to release your source code under
|
||||
works for one target at a time; without a selection the export says
|
||||
**Zuerst ein Prüfobjekt wählen**.
|
||||
2. Click **Exportieren** and choose a format:
|
||||
- **CycloneDX 1.5** -- JSON, widely supported by security tools
|
||||
- **CycloneDX 1.6** -- JSON, widely supported by security tools
|
||||
- **SPDX 2.3** -- the Linux Foundation standard, common for license compliance
|
||||
3. Click **Herunterladen**. The SBOM downloads as a JSON file.
|
||||
|
||||
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.
|
||||
The CycloneDX document follows the CycloneDX 1.6 schema and, as far as
|
||||
Prüfwerk has the data, BSI TR-03183-2 v2.1:
|
||||
|
||||
- Every component has a `bom-ref` (its purl, or
|
||||
`<package manager>:<name>@<version>`) and, from its purl, its `group` (a
|
||||
Maven group id, an npm scope).
|
||||
- The product itself is `metadata.component`, named after the target, with
|
||||
the `bom-ref` and purl `pkg:generic/<target name>` and as version the time
|
||||
its SBOM data was last compiled (the TR's rule for a component without a
|
||||
version).
|
||||
- The SBOM's creator is BreakPilot GmbH (`metadata.manufacturer`, contact
|
||||
`kontakt@breakpilot.com`), which generates the document.
|
||||
- Registry packages carry the TR's properties: `bsi:component:filename` (the
|
||||
file the package is distributed as, e.g. `log4j-core-2.17.1.jar`,
|
||||
`lodash-4.17.21.tgz`, `newtonsoft.json.13.0.3.nupkg`) and, as for the TR's
|
||||
rpm example, `bsi:component:executable` `non-executable`,
|
||||
`bsi:component:archive` `archive`, `bsi:component:structured`
|
||||
`structured`. Packages whose file the purl does not name (PyPI, Go
|
||||
modules) and components without a purl get none.
|
||||
- The dependency graph has the product depending on every component, and
|
||||
each component as its own entry. The SBOM is flat (which component depends
|
||||
on which is not known), so `compositions` states it `incomplete`.
|
||||
- Licenses are an SPDX id, an SPDX expression or a named license, marked
|
||||
`acknowledgement: declared`: they are what the package declares, not a
|
||||
licence Prüfwerk concluded.
|
||||
- The known vulnerabilities are listed at the top level, each naming the
|
||||
components it affects.
|
||||
|
||||
## VEX: the status of each vulnerability
|
||||
|
||||
@@ -230,7 +251,7 @@ 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
|
||||
**CycloneDX 1.6 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:
|
||||
@@ -269,10 +290,22 @@ evidence for the CRA requirement **cra-ai-23** (SBOM): it is shown there on
|
||||
the target's CRA page and is in the evidence pack as `sbom-quality.json`, but
|
||||
it raises no findings and does not change the requirement's state.
|
||||
|
||||
The score rates the document, not the software. Today's export is CycloneDX
|
||||
1.5 without suppliers, hashes or the TR's component properties, so BSI
|
||||
TR-03183-2, which asks for CycloneDX 1.6 and those fields, grades it low; the
|
||||
failed checks list what the export would need.
|
||||
The score rates the document, not the software. Against BSI TR-03183-2 the
|
||||
export meets the format, creator, timestamp, name, version, dependency and
|
||||
identifier checks, and the file properties for registry packages. Still
|
||||
open, and why:
|
||||
|
||||
- **Component creator**: the email or URL of each package's maintainer.
|
||||
Prüfwerk does not record it yet.
|
||||
- **Hash of the deployable component** (SHA-512) and its download URL: not
|
||||
recorded yet; lockfiles hold them for npm and NuGet. Cargo, Python and
|
||||
Maven lockfiles only have SHA-256 hashes, which the TR does not accept.
|
||||
- **Distribution licence**: the licence the product is distributed under
|
||||
(`acknowledgement: concluded`) is the manufacturer's decision; the export
|
||||
states the declared licences only.
|
||||
- **File properties of the product and of packages without a known file**:
|
||||
the product is a logical component in the TR's terms, which needs no file
|
||||
properties; sbomqs counts it like a file.
|
||||
|
||||
## Compare Tab
|
||||
|
||||
|
||||
@@ -51,6 +51,6 @@ the vulnerability comes back, the scan withdraws its "Fixed".
|
||||
## Downloading
|
||||
|
||||
**Download OpenVEX** and **Download CycloneDX VEX** save the target's
|
||||
statements as OpenVEX 0.2.0 and CycloneDX 1.5. Both files are also in the
|
||||
statements as OpenVEX 0.2.0 and CycloneDX 1.6. Both files are also in the
|
||||
evidence pack (`vex.openvex.json`, `vex.cdx.json`). Formats, how the terms map
|
||||
and the API: see [SBOM](./sbom.md#vex-the-status-of-each-vulnerability).
|
||||
+1
-1
@@ -53,7 +53,7 @@ wieder auf, nimmt die Prüfung ihr „Behoben“ zurück.
|
||||
## Herunterladen
|
||||
|
||||
**OpenVEX herunterladen** und **CycloneDX VEX herunterladen** speichern die
|
||||
Aussagen des Prüfobjekts als OpenVEX 0.2.0 bzw. CycloneDX 1.5. Beide Dateien
|
||||
Aussagen des Prüfobjekts als OpenVEX 0.2.0 bzw. CycloneDX 1.6. Beide Dateien
|
||||
liegen auch im Nachweispaket (`vex.openvex.json`, `vex.cdx.json`). Formate,
|
||||
Zuordnung der Begriffe und API: siehe
|
||||
[Stückliste (SBOM)](./sbom.md#vex-the-status-of-each-vulnerability).
|
||||
@@ -26,6 +26,7 @@ together on stage in one pass before the next prod promotion.
|
||||
| #496 | SBOM quality score (sbomqs) |
|
||||
| #494 | DevSkim: .NET SAST without a build (C#, VB.NET, .config) |
|
||||
| #498 (2/4) | VEX editor and downloads on the target page |
|
||||
| #508 (A) | CycloneDX 1.6 SBOM with BSI TR-03183-2 properties |
|
||||
|
||||
**Customer-visible on the next prod rescan** is marked **[visible]**: these
|
||||
change what a customer sees on their existing targets, without them doing
|
||||
@@ -546,6 +547,37 @@ Use the target of check 22 (one with CVE alerts), as IT-admin and as member.
|
||||
- **[visible]** a new card on every target page; the SBOM page's export still
|
||||
downloads as before (its download helper moved).
|
||||
|
||||
### 27. #508 part A: CycloneDX 1.6 and BSI TR-03183-2
|
||||
|
||||
Use a target with npm and Maven dependencies (e.g. the log4j/gson target of
|
||||
check 19) and one with a Python project.
|
||||
|
||||
- **Do:** rescan; open **SBOM**, select the target, open **SBOM-Qualität**.
|
||||
**Expect:** BSI TR-03183-2 v2.1 scores clearly higher than before (below 1,
|
||||
F). The test document scores 6.7 (D); a real target lands lower where
|
||||
components lack a pinned version, a purl or a known file. Failed checks
|
||||
left: the component creator, the deployable hash, the distribution
|
||||
licence, and the file properties for the product and packages without a
|
||||
known file.
|
||||
- **Do:** export **CycloneDX 1.6**; download the evidence pack.
|
||||
**Expect:**
|
||||
- `specVersion` `1.6`; it validates (CycloneDX's online validator, or
|
||||
`sbomqs score --profile bsi-v2.1`);
|
||||
- `metadata.manufacturer` is BreakPilot GmbH with `kontakt@breakpilot.com`;
|
||||
- `metadata.component` is the target by its name (no longer
|
||||
`repo-<id>`), with a purl and as version a timestamp;
|
||||
- log4j-core has `group` `org.apache.logging.log4j` and the properties
|
||||
`bsi:component:filename` `log4j-core-2.14.1.jar`, `executable`
|
||||
`non-executable`, `archive` `archive`, `structured` `structured`;
|
||||
Python packages have none of them;
|
||||
- licences carry `acknowledgement: declared`;
|
||||
- `dependencies` lists the product depending on every component, each
|
||||
component on its own; `compositions` says `incomplete`.
|
||||
The evidence pack's `sbom.cdx.json` and `vex.cdx.json` are 1.6 too.
|
||||
- **Do:** MCP `get_sbom` for the target. **Expect:** the same 1.6 document.
|
||||
- **[visible]** SBOM downloads and evidence packs are CycloneDX 1.6 with the
|
||||
new fields, and the SBOM quality score rises on the next rescan.
|
||||
|
||||
## After the pass
|
||||
|
||||
- The nightly job on `main` is green with the new mobile targets.
|
||||
|
||||
Reference in new issue
Block a user