feat(provenance): distribute trusted Ed25519 keys via files, vbs.keys, and environment
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 5s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 1m19s

This commit is contained in:
faumaray committed 2026-12-03 19:42:10 +03:00
1 parent f5c0c9f09d
commit ff59f6ff5c
13 files changed
+314 -7

No files matched your search

+42 -4
View File
@@ -17,6 +17,7 @@
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/Sbom.hpp>
#include <Void/Build/Provenance/TrustedKeys.hpp>
#include <Void/Build/Provenance/Verification.hpp>
#include <Void/Build/Provider/Provider.hpp>
#include <Void/Build/Provider/Translator.hpp>
@@ -282,6 +283,33 @@ Void::Result::Result<ResolvedDepMaterialization, Void::Result::Error> resolve_an
return Package::resolve_and_materialize_dependencies(ctx, merged_deps, options);
}
Void::Result::Result<std::vector<std::string>, Void::Result::Error>
combine_trusted_keys(const std::vector<std::string> &inline_keys,
const std::vector<std::string> &key_files,
const std::filesystem::path &project_root) {
std::vector<std::filesystem::path> files;
files.reserve(key_files.size());
for (const auto &file : key_files) {
files.emplace_back(file);
}
const std::string environment = Void::Configuration::get_env_or("VBS_TRUSTED_PUBLIC_KEYS", "");
std::optional<std::string_view> environment_value;
if (!environment.empty()) {
environment_value = environment;
}
auto loaded = Provenance::load_trusted_keys(files, project_root, environment_value);
if (!loaded) {
return std::unexpected{loaded.error()};
}
std::vector<std::string> combined = inline_keys;
for (auto &key : *loaded) {
if (std::ranges::find(combined, key) == combined.end()) {
combined.push_back(std::move(key));
}
}
return combined;
}
struct BuildCmdOptions {
std::string project_arg;
std::optional<std::string> build_arg;
@@ -300,6 +328,7 @@ struct BuildCmdOptions {
std::optional<std::filesystem::path> lock_root;
std::optional<std::filesystem::path> state_dir;
std::vector<std::string> trusted_public_keys;
std::vector<std::string> trusted_key_files;
bool publish_editor_selection{true};
bool no_cache{false};
bool locked{false};
@@ -333,6 +362,12 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
const std::filesystem::path project_root{opts.project_arg};
const std::filesystem::path build_root =
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
auto trusted_keys =
combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, project_root);
if (!trusted_keys) {
std::cerr << cmd_name << ": " << trusted_keys.error().message() << '\n';
return 1;
}
std::vector<std::filesystem::path> extra_build_sources;
for (const auto &s : opts.extra_build_sources) {
extra_build_sources.emplace_back(s);
@@ -492,9 +527,9 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
return 1;
}
auto resolved = resolve_and_materialize_deps(ctx, *merged_deps, project_root,
build_root, *pinned_lock, opts.offline,
false, opts.trusted_public_keys);
auto resolved =
resolve_and_materialize_deps(ctx, *merged_deps, project_root, build_root,
*pinned_lock, opts.offline, false, *trusted_keys);
if (!resolved) {
std::cerr << "vbs: " << resolved.error().message() << '\n';
return 1;
@@ -2151,7 +2186,10 @@ int main(int argc, char **argv) {
build_opts.native_foreign)
.option_many("--trusted-public-key", "",
"Trusted Ed25519 package public key (hex; repeatable)",
build_opts.trusted_public_keys);
build_opts.trusted_public_keys)
.option_many("--trusted-key-file", "",
"File with trusted Ed25519 public keys (repeatable)",
build_opts.trusted_key_files);
add_log_flags(p);
};