Repository navigation
fix(cli): route to a running server only when it serves the resolved store (#1445) - #1487
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
| /// returns `true`: routing then behaves as before. | ||
| pub(crate) fn server_serves_store(url: &str, store: &str) -> bool { | ||
| if !is_loopback_url(url) { | ||
| return true; |
| #[test] | ||
| fn a_non_loopback_server_is_never_asked() { | ||
| // Its paths are not ours, so the ids could never match; no request is made. | ||
| assert!(server_serves_store("http://192.0.2.1:9", "/tmp/anything")); |
Collaborator
Author
|
Merging with the two code-scanning alerts still listed: both are anchored to the earlier commit 998b1cb (no analysis was uploaded for the later head). #786 (probe sends no token) was checked against an auth-enabled uteke-serve: with UTEKE_AUTH_TOKEN the guard works, without it the routed command is refused with 401 and nothing lands in the wrong store; the probe uses build_client and a test now pins the Authorization header. #787 flagged the literal test URL 192.0.2.1, which no longer exists. Cora on the head commit: no issues found, 15/15 checks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
store_identity(path), the first 16 hex digits of the SHA-256 of a store's canonical path (trailing slashes trimmed when the directory does not exist). Two spellings of one directory give the same id.GET /storereturning{"id": "<id>"}for the store the server serves (ReqCtx.store_id, set from the home directory at startup). Registry row (writes: false), handler andHANDLERSrow added. The path itself is never returned. It needs the normal token when auth is on, and a read-only token may call it.server_serves_store(url, store). Before routing to a loopback server the CLI asksGET /storeand compares the id with the store it resolved (UTEKE_HOME,--store,uteke.toml). A mismatch runs the command locally with a warning on stderr. A 404 (older server), 401, timeout (500 ms), a body that is not an id, or a non-loopback server keeps the previous routing.docs/api-reference.mdanddocs/core-contract.jsonregenerated:/storeappears in thelablist only,coreis unchanged. CHANGELOG entry added.Why
UTEKE_HOME=/tmp/iso uteke remember ...with[server] enabled = truewas sent to the running server and landed in the server's store, which defeats the isolation #1105 promised. The CLI had no way to know which store a server serves. The owner approved the design on 2026-10-16: a LAB route with a token (no CORE change, so no cloud contract issue), returning an id instead of a path so nothing about the host layout is exposed. Closes #1445.Testing
store_identity(spellings, different dirs, a pinned value checked independently withshasum), serverGET /store(200 with the id for a read-only token, 401 without a token, POST refused), CLIserver_serves_storeagainst a stub HTTP server (same store routes, another store does not, 404/401/non-JSON/refused/non-loopback keep routing).cargo test --workspaceandcargo clippy --workspace --all-targets -D warningsare clean;cargo run -p docgenoutput is committed.uteke-serveon store S and a client on store H ([server]pointing at it), the reproduction from the issue: before, the memory landed in S; now it lands in H (db_count: 1) and S stays at 0 with a warning on stderr. A client withUTEKE_HOME=Sstill routes through the server.