Repository navigation
fix(ts): strip dotted API-version prefixes (#52) - #56
Merged
Merged
Conversation
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.
Description
The TypeScript proxy denied almost every non-GET request from a stock Docker CLI.
stripAPIVersion(ts/src/proxy.ts) only stripped undotted prefixes (/^\/v\d+\//). The CLI sends dotted ones on every request (/v1.43/containers/create), so the router saw the prefixed path, matched nothing, and fell to the default deny. Go and Rust were not affected.Fix: a one-line regex change,
/^\/v\d+\//→/^\/v\d+(\.\d+)?\//, which accepts/v<major>and/v<major>.<minor>. Go and Rust production code is unchanged.Closes #52
Repro against built
ts/distThe router was built with
config/, and the create request used the body{Image: "chainsafe/lodestar:latest"}.Tests (written first; the RED commit is
6f5706a)#52: GoTestRouteVersionedPaths, Rusttest_route_versioned_paths, and TSroutes dotted API-version paths like the unversioned ones.DELETE /v1.43/containers/json→ Deny, which checks that the reserved segment is still caught after the prefix is stripped.DELETE /volumes/containers/fooandDELETE /v1.2.3/containers/foo, both → Deny./^\/v[^/]*\//) in place, both rows fail./v…/first segment, so they allow both paths today. That gap is recorded on Deferred minor findings from the #43/#47/#50/#51 review cycles #55, with Go router output, as a follow-up for a Go router doesn't exclude reserved path segments in extractContainerName (cross-language parity) #24/Rust extract_container_name treats empty segment as a container name (DELETE /containers/ is forwarded) #48-style fix in all three languages.deploy/test.sh(32 → 35 checks):POST /v1.45/containers/createwith an allowed image (thedocker runpath) must get 201 or 404 from the daemon, not a proxy 403. Before the fix, TS returned 403.POST /v1.45/containers/no-such-container/startmust reach the daemon. A daemon 404 means the request got through; a proxy deny would be 403. Before the fix, TS returned 403.DELETE /v1.45/containers/json→ 403. This check passed before the fix too, because default deny already caught it, so it only guards behaviour after the fix.The RED commit fails in TypeScript on purpose, so this PR has to be squash-merged.
Type of change
Implementation(s) changed
spec/router.qntmodels paths after the version prefix is stripped)deploy/test.shchecks)Testing
make test-all): Go 102, Rust 140, TS 157 (156 pass, 1 skipped)make test-integration,make test-integration-rsandmake test-integration-tseach pass all 35 checks. With the regex reverted, the TS suite fails exactly the two discriminating versioned checks (33 passed, 2 failed).make verify): not run locally, since the spec didn't change. It runs in CI (quint job), andmake test-specpasses.Checklist
AGENTS.mdandREADME.md)