Repository navigation
fix(sync): fail a run whose stored host POST /repos refuses - #907
Conversation
as given: a name with letters outside ASCII, a number that curl reads as an IPv4 address, a port outside 1-65535, an IPv4 literal with a zone, or a base URL with `?`, `#`, a space or an upper-case scheme. A link stored before that keeps its host, and every run handed it to git. Depending on the host, git or curl refused the URL, or curl dialed an address that the registration check never saw (2130706433 is 127.0.0.1), and the failure class varied. Each pull and push run now checks the stored host with the rule of POST /repos before git starts. A host that fails it fails the run as `repository configuration error`, and the cause is the reason that POST /repos gives, `upstream host is not a valid host`, without the host. ValidUpstreamHost and its helpers move from internal/api to internal/sync, because api imports sync and not the reverse, and InvalidUpstreamHostReason is the shared reason. A file:// host stays exempt: only the tests' fixtures store one, and GIT_ALLOW_PROTOCOL refuses it in production. The docs tell operators to link such an upstream again with the host in its ASCII form. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I4bd9c08939f72be8e5b3a5c90bda11244103b1ae Signed-off-by: Thomas Kosiewski <tk@coder.com>
worker.go and handlers_sync.go are covered code: upstreamURLFailure checks the stored host, and the host rule moves to internal/sync. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I52a372967181736ba269cb6f75dbde8513212b8b Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The run now has cases for a resolver-refused ASCII name and a base URL with a fragment, and a case that the host is checked before the URL length. The docs say that no route changes the host of a stored link, and that an older server during an upgrade can store such a host too. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I11956a6d92baf4cdc08b52ed816caf13101db5df Signed-off-by: Thomas Kosiewski <tk@coder.com>
Main gained #905 (both sync lanes decide on the egress proxy with viaEgressProxy). The only conflict is the sync commit of the lane-schedule model; it is re-recorded on the merged tree. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I592ce6e29585d166e4b341c338bb234bdc0d0255 Signed-off-by: Thomas Kosiewski <tk@coder.com>
With the run's host check, #905's lane tests no longer reach the egress proxy: the run refuses an `HTTP://` host before git starts. The tests still pass only while one of the two guards holds, so they now say so in their names and comments. TestViaEgressProxy pins the proxy decision by itself. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I9b3211586de1bf4cb092471eb629f0e63e886072 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Main gained #906 (the hook quotes an unknown ref policy op with errtext.Quote). The only conflict is the sync commit of the lane-schedule model; the next commit re-records it on the merged tree. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: Idc3d6c16d4e6288a5a66f32fbe057badec2ba825 Signed-off-by: Thomas Kosiewski <tk@coder.com>
The merges brought #905's and #906's fingerprints; TLC passes on the merged tree, so the sync commit moves to it. No fingerprint changes. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I1e93add5a92183dda736b91f90b89090e7e46ff4 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Since #903,
POST /reposrefuses an upstream host that a sync run cannot use as given. A link stored before that keeps such a host, and every pull and push run still handed it to git. The result depended on the host, and so did the failure class. The new test on main (allow-private egress policy, the test fixture's default) shows it:bücher.example,https://bücher.examplefailed to clone repository/failed to push to upstream: this host's curl refused the URL (URL using bad/illegal format)http://2130706433:<port>,http://0x7f.1:<port>,http://127.0.0.1:<port>?,http://127.0.0.1:<port>#x<<<.com,http://127.0.0.1:<port>/a b,forge.example:65536HTTP://127.0.0.1:<port>transport 'HTTP' not allowed)https://[fe80::1%25eth0]upstream repository unreachable: the egress dial failedNow each run checks the stored host with the rule of
POST /reposbefore git starts. A host that fails it fails the run asrepository configuration error. The server'sWARNline for the run gives the causerepository configuration error: upstream host is not a valid host, with the reason thatPOST /reposgives, and does not repeat the host.A stored link that synced before can now fail every run. With the allow-private policy, a
http://2130706433:<port>link reached a git server on 127.0.0.1 and could sync from it; abücher.examplelink could sync where the server's curl and locale convert the name (I did not verify this; this host's curl refuses it). This is the intended change, and it goes into the release notes with #903's. The docs tell operators to create a sync repository again with the host in a form thatPOST /repostakes, such as the ASCII form of a name.Changes
ValidUpstreamHostand its helpers (dialableAuthority,dialableHostname,resolverName,curlIPv4Name,curlIPv4Part) move unchanged frominternal/api/handlers_sync.gotointernal/sync/upstreamhost.go, because api imports sync and not the reverse.InvalidUpstreamHostReason(is not a valid host) is the reason both packages give.TestValidUpstreamHostmoves with them.upstreamURLFailure, which both lanes call before git starts, checks the host before the URL length, asPOST /reposdoes. Afile://host is exempt: only the tests' fixtures store one,POST /reposnever has, andGIT_ALLOW_PROTOCOLrefuses it in production.docs/reference/http-api.md("Upstream sync") says how such a run fails, that no route changes the host of a stored link, and that a new sync repository with the host in a formPOST /repostakes syncs the upstream again; the READMEs ofinternal/apiandinternal/sync.TestWorkerUpperCaseSchemeUpstreamNeverDialsAroundProxy,TestPushRunUpperCaseSchemeUpstreamNeverDialsAroundProxy, renamed from...DialsThroughProxy) now stop at the host check, before git starts. They still fail only when both guards break: with the host check off they pass on the egress proxy, with the proxy decision back to lower case only they pass on the host check, and with both they fail.TestViaEgressProxypins the proxy decision by itself.worker.goandhandlers_sync.goare covered by the lane-schedule model, so the fingerprints are re-recorded. The host rule's functions leave the record withhandlers_sync.go: the model describes lanes, not hosts.Evidence
TestRunRefusesStoredInvalidHost(internal/sync) stores the eleven hosts above, at least one per class thatPOST /reposrefuses, and runs each through the pull lane and the push lane. Each run must return exactlyrepository configuration error: upstream host is not a valid host, emit a failed event withrepository configuration error, send no request to the loopback upstream, and log that cause without the host.TestRunChecksStoredHostBeforeURLLengthstores a non-ASCII base URL whose upstream URL is also over the length limit: the run gives the host's reason.worker.go, all 22 cases fail as in the table, and the order test gets the URL-length cause.go test -race -tags=openstorage_viewcheckof./internal/sync/...and./internal/api/...without pg passes at d75a879 (91 s, 373 s) and at 72ffbda, after the merge with fix(sync): send an upper-case http(s) scheme through the egress proxy #905 (72 s, 384 s). PostgreSQL and S3-WAL rely on CI.Reviews
POST /reposstores and a run now refuses (provider defaults and every host in the tests), and checked the table above and the "could sync from it" claim against a real git http-backend with main'sworker.go. Its mutants (no check, one lane only, every non-http scheme exempt, the host in the cause, another class or reason) all failed the test, except the host checked after the URL length. Round 2 adds that test, the<<<.comand#xhosts, and two docs points: no route changes a stored host, and an older server during an upgrade can store one. Left open (P3): ADR 044 still namesvalidUpstreamHost(a historical record), and a storedfile://row, which no release ever wrote, would fail as a clone or push error instead.git diff origin/maintouches only this PR's files, the fingerprints hold all three PRs' entries, the two-guard claim and the order test hold under mutants, and the new table rows reproduce with main'sworker.go. Its one P2 was this PR body, still the round-1 text at the new head; it checked this text claim by claim. Left open (P3):http-api.mdsays theWARNline gives the causeupstream host is not a valid host, which the logged cause contains afterrepository configuration error:.Found by the reviews of #903 (desk follow-up).
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh