Repository navigation
fix(providers): admit credential endpoints and bound responses - #5336
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on 99c7a77. The verdict and the full list are in the summary comment.
- 🟡 Minor · Response-size limits are duplicated per call site instead of one owner ·
packages/provider-webdriver/src/webdriver-transport.ts:290 - 🟡 Minor · Limrun download re-implements the byte-limit Transform instead of createByteLimitStream ·
packages/provider-limrun/src/download-file.ts:85 - 🟡 Minor · Revyl body reader is a hand-copied clone of the WebDriver bounded reader ·
packages/provider-revyl/src/revyl-client.ts:458
This comment has been minimized.
This comment has been minimized.
Size Report
Startup median (7 runs, lower is better):
Affected plugins
|
This comment has been minimized.
This comment has been minimized.
|
The bounded readers still let several large provider responses through at 9732d00, and credential endpoint refusals do not always carry the typed reason. All 23 checks pass at this commit, including the Coverage and closure guards that failed on the earlier head. There are no conflicts. Before merge, the findings below need fixes. A second independent pass found that webdriver-transport.ts:296 gives every status and route the binary limit. A BrowserStack or TestMu hub can return a 2 MiB JSON reply to POST /session, or a 2 MiB error page to a session command, and the transport buffers and parses it. Ordinary WebDriver text then uses the 32 MiB budget, not the promised 1 MiB. Default to the 1 MiB text reader, let the client select the 32 MiB budget only for successful screenshot and hierarchy responses, and keep unsuccessful responses on the text budget. A second independent pass found the same shape in revyl-client.ts:447. A screenshot or hierarchy GET that returns a 2 MiB JSON 403 or gateway 502 is read under the 32 MiB budget chosen at lines 267-274, and assertSuccess can then decode and parse it (lines 517-520 and 646-660). Apply the larger limit only to successful screenshot and hierarchy responses, and use the 1 MiB budget for every unsuccessful status. A second independent pass found that ios-files.ts:29 still calls response.json() for GET /files/list and for the PUT used by stageFile, both through readFileReply (lines 121-125 and 164-172). A configured Limrun instance can return a multi-megabyte JSON payload there, and the 15-second deadline only stops a stalled peer. Read both replies through the shared 1 MiB body reader, keep the current signal, and let provider_response_too_large pass through the invalid-JSON handler. A second independent pass found that ios-runner-products.ts:313 reads the whole /sync reply with response.json() before it checks needFull. A configured instance can return an array larger than 1 MiB while runner products are staged. Use the shared 1 MiB body reader for this reply and keep the typed overflow through the JSON parse handler. A second independent pass found that ios-runner.ts:188 buffers a finite 409 or 500 body from POST /xctest/run through result.text() before it scrubs the diagnostic. The deadline bounds the wait but not the byte count. Cancel the body when only the status is needed, or read it with the shared 1 MiB cap. Keep the status-based 409 retry decision, and make the launch deadline reach the error-body read. A second independent pass found that ios-files.ts:226 reads an Info.plist that was downloaded under the 2 GiB artifact budget (line 219), and readFile allocates the whole file before the plist parser runs. An XML plist over 1 MiB or a binary plist over 32 MiB can reach the in-memory parser. Set a metadata-specific limit before the download, and keep the abort signal and temporary-directory cleanup. A second independent pass found that ios-runner-products.ts:163 downloads the release manifest under the 2 GiB disk budget (lines 157-162), then reads all of the JSON into memory with no signal, even if input.signal aborts after the transfer. Give the manifest download the 1 MiB text budget and pass input.signal to the manifest read. Keep the 2 GiB budget for the runner archive, and hash that archive incrementally so the disk budget stays a disk budget. A second independent pass found that webdriver-utils.ts:64 builds the URL before admission. A malformed BROWSERSTACK_SESSION_DETAILS_ENDPOINT or TESTMU_API_ENDPOINT reaches appendUrlPath from browserstack.ts:184 or testmu.ts:229, and new URL throws before fetchProviderSessionDetails can issue provider_credential_endpoint_blocked. The TestMu app-list override reaches new URL at testmu-connection-verification.ts:109 before the same policy. No credentials leave on these paths, but callers lose the expected reason. Admit each credentialed base before appending a path or query, and keep the unauthenticated catalog URL construction independent. A second independent pass found that webdriver-utils.ts:325 loses the redirect refusal reason. When an admitted endpoint returns a redirect during credential verification or session-details lookup, fetch correctly refuses to follow it. The handlers at lines 325-331 and 362-367 then return COMMAND_FAILED with only a network hint, so a caller cannot tell the policy refusal from a connection failure. Keep redirect targets unfetched, classify redirect responses before reading them, cancel their bodies, and pass a shared typed refusal reason through the wrappers. A second independent pass found that webdriver-utils.ts:296 also stops redirects on the public TestMu catalog. A staging deployment configured with TESTMU_API_ENDPOINT redirects /capability/generator to its canonical path, which answers with the expected catalog. This head fails connect before the app-list request, although testmu-connection-verification.ts:53-57 sends the catalog request without credentials on purpose. Apply redirect refusal only to the credential-bearing verification call, and keep the previous fetch behavior for the public catalog request. Not blocking, and these can be taken or left: other provider readers still buffer with response.json() (Limrun readFileReply, the runner upload reply, and the ADC client json() at provider-adc/src/client.ts:122), and a follow-up issue could enumerate them by grepping .json()/.text()/.arrayBuffer() under packages/provider-*; readResponseText in src/cli/cloud-response.ts and fetchReleaseFile in packages/apple-runner/src/runner-release-artifact.ts could delegate to readBoundedResponseBody in a second follow-up; the './response-body' export in packages/host-kit/package.json:103 is the only one that points into src/internal/, so a top-level module would match the other subpaths; PROVIDER_RESPONSE_REASONS in packages/contracts/src/facades/remote.ts:29 is the only constant defined in a file of re-exports; the transport and Revyl client import host-kit/response-body twice only to resolve one constant, so readProviderTextBody and readRevylResponseBody could take a 'text' | 'binary' kind; the redirect test at webdriver-transport.test.ts:629 could assert details.reason === 'webdriver_request_interrupted' with dispatched 'unknown'; and the PR body links two private finding URLs with no public issue, still says validation is pending although CI is green, calls Limrun's 2 GiB budget 'existing' although base had no cap, and the PR is still a draft. The three earlier inline threads no longer apply at this head, so they can be resolved: the budgets now have one owner in host-kit (#5336 (comment)), Limrun now uses createByteLimitStream from host-kit/archive (#5336 (comment)), and Revyl delegates to readBoundedResponseBody as WebDriver does (#5336 (comment)). Not verified here: live BrowserStack, TestMu, Revyl and Limrun runs, real response sizes against the new budgets (mainly the TestMu capability/generator catalog and BrowserStack device and app lists against 1 MiB, and the largest WebDriver page source or screenshot against 32 MiB), the test counts in the PR body, and the two private finding URLs. Live evidence is not required for this change. Base had no ceiling, so an answer above these ceilings would be a regression that no fixture can show. |
9732d00 to
e7b78bb
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on e7b78bb. The verdict and the full list are in the summary comment.
- 🟡 Minor · redirect:'manual' is applied to every WebDriver request, not just credentialed ones ·
packages/provider-webdriver/src/webdriver-transport.ts:261
|
The code in e7b78bb is ready. The earlier findings from 9732d00 (#5336 (comment)) are mostly fixed: the response budgets now live in one place and the providers share them. Not blocking: a malformed BROWSERSTACK_SESSION_DETAILS_ENDPOINT, TESTMU_API_ENDPOINT or TestMu apps endpoint still throws a bare TypeError from CI is likely related to the second note: the layering gate rejects a On the open threads: the redirect thread on webdriver-transport.ts (#5336 (comment)) is lower priority and still applies, so one lower-priority thread remains. These no longer apply and can be resolved: all budgets now live in host-kit/src/response-body.ts and every provider imports them (#5336 (comment)); download-file.ts now uses createByteLimitStream (#5336 (comment)); revyl-client.ts now reads through readBoundedResponse (#5336 (comment)). Not verified here: real response sizes against the new budgets (device and app lists and the TestMu catalog against 1 MiB, the largest page source or screenshot against 32 MiB, Info.plist against 256 KiB), and the PR body test counts. |
There was a problem hiding this comment.
All reported issues were addressed across 46 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings and 1 moved to a new line on 09ad38d. The verdict and the full list are in the summary comment.
- 🟡 Minor · Connect-time device catalogs get the 1 MiB budget and fail provider_response_too_large ·
packages/provider-browserstack/src/browserstack-connection-verification.ts:40 - 🟡 Minor · New shared reader in host-kit has no unit tests ·
packages/host-kit/src/response-body.ts:14 - 🟡 Minor · redirect:'manual' + refuseRedirect fire on uncredentialed WebDriver requests too ·
packages/provider-webdriver/src/webdriver-transport.ts:265(moved)
09ad38d to
8fcdee4
Compare
This comment has been minimized.
This comment has been minimized.
…review findings Load host-kit admission and response readers on demand, follow redirects for uncredentialed WebDriver requests, keep the response status on an oversized body, and give provider inventories the large budget.
Apex Sentinel · ✅ Approve · review of
|
| Finding | Fixed by | Where |
|---|---|---|
| Connect-time device catalogs get the 1 MiB budget and fail provider_response_too_large | thymikee | d8dec8b · reply |
| New shared reader in host-kit has no unit tests | thymikee | d8dec8b · reply |
| redirect:'manual' + refuseRedirect fire on uncredentialed WebDriver requests too | thymikee | d8dec8b · reply |
Not in the reviewers' scope (1 file)
pnpm-lock.yaml: generated or a lockfile, so its lines were left out
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (0565094667ed).
💬 Talking to Sentinel
In a finding's thread, reply with:
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
The change at 18d1335 looks good, and the earlier notes from the e7b78bb review (#5336 (comment)) are now fixed or benign. The oversized non-2xx body, the credentialed-only redirect refusal, the status on too-large errors, the 32 MiB budget for verification reads, the download clamp and the new response-body tests all match what the code now does. All 12 earlier inline threads, plus the three newer ones, are fixed at this head except one that is benign: response-body.ts:15-18 is unchanged, and every caller passes a module constant or undefined, so no input reaches an invalid maxBytes (#5336 (comment)). These can be resolved: #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment), #5336 (comment) and #5336 (comment) (this one also closes the earlier low-priority redirect thread r4781477086). CI is green at 18d1335: 24 checks, none failing. The earlier R86 process-globals failure is gone, since no process.env read remains in provider-webdriver production code. No conflicts. Not verified here: real provider response sizes against the 1 MiB, 32 MiB and 256 KiB budgets. The PR body's local validation and the eager-closure budget result rely on green CI and were not re-run. The review covered the changes from aa0b515 to 18d1335; the 0.22 rebase commits were treated as upstream. Nothing else must change before merge. |
Summary
provider A/provider B requests that carry credentials go only to HTTPS or loopback-HTTP endpoints and never follow redirects. Every provider response body (WebDriver hub, Revyl, provider C) is read through one bounded reader. The endpoint URL comes from user config or profile; the response bytes come from the provider.
Before / after
response.text()/arrayBuffer()/json()read unbounded provider bodies.credentialTransportRefusalrule (throughadmitCredentialDestination, including theAGENT_DEVICE_ALLOW_INSECURE_TRANSPORToverride) is checked with the hostenvbefore each credentialed request. Credentialed requests useredirect: 'manual', and any 3xx givesprovider_redirect_refused. Requests without credentials keep following redirects.@agent-device/host-kit/response-bodyreads bodies with a 1 MiB budget. Successful screenshot and source answers, Revyl artifact answers, and provider catalog or app-list replies get 32 MiB. Overflow givesprovider_response_too_largewith the HTTP status. An oversized Revyl error body is dropped, so the status classifier still runs.createByteLimitStream(2 GiB cap). Info.plist and release manifest reads pass a 256 KiB budget.Out of scope: long-lived streaming bodies, such as the provider C
/xctest/runsuccess stream.Size
About 260 production lines versus 0.22.
Validation
Ran the provider package suites,
packages/host-kit/src/response-body.test.ts, andscripts/__tests__/eager-closure-budgets.test.tswith vitest. All passed.