diff --git a/README.md b/README.md index 25fc863..e6125fe 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ All CLI help text (`vbs --help`, `vbs --help`, `vbs compdb --help`, `v - `vbs pack [--project DIR] [--output FILE]` - `vbs publish --registry URL --name PKG --version X.Y.Z [--project DIR] [--description TEXT] [--token-env VAR] [--signing-key FILE] [--private]` - `vbs publish-binary --registry URL --name PKG --version X.Y.Z --variant ID --file ARTIFACT [--signing-key FILE] [--token-env VAR]` -- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--token-env VAR]` +- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--trusted-public-key HEX]... [--trusted-key-file FILE]... [--token-env VAR]` - `vbs releases list --registry URL --name PKG [--token-env VAR]` - `vbs bridge --request FILE --output FILE` (backend for [cmake/bridge/VbsDeps.cmake](cmake/bridge/VbsDeps.cmake)) - `vbs gc [--build-dir DIR] [--max-bytes N]` diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 475914e..d881893 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -179,7 +179,7 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - Tests: `Daemon.actions_lists_lowered_actions` and extended registry binary-variant assertions; Daemon suite is now 26 cases. - Note: a swarm retried for the daemon half stalled on its planning step again and was stopped; the work was then implemented directly. -- **Wave 61 (Registry Package Ownership API)**:\n - Added `GET/PUT/DELETE /api/v1/packages//owners[/]`: listing honors read permissions, mutations require authentication, CSRF for browser sessions, and ownership/publish authority; unknown users return 404 and removing the last owner returns 409. Owner changes are audited (`package.owner_add`/`package.owner_remove`) and persisted.\n - Extended the registry RBAC test with a dedicated package: list, add, unknown user, reader-with-ownership still denied (403), remove, and last-owner rejection.\n\n- **Wave 62 (`vbs releases list`)**:\n - Added `vbs releases list --registry URL --name PKG [--token-env VAR]` over `Package::fetch_package_releases`, printing `version sha256 active|yanked binaries=N` per release.\n - Covered by CLI contracts (help + required-argument error) and the live registry E2E (both published versions listed as active).\n\n- **Wave 63 (Daemon Install Request)**:\n - Added the `install` daemon request (`vbs daemon install --prefix DIR [--package-version]`): builds the member graph, stages a relocatable install via `Install::install_project`, and returns `prefix`, `manifest`, and file count. Request fields cover `package_name` (defaults to the project/member directory name), `package_version`, `component`, and `export_cmake`/`export_native` booleans. `prefix` is required and bounded.\n - Added `Daemon.install_stages_prefix_and_writes_manifest` (installed binary + manifest present, missing prefix rejected) and a CLI help contract; Daemon suite is now 27 cases.\n\n- **Wave 64 (Daemon Uninstall Request)**:\n - Added the `uninstall` daemon request (`vbs daemon uninstall --prefix DIR`): removes only VBS-owned files recorded in the install manifest via `Install::uninstall_prefix` and returns `prefix` + removed count. `prefix` is required and bounded.\n - Extended `Daemon.install_stages_prefix_and_writes_manifest` to uninstall after asserting the install artifacts and check the binary is gone; added a CLI help contract.\n\n- **Wave 65 (Daemon Gen-Tests Request)**:\n - Added the `gen_tests` daemon request (`vbs daemon gen-tests --input --output-dir`): generates the native `Void::Testing` registration unit and returns the generated path and case count. The input must resolve inside the project root and the output directory inside the build root (relative paths resolve against those roots).\n - Added `Daemon.gen_tests_generates_registration_unit_confined` (two cases generated inside the build root; escaping input/output rejected) and a CLI help contract; Daemon suite is now 28 cases.\n\n## Remaining future scope"}"}"}"}"}"}"}"}"}"}, {"oldString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope).", "newString": "Track E4 (`Void::Net` now backs both the registry client transport and the registry HTTP server when enabled, and `Void::Sqlite` backs the StateStore; the POSIX fallbacks remain for minimal toolchains)."}]"}, {"oldString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope.", "newString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope)."}, {"oldString": "Live `conan` CLI verification (Track B3), Track C", "newString": "Track C"}"}, {"oldString": "Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.", "newString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope."} +- **Wave 61 (Registry Package Ownership API)**:\n - Added `GET/PUT/DELETE /api/v1/packages//owners[/]`: listing honors read permissions, mutations require authentication, CSRF for browser sessions, and ownership/publish authority; unknown users return 404 and removing the last owner returns 409. Owner changes are audited (`package.owner_add`/`package.owner_remove`) and persisted.\n - Extended the registry RBAC test with a dedicated package: list, add, unknown user, reader-with-ownership still denied (403), remove, and last-owner rejection.\n\n- **Wave 62 (`vbs releases list`)**:\n - Added `vbs releases list --registry URL --name PKG [--token-env VAR]` over `Package::fetch_package_releases`, printing `version sha256 active|yanked binaries=N` per release.\n - Covered by CLI contracts (help + required-argument error) and the live registry E2E (both published versions listed as active).\n\n- **Wave 63 (Daemon Install Request)**:\n - Added the `install` daemon request (`vbs daemon install --prefix DIR [--package-version]`): builds the member graph, stages a relocatable install via `Install::install_project`, and returns `prefix`, `manifest`, and file count. Request fields cover `package_name` (defaults to the project/member directory name), `package_version`, `component`, and `export_cmake`/`export_native` booleans. `prefix` is required and bounded.\n - Added `Daemon.install_stages_prefix_and_writes_manifest` (installed binary + manifest present, missing prefix rejected) and a CLI help contract; Daemon suite is now 27 cases.\n\n- **Wave 64 (Daemon Uninstall Request)**:\n - Added the `uninstall` daemon request (`vbs daemon uninstall --prefix DIR`): removes only VBS-owned files recorded in the install manifest via `Install::uninstall_prefix` and returns `prefix` + removed count. `prefix` is required and bounded.\n - Extended `Daemon.install_stages_prefix_and_writes_manifest` to uninstall after asserting the install artifacts and check the binary is gone; added a CLI help contract.\n\n- **Wave 65 (Daemon Gen-Tests Request)**:\n - Added the `gen_tests` daemon request (`vbs daemon gen-tests --input --output-dir`): generates the native `Void::Testing` registration unit and returns the generated path and case count. The input must resolve inside the project root and the output directory inside the build root (relative paths resolve against those roots).\n - Added `Daemon.gen_tests_generates_registration_unit_confined` (two cases generated inside the build root; escaping input/output rejected) and a CLI help contract; Daemon suite is now 28 cases.\n\n- **Wave 66 (Signed `vbs binaries fetch`)**:\n - `vbs binaries fetch` accepts `--trusted-public-key`/`--trusted-key-file` (plus the `vbs.keys`/`VBS_TRUSTED_PUBLIC_KEYS` sources) and requires a verified variant signature before downloading; without trusted keys it keeps the digest-only behavior.\n - The live registry E2E asserts that an unsigned variant fails when a trusted key is required.\n\n## Remaining future scope"}"}"}"}"}"}"}"}"}"}, {"oldString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope).", "newString": "Track E4 (`Void::Net` now backs both the registry client transport and the registry HTTP server when enabled, and `Void::Sqlite` backs the StateStore; the POSIX fallbacks remain for minimal toolchains)."}]"}, {"oldString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope.", "newString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope)."}, {"oldString": "Live `conan` CLI verification (Track B3), Track C", "newString": "Track C"}"}, {"oldString": "Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.", "newString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope."} - **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing and distribution materialization, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, daemon-backed IDE metadata, compdb export, IDE config generation, editor watch poll and bounded long-poll done; dedicated external editor plugins remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index cc170bc..b00659b 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -70,4 +70,5 @@ Base HEAD: `fe0d1a6` | Wave 63 (Daemon install request) | `install` daemon request + `vbs daemon install --prefix`: build, stage, export, return manifest and file count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 27/27, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | | Wave 64 (Daemon uninstall request) | `uninstall` daemon request + `vbs daemon uninstall --prefix`: manifest-scoped removal with removed count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 27/27, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | | Wave 65 (Daemon gen-tests request) | `gen_tests` daemon request + `vbs daemon gen-tests --input --output-dir`: confined registration-unit generation, returns path and case count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 28/28, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 66 (Signed binaries fetch) | `binaries fetch --trusted-public-key/--trusted-key-file` verifies the variant signature before download; E2E covers unsigned rejection | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, docs | | Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index d8c9504..048f7c0 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1068,6 +1068,19 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - Full CTest: **8 / 8 passed** in 263.40 s. - `clang-format --dry-run --Werror` passes on the changed C++ files. +## Signed `vbs binaries fetch` (GCC 16.2, pin `0002e74`) + +```sh +dev cpp-gcc -c cmake --build build/pinned --parallel 8 +dev cpp-gcc -c build/pinned/bin/vbs_registry_tests --no-color +dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure +``` + +- Build: exit 0. Registry suite: **7 / 7 passed** in 12.87 s; the live E2E fetches an unsigned + variant successfully without trusted keys and fails when `--trusted-public-key` is required. +- Full CTest: **8 / 8 passed** in 269.54 s. +- `clang-format --dry-run --Werror` passes on `src/Main.cpp` and `tests/RegistryTests.cpp`. + ## 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). diff --git a/src/Main.cpp b/src/Main.cpp index 457e0b6..9e583be 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1189,6 +1189,8 @@ struct BinariesCmdOptions { std::optional variant_arg; std::optional output_arg; std::string token_env{"VBS_REGISTRY_TOKEN"}; + std::vector trusted_public_keys; + std::vector trusted_key_files; }; int execute_binaries_command(std::string_view sub, const BinariesCmdOptions &opts) { @@ -1232,6 +1234,31 @@ int execute_binaries_command(std::string_view sub, const BinariesCmdOptions &opt std::cerr << "vbs binaries fetch: variant '" << *opts.variant_arg << "' not found\n"; return 1; } + + // When trusted keys are configured, require a verified signature before downloading. + auto trusted_keys = combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, + std::filesystem::current_path()); + if (!trusted_keys) { + std::cerr << "vbs binaries fetch: " << trusted_keys.error().message() << '\n'; + return 1; + } + if (!trusted_keys->empty()) { + auto decision = Provenance::verify_trusted_binary_signature( + Provenance::BinarySignature{match->variant_id, match->sha256, + match->signature.value_or(std::string{}), + match->public_key.value_or(std::string{})}, + *trusted_keys); + if (!decision) { + std::cerr << "vbs binaries fetch: " << decision.error().message() << '\n'; + return 1; + } + if (*decision != Provenance::TrustDecision::Verified) { + std::cerr << "vbs binaries fetch: variant '" << match->variant_id + << "' is not signed by a trusted key (" + << Provenance::trust_decision_name(*decision) << ")\n"; + return 1; + } + } const std::string url = registry_url + "/api/v1/packages/" + Void::Encoding::Url::encode(*opts.name_arg) + "/" + Void::Encoding::Url::encode(*opts.version_arg) + "/binaries/" + @@ -2607,7 +2634,12 @@ int main(int argc, char **argv) { binaries_cmd.subcommand("fetch", "Download one binary variant artifact"); configure_binaries(binaries_fetch_cmd); binaries_fetch_cmd.option("--variant", "", "Binary variant id", binaries_opts.variant_arg) - .option("--output", "-o", "Destination artifact path", binaries_opts.output_arg); + .option("--output", "-o", "Destination artifact path", binaries_opts.output_arg) + .option_many("--trusted-public-key", "", + "Required trusted Ed25519 signer key (hex; repeatable)", + binaries_opts.trusted_public_keys) + .option_many("--trusted-key-file", "", "File with trusted public keys (repeatable)", + binaries_opts.trusted_key_files); auto &pack_cmd = root.subcommand("pack", "Create a deterministic USTAR source archive (.tar)"); pack_cmd.option_default("--project", "-C", "Project directory", pack_opts.project_arg, cwd) diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 3e4bdd9..e55d2cd 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -1004,6 +1004,27 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include Void::Testing::require(fetched_bytes.has_value()); Void::Testing::expect(*fetched_bytes == "CLI_BINARY_VARIANT_BYTES"); + // An unsigned variant cannot satisfy a trusted-key requirement. + Platform::ProcessRequest trusted_fetch; + trusted_fetch.executable = vbs_bin; + trusted_fetch.arguments = {"binaries", + "fetch", + "--registry", + reg_url, + "--name", + "hello-pkg", + "--version", + "1.1.0", + "--variant", + "cli-variant", + "--output", + (tmp / "trusted_binary.bin").string(), + "--trusted-public-key", + std::string(64, 'a')}; + trusted_fetch.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok; + auto trusted_binary_res = Platform::run_supervised(trusted_fetch); + Void::Testing::expect(trusted_binary_res.has_value() && !trusted_binary_res->succeeded()); + Platform::ProcessRequest releases_list; releases_list.executable = vbs_bin; releases_list.arguments = {"releases", "list", "--registry", reg_url, "--name", "hello-pkg"};