feat(registry): manage package owners with audit
This commit is contained in:
1 parent
34fe148eb4
commit
18caf2e7e6
6 files changed
+106
-2
No files matched your search
@@ -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.
|
||||
|
||||
## 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/<name>/owners[/<user>]`: 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## 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.
|
||||
|
||||
|
||||
@@ -65,4 +65,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 58 (Daemon target info) | `target_info` daemon request + `vbs daemon target info --name`: kind, sources, outputs, runtime libraries | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 24/24, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 59 (Daemon pack request) | `pack` daemon request + `vbs daemon pack --output`: deterministic archive confined to the build root, returns path and SHA-256 | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 25/25, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 60 (Daemon actions + binary detail) | `actions` daemon request with target filter and limit; `GET .../binaries/<variant>` detail endpoint | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 26/26, Registry 7/7, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/DaemonTests.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 61 (Registry ownership API) | `GET/PUT/DELETE .../owners[/<user>]` with authority, CSRF, audit, 404/409 handling | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `registry/service/RegistryService.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) |
|
||||
@@ -996,6 +996,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
|
||||
(same pattern as before), and was stopped before any file was written; the slice was then
|
||||
implemented directly.
|
||||
|
||||
## Registry Package Ownership API (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.70 s; on a dedicated package the RBAC
|
||||
test checks owners listing, adding an owner, a 404 for an unknown user, a 403 when a
|
||||
reader-owner tries to mutate, successful removal, and a 409 when removing the last owner.
|
||||
- Full CTest: **8 / 8 passed** in 239.25 s.
|
||||
- `clang-format --dry-run --Werror` passes on the changed C++ files.
|
||||
|
||||
## 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).
|
||||
|
||||
@@ -73,7 +73,7 @@ flowchart LR
|
||||
| --- | --- | --- |
|
||||
| **E1 — Everyday CLI Ergonomics (Implemented in Wave 8)** | `vbs init` project scaffolding, `vbs clean`, `vbs doctor` environment diagnostics, `vbs graph --format dot|json`, and `vbs build --native-foreign`. | End-to-end CLI & integration tests passing in `vbs_cli_contract` and `vbs_v1_tests`. |
|
||||
| **E2 — Multi-Package Workspaces (`workspace.cpp`)** *(verified in Docker GCC 16)* | Shared root `vbs.lock` and `build/.vbs` CAS, `workspace_dependency()` cross-member native linking, and affected-member selection (`vbs build/test --member <pkg>` / `--changed-since <ref>`). | 3-package workspace fixture (shared library + app + tests) builds/tests with one root lockfile; member selection and `--changed-since` verified in `FullV1Tests.workspace_members_shared_build_and_member_selection`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon clean` removes generated outputs while preserving the shared cache, `vbs daemon target info` reports per-target sources/outputs, `vbs daemon actions` lists bounded lowered actions, `vbs daemon pack` creates a confined deterministic source archive, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, and releases expose a version-specific detail endpoint. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon clean` removes generated outputs while preserving the shared cache, `vbs daemon target info` reports per-target sources/outputs, `vbs daemon actions` lists bounded lowered actions, `vbs daemon pack` creates a confined deterministic source archive, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, releases expose a version-specific detail endpoint, and package ownership is managed through an audited owners API. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E4 — Transport & Storage Upstream Alignment** *(Sqlite and Net client adopted)* | Adopt `Void::Net` (`VL-004`/`VL-005`) and `Void::Sqlite` (`VL-011b`) when lightweight/bundled builds become available in minimal Nix toolchains, reducing VBS transport code further. `Void::Sqlite` backs the `StateStore` when SQLite3 is present, `Void::Net` backs the `RegistryClient`, remote-cache, and registry-server HTTP transports (TLS-verifying `HttpClient`/`HttpServer`) when `Net` is enabled (`-p openssl -p boost`), keeping the pure-POSIX fallbacks. | All `vbs_registry_tests` and `vbs_core_tests` pass on both minimal and full toolchains (verified: registry 7/7 on the Net transport; default and SQLite builds 8/8). |
|
||||
|
||||
---
|
||||
|
||||
@@ -900,6 +900,62 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
|
||||
"}\n");
|
||||
}
|
||||
|
||||
// Owners: GET/PUT/DELETE /api/v1/packages/<name>/owners[/<user>]
|
||||
if ((segs.size() == 5 || segs.size() == 6) && segs[4] == "owners") {
|
||||
const auto pit = packages_.find(pkg_name);
|
||||
if (pit == packages_.end()) {
|
||||
return HttpResponse::error_json(404, "not_found", "package not found");
|
||||
}
|
||||
const auto owners_json = [&] { return json_array(pit->second.owners, json_quote); };
|
||||
if (req.method == "GET" && segs.size() == 5) {
|
||||
if (!can_read_pkg(pit->second)) {
|
||||
return HttpResponse::error_json(principal ? 403 : 401, "forbidden",
|
||||
"private package requires authorization");
|
||||
}
|
||||
return HttpResponse::json(200, "{\"name\":" + json_quote(pkg_name) +
|
||||
",\"owners\":" + owners_json() + "}\n");
|
||||
}
|
||||
if (!principal) {
|
||||
return HttpResponse::error_json(401, "unauthorized", "authentication required");
|
||||
}
|
||||
if (!check_csrf_locked(req, *principal)) {
|
||||
return HttpResponse::error_json(403, "csrf_failed",
|
||||
"missing or invalid CSRF token");
|
||||
}
|
||||
if (!can_publish_pkg(&pit->second)) {
|
||||
return HttpResponse::error_json(403, "forbidden",
|
||||
"insufficient ownership authority");
|
||||
}
|
||||
if (segs.size() != 6) {
|
||||
return HttpResponse::error_json(400, "invalid_request",
|
||||
"owner mutations require a user name");
|
||||
}
|
||||
const std::string &target_user = segs[5];
|
||||
if (!users_.contains(target_user)) {
|
||||
return HttpResponse::error_json(404, "not_found", "user not found");
|
||||
}
|
||||
if (req.method == "PUT" || req.method == "POST") {
|
||||
pit->second.owners.insert(target_user);
|
||||
append_audit_locked(principal->username, "package.owner_add",
|
||||
pkg_name + ":" + target_user, "ok", "");
|
||||
(void)save_locked();
|
||||
return HttpResponse::json(200, "{\"owners\":" + owners_json() + "}\n");
|
||||
}
|
||||
if (req.method == "DELETE") {
|
||||
if (pit->second.owners.size() <= 1 && pit->second.owners.contains(target_user)) {
|
||||
return HttpResponse::error_json(409, "last_owner",
|
||||
"cannot remove the last owner");
|
||||
}
|
||||
pit->second.owners.erase(target_user);
|
||||
append_audit_locked(principal->username, "package.owner_remove",
|
||||
pkg_name + ":" + target_user, "ok", "");
|
||||
(void)save_locked();
|
||||
return HttpResponse::json(200, "{\"owners\":" + owners_json() + "}\n");
|
||||
}
|
||||
return HttpResponse::error_json(405, "method_not_allowed",
|
||||
"owners supports GET/PUT/POST/DELETE");
|
||||
}
|
||||
|
||||
// Release detail: GET /api/v1/packages/<name>/<version>
|
||||
if (segs.size() == 5 && req.method == "GET") {
|
||||
const auto pit = packages_.find(pkg_name);
|
||||
|
||||
@@ -176,6 +176,39 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
|
||||
*bytes1);
|
||||
Void::Testing::expect(half_sig_pub.has_value() && half_sig_pub->status == 400);
|
||||
|
||||
// Package ownership management (bearer tokens are not ambient browser credentials).
|
||||
auto owner_pkg_pub = send_loopback_http(
|
||||
port, "PUT", "/api/v1/packages/owner-pkg/1.0.0",
|
||||
{{"Authorization", "Bearer " + *alice_tok}, {"X-Content-SHA256", *sha1}}, *bytes1);
|
||||
Void::Testing::expect(owner_pkg_pub.has_value() && owner_pkg_pub->status == 201);
|
||||
auto owners = send_loopback_http(port, "GET", "/api/v1/packages/owner-pkg/owners",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(owners.has_value() && owners->status == 200);
|
||||
if (owners) {
|
||||
Void::Testing::expect(owners->body.find("pub_alice") != std::string::npos);
|
||||
}
|
||||
auto add_owner = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/read_bob",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::require(add_owner.has_value());
|
||||
Void::Testing::expect_eq(static_cast<int>(add_owner->status), 200);
|
||||
auto add_unknown = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/ghost",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(add_unknown.has_value() && add_unknown->status == 404);
|
||||
// A reader who was added as an owner still lacks publish authority, so cannot mutate.
|
||||
auto reader_remove =
|
||||
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/pub_alice",
|
||||
{{"Authorization", "Bearer " + *bob_tok}});
|
||||
Void::Testing::expect(reader_remove.has_value() && reader_remove->status == 403);
|
||||
auto remove_added =
|
||||
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/read_bob",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(remove_added.has_value() && remove_added->status == 200);
|
||||
// The last remaining owner cannot be removed.
|
||||
auto remove_last =
|
||||
send_loopback_http(port, "DELETE", "/api/v1/packages/owner-pkg/owners/pub_alice",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(remove_last.has_value() && remove_last->status == 409);
|
||||
|
||||
// Unauthenticated access to private package MUST fail (401)!
|
||||
auto anon_priv = send_loopback_http(port, "GET", "/api/v1/packages/secret-pkg");
|
||||
Void::Testing::expect(anon_priv.has_value() && anon_priv->status == 401);
|
||||
|
||||
Reference in new issue
Block a user