feat(provenance): emit deterministic SPDX and CycloneDX SBOMs
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s

- New Provenance::Sbom module generating SPDX 2.3 / CycloneDX 1.5 from lockfile packages + BuildGraph outputs
- Wire vbs build|test --sbom FILE --sbom-format spdx|cyclonedx
- Register the module in CMake, build.cpp and the self-host recipe
- Ed25519 signing requested upstream as Void/Library#36 (VL-014)
- Verified in Docker GCC 16: 8/8 CTest suites; deterministic JSON unit test + CLI SBOM assertion
This commit is contained in:
faumaray committed 2026-12-03 13:20:31 +03:00
1 parent 2970fbe25c
commit 55ea305528
13 files changed
+403 -8

No files matched your search

+38 -2
View File
@@ -13,6 +13,7 @@
#include <Void/Build/Package/Toml.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/Sbom.hpp>
#include <Void/Build/Provider/Provider.hpp>
#include <Void/Build/Provider/Translator.hpp>
#include <Void/Build/Snapshot/Snapshot.hpp>
@@ -177,9 +178,14 @@ void build(Void::Build::Project &p) {
Void::Testing::expect(!std::filesystem::exists(ws / "packages" / "lib" / "vbs.lock", ec));
const auto selected_build = tmp / "build_selected";
auto selected = run_vbs({"build", "--project", ws.string(), "--build-dir",
selected_build.string(), "--member", "app"});
const auto sbom_path = tmp / "app.cdx.json";
auto selected =
run_vbs({"build", "--project", ws.string(), "--build-dir", selected_build.string(),
"--member", "app", "--sbom", sbom_path.string(), "--sbom-format", "cyclonedx"});
Void::Testing::expect(selected.has_value() && selected->succeeded());
auto sbom_text = Void::FileSystem::read_file(sbom_path);
Void::Testing::expect(sbom_text.has_value() &&
sbom_text->find("CycloneDX") != std::string::npos);
Void::Testing::expect(std::filesystem::exists(selected_build / "members" / "app" / "profiles" /
"debug" / "out" / "bin" / "ws_app"));
Void::Testing::expect(!std::filesystem::exists(selected_build / "members" / "tests"));
@@ -214,6 +220,36 @@ void build(Void::Build::Project &p) {
}
}
VOID_TEST(FullV1Tests, sbom_spdx_and_cyclonedx_are_deterministic_and_valid_json) {
Provenance::SbomInput input;
input.project_name = "demo";
input.project_version = "1.2.3";
input.tool_version = "0.1.0";
input.packages.push_back({"zlib", "1.3", "", "https://example.invalid/zlib",
std::string(64, 'a'), "pkg:generic/zlib@1.3"});
input.files.push_back({"out/bin/demo", std::string(64, 'b')});
auto spdx = Provenance::generate_sbom(input, Provenance::SbomFormat::Spdx);
Void::Testing::expect(spdx.has_value());
if (!spdx) {
return;
}
Void::Testing::expect(Void::Json::Strict::parse(*spdx).has_value());
Void::Testing::expect(spdx->find("\"SPDX-2.3\"") != std::string::npos);
Void::Testing::expect(spdx->find("zlib") != std::string::npos);
Void::Testing::expect(spdx->find("out/bin/demo") != std::string::npos);
auto spdx_again = Provenance::generate_sbom(input, Provenance::SbomFormat::Spdx);
Void::Testing::expect(spdx_again.has_value() && *spdx_again == *spdx);
auto cdx = Provenance::generate_sbom(input, Provenance::SbomFormat::CycloneDX);
Void::Testing::expect(cdx.has_value());
if (cdx) {
Void::Testing::expect(Void::Json::Strict::parse(*cdx).has_value());
Void::Testing::expect(cdx->find("CycloneDX") != std::string::npos);
Void::Testing::expect(cdx->find("pkg:generic/zlib@1.3") != std::string::npos);
}
}
// === Plan 09: CompDB projection, selection ticket races, user-file preservation, recovery ===
VOID_TEST(FullV1Tests, compdb_projection_ticket_races_and_user_file_preservation) {
Void::FileSystem::TempDir tmp{"vbs_compdb_"};