feat(trust): signed SLSA attestations and OSV advisory audit (G5)
VoidBuildSystem CI / 1 · Requirements (push) Successful in 8s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m55s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m37s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 4m7s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m57s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m38s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 26s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 27s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 8m38s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 29s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m36s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 5m13s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 5m4s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped

- vbs attest create renders an in-toto Statement v1 / SLSA provenance v1
  predicate (subjects with sha256 digests, build definition with
  project/profile/targets/lock revision, internal parameters, run details)
  and wraps it in a DSSE envelope signed with the existing Ed25519
  primitives over the PAE; creation fails closed without a signing backend.
- vbs attest verify requires a trusted key, verifies the DSSE PAE
  signature, checks the statement type and requires every supplied
  artifact digest to be covered; wrong artifacts, tampered payloads and
  untrusted keys are rejected.
- vbs audit matches OSV advisories (array or "vulnerabilities" object;
  introduced/fixed/last_affected/limit ranges and exact versions) against
  every package entry in vbs.lock, with --severity-threshold and --json;
  findings fail the command.
- vbs doctor reports Ed25519 signing availability.

Implemented with VoidLibrary: Void::Text::Base64 (DSSE payload),
Void::Json::Strict (statement/envelope/audit output), Void::Semver
(version ranges), Void::Str, plus the existing Signing primitives.

Verified: attest_create_and_verify_detects_tampering and
audit_matches_osv_advisories_against_lock pass; CLI contracts pass;
clang-format clean.
This commit is contained in:
faumaray committed 2026-12-06 19:52:54 +03:00
1 parent ff3bfd03a1
commit 8b21583eeb
11 files changed
+1185 -5

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <Void/Build/Package/Lockfile.hpp>
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <string>
#include <string_view>
#include <vector>
namespace Void::Build::Package {
struct AuditFinding {
std::string package;
std::string version;
std::string advisory_id;
std::string severity; // "critical", "high", "medium", "low", "unknown"
std::string summary;
};
// Matches OSV-format advisories (a JSON array, or an object with a "vulnerabilities" array)
// against every package entry in the lockfile. Versions that are not strict SemVer (git
// revisions, empty path-dependency versions) are skipped.
[[nodiscard]] Void::Result::Result<std::vector<AuditFinding>, Void::Result::Error>
match_advisories(const LockfileDocument &lock, std::string_view osv_json);
// Severity ordering used by `vbs audit --severity-threshold`.
[[nodiscard]] int severity_rank(std::string_view severity) noexcept;
[[nodiscard]] bool severity_at_least(std::string_view severity, std::string_view threshold) noexcept;
[[nodiscard]] bool valid_severity_threshold(std::string_view threshold) noexcept;
} // namespace Void::Build::Package
@@ -0,0 +1,65 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <cstdint>
#include <filesystem>
#include <string>
#include <string_view>
#include <vector>
namespace Void::Build::Provenance {
// One subject of an in-toto statement (an artifact and its SHA-256 digest).
struct AttestationSubject {
std::string name;
std::string sha256;
};
// Build facts embedded in the SLSA provenance predicate.
struct AttestationBuild {
std::string project_root;
std::string profile;
std::string compiler;
std::vector<std::string> targets;
std::string lock_revision; // vbs.lock revision hash, empty when absent
std::string vbs_version;
std::string host_os;
std::string host_architecture;
std::int64_t created_epoch{0};
};
struct SignedAttestation {
std::string statement; // canonical in-toto statement JSON
std::string public_key; // Ed25519 public key (hex)
std::string signature; // Ed25519 signature over the DSSE PAE (hex)
std::string envelope; // DSSE envelope JSON
};
struct VerifiedAttestation {
std::string statement;
std::string public_key;
std::vector<AttestationSubject> subjects;
};
// Renders the canonical in-toto Statement v1 / SLSA provenance v1 JSON.
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
render_statement(const AttestationBuild &build, const std::vector<AttestationSubject> &subjects);
// Signs a statement in a DSSE envelope. Fails closed when no Ed25519 backend is available.
[[nodiscard]] Void::Result::Result<SignedAttestation, Void::Result::Error>
sign_statement(std::string_view statement, const std::filesystem::path &seed_path);
// Verifies a DSSE envelope against trusted Ed25519 keys and, when `expected_subjects` is
// non-empty, requires every expected artifact digest to appear in the statement.
// Unsigned, untrusted, malformed or mismatched attestations fail explicitly.
[[nodiscard]] Void::Result::Result<VerifiedAttestation, Void::Result::Error>
verify_envelope(std::string_view envelope_json,
const std::vector<AttestationSubject> &expected_subjects,
const std::vector<std::string> &trusted_public_keys);
// DSSE pre-authentication encoding (exposed for tests).
[[nodiscard]] std::string dsse_pae(std::string_view payload_type, std::string_view payload);
} // namespace Void::Build::Provenance