feat(cli,registry): verify signed artifacts offline; attach download filenames
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 8s

This commit is contained in:
faumaray committed 2026-12-04 07:59:38 +03:00
1 parent da7e8233ce
commit af735c28ff
5 files changed
+122

No files matched your search

+11
View File
@@ -1270,6 +1270,17 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
orchestrator); `graph_exports_target_dependencies_as_json_and_dot` passes (2.38 s).
- Full CTest: **8 / 8 passed** in 262.82 s.
## `vbs verify` & Registry Content-Disposition (GCC 16.2, pin `0002e74`)
- `vbs verify --help` exits 0, missing arguments exit 2, and an invalid signature exits 1. In the
current default build the linked `Void::Crypto` reports Ed25519 unavailable, so the command fails
closed with an explicit backend message; the OpenSSL-enabled build performs real verification
(see the Signing/SignatureEnforcement sections).
- Swarm `swarm_mx8i87lc_3eom` (one worker) added sanitized `Content-Disposition: attachment`
headers to release and binary downloads with tests (4/4 substantive tasks; build task stopped and
re-run by the orchestrator). Registry suite: **9 / 9 passed** (11.10 s).
- `vbs_cli_contract` passes (8.53 s).
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+18
View File
@@ -293,6 +293,20 @@ std::string content_type_for_ext(const std::filesystem::path &p) {
return "application/octet-stream";
}
// Builds a quoted attachment disposition for a download response. Route segments are already
// validated, but only [A-Za-z0-9._-] is kept so the header can never contain quotes, CR/LF or
// path separators.
std::string attachment_disposition(std::string_view filename) {
std::string safe;
safe.reserve(filename.size());
for (const char c : filename) {
const bool keep = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-';
safe.push_back(keep ? c : '_');
}
return "attachment; filename=\"" + safe + "\"";
}
} // namespace
RegistryService::RegistryService(RegistryConfig config)
@@ -1379,6 +1393,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
HttpResponse resp;
resp.status = 200;
resp.headers["Content-Type"] = "application/x-tar";
resp.headers["Content-Disposition"] =
attachment_disposition(pkg_name + "-" + segs[4] + ".tar");
resp.headers["X-Content-SHA256"] = rit->second.sha256;
resp.headers["ETag"] = "\"" + rit->second.sha256 + "\"";
resp.body = std::move(*bytes);
@@ -1573,6 +1589,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
HttpResponse resp;
resp.status = 200;
resp.headers["Content-Type"] = "application/octet-stream";
resp.headers["Content-Disposition"] =
attachment_disposition(pkg_name + "-" + segs[4] + "-" + segs[6] + ".bin");
resp.headers["X-Content-SHA256"] = bit->second.sha256;
resp.headers["ETag"] = "\"" + bit->second.sha256 + "\"";
resp.body = std::move(*bytes);
+51
View File
@@ -20,6 +20,7 @@
#include <Void/Build/Platform/Host.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/Sbom.hpp>
#include <Void/Build/Provenance/Signing.hpp>
#include <Void/Build/Provenance/TrustedKeys.hpp>
#include <Void/Build/Provenance/Verification.hpp>
#include <Void/Build/Provider/Provider.hpp>
@@ -1200,6 +1201,42 @@ int execute_tokens_command(std::string_view sub, const TokensCmdOptions &opts) {
return 0;
}
struct VerifyCmdOptions {
std::optional<std::string> name_arg;
std::optional<std::string> version_arg;
std::optional<std::string> file_arg;
std::optional<std::string> signature_arg;
std::optional<std::string> public_key_arg;
};
int execute_verify_command(const VerifyCmdOptions &opts) {
if (!opts.name_arg || !opts.version_arg || !opts.file_arg || !opts.signature_arg ||
!opts.public_key_arg) {
std::cerr << "vbs verify: --name, --version, --file, --signature, and --public-key are "
"required\n";
return 2;
}
auto digest = Util::sha256_file_hex(*opts.file_arg);
if (!digest) {
std::cerr << "vbs verify: " << digest.error().message() << '\n';
return 1;
}
auto verified = Provenance::verify_package(*opts.name_arg, *opts.version_arg, *digest,
*opts.signature_arg, *opts.public_key_arg);
if (!verified) {
std::cerr << "vbs verify: " << verified.error().message() << '\n';
return 1;
}
if (!*verified) {
std::cerr << "vbs verify: signature does not match " << *opts.name_arg << '@'
<< *opts.version_arg << " sha256=" << *digest << '\n';
return 1;
}
std::cout << "verified " << *opts.name_arg << '@' << *opts.version_arg
<< " sha256=" << *digest << '\n';
return 0;
}
struct LockCmdOptions {
std::string project_arg;
};
@@ -2480,6 +2517,7 @@ int main(int argc, char **argv) {
ReleasesCmdOptions releases_opts;
TokensCmdOptions tokens_opts;
LockCmdOptions lock_opts;
VerifyCmdOptions verify_opts;
publish_opts.project_arg = cwd;
BridgeCmdOptions bridge_opts;
GcCmdOptions gc_opts;
@@ -2643,6 +2681,16 @@ int main(int argc, char **argv) {
publish_binary_opts.token_env, "VBS_REGISTRY_TOKEN");
add_log_flags(publish_binary_cmd, false); // `-v` is `--version` on publish-binary.
auto &verify_cmd =
root.subcommand("verify", "Verify a detached Ed25519 signature over a package artifact");
verify_cmd
.option("--name", "-n", "Package name", verify_opts.name_arg)
.option("--version", "-v", "Package version", verify_opts.version_arg)
.option("--file", "-f", "Artifact file whose SHA-256 is signed", verify_opts.file_arg)
.option("--signature", "", "Detached signature hex", verify_opts.signature_arg)
.option("--public-key", "", "Signer public key hex", verify_opts.public_key_arg);
add_log_flags(verify_cmd, false); // `-v` is `--version` on verify.
auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock");
auto &lock_show_cmd = lock_cmd.subcommand("show", "Print lockfile contexts and entries");
lock_show_cmd.option_default("--project", "-C", "Project directory", lock_opts.project_arg,
@@ -3092,6 +3140,9 @@ int main(int argc, char **argv) {
if (cmd == "lock") {
return execute_lock_show_command(lock_opts);
}
if (cmd == "verify") {
return execute_verify_command(verify_opts);
}
if (cmd == "bridge") {
return execute_bridge_command(bridge_opts);
}
+5
View File
@@ -52,6 +52,11 @@ check_process(0 "Usage: vbs binaries list " "" binaries list --help)
check_process(0 "Usage: vbs releases list " "" releases list --help)
check_process(0 "Usage: vbs tokens list " "" tokens list --help)
check_process(0 "Usage: vbs lock show " "" lock show --help)
check_process(0 "Usage: vbs verify " "" verify --help)
check_process(2 "" "--name, --version, --file, --signature, and --public-key are required" verify)
check_process(1 "" "" verify --name demo --version 1.0.0 --file CMakeLists.txt
--signature 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
--public-key 0000000000000000000000000000000000000000000000000000000000000000)
check_process(0 "no vbs.lock in" "" lock show --project "${CMAKE_CURRENT_BINARY_DIR}/no-lock-project")
check_process(2 "" "vbs tokens: --registry is required" tokens list)
check_process(0 "Usage: vbs tokens revoke .*--token-id" "" tokens revoke --help)
+37
View File
@@ -79,6 +79,22 @@ std::optional<bool> extract_json_bool(std::string_view json, const std::string &
return b ? std::optional<bool>{*b} : std::nullopt;
}
void expect_attachment_disposition(const std::map<std::string, std::string, std::less<>> &headers,
std::string_view expected_filename) {
const auto it = headers.find("content-disposition");
Void::Testing::expect(it != headers.end());
if (it == headers.end()) {
return;
}
const std::string &value = it->second;
Void::Testing::expect(value.starts_with("attachment; filename=\""));
Void::Testing::expect(value.find("filename=\"" + std::string{expected_filename} + "\"") !=
std::string::npos);
Void::Testing::expect(value.find('\r') == std::string::npos);
Void::Testing::expect(value.find('\n') == std::string::npos);
Void::Testing::expect(std::ranges::count(value, '"') % 2 == 0);
}
std::filesystem::path locate_vbs_binary() {
std::error_code ec;
if (const auto self_exe = Platform::current_executable_path(); self_exe) {
@@ -631,6 +647,9 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
"/api/v1/packages/secret-pkg/1.0.0/download",
{{"Authorization", "Bearer " + *alice_tok}});
Void::Testing::expect(dl.has_value() && dl->status == 200 && dl->body == *bytes1);
if (dl) {
expect_attachment_disposition(dl->headers, "secret-pkg-1.0.0.tar");
}
(*svc2)->stop_http();
}
}
@@ -1009,6 +1028,7 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
Void::Testing::expect(downloaded.has_value() && downloaded->status == 200);
if (downloaded) {
Void::Testing::expect(downloaded->body == artifact);
expect_attachment_disposition(downloaded->headers, "demo-bin-1.0.0-" + variant_id + ".bin");
}
auto etag_head = send_loopback_http(port, "GET", binary_path + "/download");
Void::Testing::expect(etag_head.has_value() && etag_head->status == 200);
@@ -1032,6 +1052,7 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
Void::Testing::expect(
ranged->headers.at("content-range").find("/" + std::to_string(artifact.size())) !=
std::string::npos);
expect_attachment_disposition(ranged->headers, "demo-bin-1.0.0-" + variant_id + ".bin");
}
auto unsatisfiable =
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=999999-"}});
@@ -1042,6 +1063,22 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
Void::Testing::expect(head_binary->body.empty());
Void::Testing::expect_eq(head_binary->headers.at("content-length"),
std::to_string(artifact.size()));
expect_attachment_disposition(head_binary->headers,
"demo-bin-1.0.0-" + variant_id + ".bin");
}
// A SemVer build tag is not a safe filename byte, so the header sanitizes it instead of
// reflecting it verbatim.
const std::string build_version = "1.0.0+build.5";
auto build_publish = send_loopback_http(
port, "PUT", "/api/v1/packages/demo-bin/" + build_version,
{{"Authorization", "Bearer " + *tok}, {"X-Content-SHA256", *source_sha}}, *source_bytes);
Void::Testing::expect(build_publish.has_value() && build_publish->status == 201);
auto build_download =
send_loopback_http(port, "GET", "/api/v1/packages/demo-bin/" + build_version + "/download");
Void::Testing::expect(build_download.has_value() && build_download->status == 200);
if (build_download) {
expect_attachment_disposition(build_download->headers, "demo-bin-1.0.0_build.5.tar");
}
auto conflict = send_loopback_http(