diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index bc2351c..a64601d 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -271,6 +271,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 89 (`vbs binaries show` & Daemon Install File List)**: added `Package::fetch_binary_detail` and `vbs binaries show --variant` (digest, size, yank, signed state), exercised in the CLI E2E. A swarm worker added a bounded, sorted `installed_files` array (with truncation marker) to the daemon `install` response and its test; the worker then stalled on its remaining verification tasks and was stopped after its edits landed. +- **Wave 90 (`vbs verify --trusted-public-key` & RFC 7232 If-None-Match)**: `vbs verify` accepts trusted key sources and rejects untrusted signer keys before verifying. A swarm worker (6/6 tasks) added ETag/304 support to the binary-variant detail endpoint and hardened `If-None-Match` handling per RFC 7232 (weak `W/` prefixes, comma lists, `*`) for all ETag-validated responses. + ## Remaining future 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))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 4aa2d21..4acb0a1 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -93,4 +93,5 @@ Base HEAD: `fe0d1a6` | Wave 87 (Releases yank + info workspace) | `set_release_yanked`/`vbs releases yank --unyank`; swarm added daemon `info` workspace/lockfile fields | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 9/9, Daemon suite passes, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, `tests/CliContracts.cmake`, docs | | Wave 88 (Track C1 boundaries) | Windows compile-time boundaries for the daemon socket and registry POSIX HTTP; `_putenv_s` branches for workspace env vars | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `registry/service/HttpServer.cpp`, docs | | Wave 89 (Binaries show + install file list) | `fetch_binary_detail`/`vbs binaries show`; swarm added bounded sorted `installed_files` to daemon install | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry and Daemon tests pass, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 90 (Verify trust + RFC 7232) | `vbs verify --trusted-public-key/--trusted-key-file`; swarm added binary-detail ETag and RFC 7232 If-None-Match matching | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; CLI contract and Registry suite pass, full CTest 8/8) | `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/{RegistryTests,CliContracts}.cmake`, 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 a4208ed..9b3b5e3 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1308,6 +1308,17 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color passes (2.60 s). - Full CTest: **8 / 8 passed** in 283.27 s. +## `vbs verify` Trust and RFC 7232 (GCC 16.2, pin `0002e74`) + +- `vbs verify` with `--trusted-public-key` rejects an untrusted signer key before any crypto + (`vbs_cli_contract`, 8.56 s). +- Swarm `swarm_mx8kmg2e_w0k2` (one worker) completed 6/6 tasks: the binary-variant detail response + is ETag-validated and `If-None-Match` now follows RFC 7232 (weak `W/` prefix, comma lists, `*`) + for all ETag-validated responses; the registry test covers 304 semantics and stale validators. +- Daemon install assertions were strengthened (exact installed-file count, no truncation flag, + absolute paths under the prefix) by the prior swarm's queued edits. +- Full CTest on the final tree: **8 / 8 passed** in 267.99 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). diff --git a/docs/roadmap/21-expansion-roadmap.md b/docs/roadmap/21-expansion-roadmap.md index a7223d9..29b7286 100644 --- a/docs/roadmap/21-expansion-roadmap.md +++ b/docs/roadmap/21-expansion-roadmap.md @@ -46,7 +46,7 @@ flowchart LR | Phase | Concrete Scope | Acceptance Gate | | --- | --- | --- | -| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (the daemon socket and registry POSIX server carry explicit Windows compile-time boundaries, `vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, registry downloads answer HEAD with full headers, support single-range requests, and both metadata reads and downloads are ETag-validated). | Zero Linux regressions; clean platform abstraction boundary. | +| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (the daemon socket and registry POSIX server carry explicit Windows compile-time boundaries, `vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, registry downloads answer HEAD with full headers, support single-range requests, both metadata reads and downloads are ETag-validated with RFC 7232 If-None-Match matching, and `vbs verify` can require a trusted signer key). | Zero Linux regressions; clean platform abstraction boundary. | | **C2 — macOS / Apple Clang & `ld64`** | Apple Clang toolchain probes, `.dylib` + `@rpath`/`@loader_path` install-name lowering, `FSEvents` watcher, Mach-O deterministic timestamps. | Real macOS CI runner passing all SDK, core, module, and install tests. | | **C3 — Windows / MSVC & `clang-cl`** | MSVC (`cl.exe`, `lib.exe`, `link.exe`, `/showIncludes`, `.pdb`, `/FS`, `.dll`/`.lib` import libraries), Job Object process-tree kill, `ReadDirectoryChangesW` watcher, case-insensitive path conflict detection. | Real Windows CI runner passing process-tree kill, header-shadowing, and install relocation tests. | | **C4 — True Host-vs-Target Cross-Compilation** | Dual-context evaluation (`host` profile for code generators and `build_dependency` tools vs `target` profile for cross-compiled products), sysroot & `--target=` triple propagation. | `linux-x86_64` host cross-compiling `linux-aarch64` fixture while executing host-compiled generator natively. | diff --git a/registry/service/RegistryService.cpp b/registry/service/RegistryService.cpp index c7882dd..3ae4b6b 100644 --- a/registry/service/RegistryService.cpp +++ b/registry/service/RegistryService.cpp @@ -46,6 +46,36 @@ std::optional not_modified_for(const HttpRequest &req, const std:: return resp; } +// Weak comparison of an If-None-Match field value against a strong ETag per RFC 7232 +// section 3.2: `*` matches any current representation, list members compare by opaque tag, +// and the W/ weakness prefix is ignored on both sides. +bool if_none_match_matches(std::string_view field, std::string_view etag) { + const auto trim = [](std::string_view text) { + while (!text.empty() && (text.front() == ' ' || text.front() == '\t')) { + text.remove_prefix(1); + } + while (!text.empty() && (text.back() == ' ' || text.back() == '\t')) { + text.remove_suffix(1); + } + return text; + }; + const auto opaque_tag = [&](std::string_view tag) { + tag = trim(tag); + if (tag.starts_with("W/")) { + tag.remove_prefix(2); + } + return tag; + }; + const auto expected = opaque_tag(etag); + for (const auto part : Void::Str::split(field, ',')) { + const std::string_view candidate = trim(part); + if (candidate == "*" || opaque_tag(candidate) == expected) { + return true; + } + } + return false; +} + // Adds a strong ETag to a cacheable 200 response and honours If-None-Match with 304. HttpResponse with_etag(HttpResponse resp, const HttpRequest &req) { if (resp.status != 200) { @@ -54,10 +84,11 @@ HttpResponse with_etag(HttpResponse resp, const HttpRequest &req) { std::string etag = "\"" + Util::sha256_hex(resp.body).substr(0, 32) + "\""; resp.headers["ETag"] = etag; resp.headers["Cache-Control"] = "no-cache"; - if (const auto inm = req.header("if-none-match"); inm && *inm == etag) { + if (const auto inm = req.header("if-none-match"); inm && if_none_match_matches(*inm, etag)) { HttpResponse not_modified; not_modified.status = 304; not_modified.headers["ETag"] = etag; + not_modified.headers["Cache-Control"] = "no-cache"; return not_modified; } return resp; diff --git a/src/Main.cpp b/src/Main.cpp index 5bfd8e3..f9840c6 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -1276,6 +1277,8 @@ struct VerifyCmdOptions { std::optional file_arg; std::optional signature_arg; std::optional public_key_arg; + std::vector trusted_public_keys; + std::vector trusted_key_files; }; int execute_verify_command(const VerifyCmdOptions &opts) { @@ -1285,6 +1288,23 @@ int execute_verify_command(const VerifyCmdOptions &opts) { "required\n"; return 2; } + auto trusted = combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, + std::filesystem::current_path()); + if (!trusted) { + std::cerr << "vbs verify: " << trusted.error().message() << '\n'; + return 1; + } + if (!trusted->empty()) { + std::string supplied = *opts.public_key_arg; + std::ranges::transform(supplied, supplied.begin(), [](char c) { + return static_cast(std::tolower(static_cast(c))); + }); + if (std::ranges::find(*trusted, supplied) == trusted->end()) { + std::cerr << "vbs verify: public key is not trusted\n"; + return 1; + } + } + auto digest = Util::sha256_file_hex(*opts.file_arg); if (!digest) { std::cerr << "vbs verify: " << digest.error().message() << '\n'; @@ -2809,7 +2829,12 @@ int main(int argc, char **argv) { .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); + .option("--public-key", "", "Signer public key hex", verify_opts.public_key_arg) + .option_many("--trusted-public-key", "", + "Require the signer key to be trusted (hex; repeatable)", + verify_opts.trusted_public_keys) + .option_many("--trusted-key-file", "", "File with trusted public keys (repeatable)", + verify_opts.trusted_key_files); add_log_flags(verify_cmd, false); // `-v` is `--version` on verify. auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock"); diff --git a/tests/CliContracts.cmake b/tests/CliContracts.cmake index a44b9fd..9a95cf2 100644 --- a/tests/CliContracts.cmake +++ b/tests/CliContracts.cmake @@ -60,6 +60,11 @@ check_process(0 "Usage: vbs compdb-entries " "" compdb-entries --help) check_process(1 "" "no compilation database is published" compdb-entries --project "${CMAKE_CURRENT_BINARY_DIR}/no-lock-project") check_process(2 "" "--name, --version, --file, --signature, and --public-key are required" verify) +check_process(1 "" "public key is not trusted" verify --name demo --version 1.0.0 + --file CMakeLists.txt + --signature 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + --public-key 0000000000000000000000000000000000000000000000000000000000000000 + --trusted-public-key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) check_process(1 "" "" verify --name demo --version 1.0.0 --file CMakeLists.txt --signature 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 --public-key 0000000000000000000000000000000000000000000000000000000000000000) diff --git a/tests/DaemonTests.cpp b/tests/DaemonTests.cpp index fa204e8..3c29011 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -2237,9 +2237,21 @@ void build(Void::Build::Project &project) { Void::Testing::expect(std::filesystem::exists(str_field(*installed, "manifest"))); const auto installed_files = string_array_field(*installed, "installed_files"); Void::Testing::require(!installed_files.empty()); - Void::Testing::expect(std::filesystem::exists(installed_files.front())); - Void::Testing::expect(installed_files.size() <= - static_cast(int_field(*installed, "files"))); + Void::Testing::expect_eq(installed_files.size(), + static_cast(int_field(*installed, "files"))); + Void::Testing::expect(!bool_field(*installed, "installed_files_truncated")); + const auto prefix_abs = std::filesystem::weakly_canonical(prefix); + for (const auto &file : installed_files) { + const std::filesystem::path path{file}; + Void::Testing::expect(!file.empty()); + Void::Testing::expect(path.is_absolute()); + Void::Testing::expect(std::filesystem::is_regular_file(path)); + const auto relative = path.lexically_relative(prefix_abs); + Void::Testing::expect(!relative.empty()); + if (!relative.empty()) { + Void::Testing::expect(relative.native().rfind("..", 0) != 0); + } + } Void::Testing::require(missing_prefix.has_value()); Void::Testing::expect(!bool_field(*missing_prefix, "ok", true)); @@ -2254,6 +2266,14 @@ void build(Void::Build::Project &project) { Void::Testing::expect(bool_field(*installed_no_cmake, "ok")); Void::Testing::expect(int_field(*installed_no_cmake, "files") >= 1); Void::Testing::expect(std::filesystem::exists(prefix_no_cmake / "bin" / "app")); + const auto installed_files_no_cmake = + string_array_field(*installed_no_cmake, "installed_files"); + Void::Testing::require(!installed_files_no_cmake.empty()); + for (const auto &file : installed_files_no_cmake) { + Void::Testing::expect(std::filesystem::exists(file)); + Void::Testing::expect(!file.ends_with("Config.cmake")); + Void::Testing::expect(!file.ends_with("Targets.cmake")); + } bool has_cmake_config = false; for (const auto &entry : std::filesystem::recursive_directory_iterator(prefix_no_cmake)) { if (entry.is_regular_file() && entry.path().filename().string().ends_with("Config.cmake")) { @@ -2295,6 +2315,9 @@ void build(Void::Build::Project &project) { Void::Testing::expect(bool_field(*uninstalled, "ok")); Void::Testing::expect(int_field(*uninstalled, "removed") >= 1); Void::Testing::expect(!std::filesystem::exists(prefix / "bin" / "app")); + for (const auto &file : installed_files) { + Void::Testing::expect(!std::filesystem::exists(file)); + } } VOID_TEST(Daemon, install_request_component_filters_installed_files) { diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 6571127..6080248 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -1021,6 +1021,40 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ std::string::npos); Void::Testing::expect(binary_detail->body.find("\"download_url\":") != std::string::npos); } + // The binary detail response is ETag-validated: matching (strong, weak, list or `*`) + // If-None-Match values yield a bodyless 304, while a stale validator returns the full 200. + if (binary_detail) { + Void::Testing::expect_eq(binary_detail->headers.at("cache-control"), + std::string{"no-cache"}); + const auto etag_it = binary_detail->headers.find("etag"); + Void::Testing::expect(etag_it != binary_detail->headers.end()); + if (etag_it != binary_detail->headers.end()) { + const std::string &etag = etag_it->second; + auto not_modified = + send_loopback_http(port, "GET", binary_path, {{"If-None-Match", etag}}); + Void::Testing::expect(not_modified.has_value() && not_modified->status == 304); + if (not_modified) { + Void::Testing::expect(not_modified->body.empty()); + Void::Testing::expect_eq(not_modified->headers.at("etag"), etag); + Void::Testing::expect_eq(not_modified->headers.at("cache-control"), + std::string{"no-cache"}); + } + auto weak = + send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "W/" + etag}}); + Void::Testing::expect(weak.has_value() && weak->status == 304); + auto list_match = send_loopback_http(port, "GET", binary_path, + {{"If-None-Match", "\"stale\", " + etag}}); + Void::Testing::expect(list_match.has_value() && list_match->status == 304); + auto wildcard = send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "*"}}); + Void::Testing::expect(wildcard.has_value() && wildcard->status == 304); + auto stale = + send_loopback_http(port, "GET", binary_path, {{"If-None-Match", "\"stale\""}}); + Void::Testing::expect(stale.has_value() && stale->status == 200); + if (stale) { + Void::Testing::expect_eq(stale->body, binary_detail->body); + } + } + } auto missing_binary = send_loopback_http(port, "GET", binary_path + "-missing"); Void::Testing::expect(missing_binary.has_value() && missing_binary->status == 404);