Repository navigation
refactor(compute): drop the last dead strict ipv4 checks - #2428
Conversation
The channel proxy IPv4 rule in the Kubernetes Compute Driver and ipv4HostKept in the profile renderer still tested a strict decimal-octet pattern (and, in Compute, an octet > 255 check) on a host already known to equal the URL parser's hostname after isIP(...) === 4. isIP accepts only four decimal octets from 0 to 255 with no leading zeros, and the parser serializes every IPv4 host that way, so those terms never changed an outcome. The written-vs-parsed host comparison alone decides every refusal. Messages are unchanged. Finding 1337.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes redundant strict IPv4 checks from Kubernetes channel-proxy validation and installation-profile rendering. Example: An Installation configures channels.proxyUrl as http://0177.0.0.1:8080.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep this PR open for maintainer triage; the pinned diff removes redundant checks without changing accepted inputs, diagnostics, or egress destinations, and no actionable defect was found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherInstallation profiles validate operator URLs before rendering configuration, while Kubernetes Compute validates the channel proxy endpoint before using its address and port in gateway egress NetworkPolicies. flowchart LR
A[Operator URLs] --> B[Profile validation]
B --> C[Installation configuration]
C --> D[Kubernetes Compute]
D --> E[Channel proxy validation]
E --> F[Gateway egress NetworkPolicy]
Technical reviewBest possible solution: Retain the written-host comparisons and accept the focused removal of conditions already guaranteed by isIP. Do we have a high-confidence way to reproduce the issue? No user-facing defect is claimed; source inspection confirms the removed conditions are redundant under the retained isIP guards. Is this the best way to solve the issue? The focused deletion preserves the original validation contract without adding a helper, configuration option, or parallel implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b891e5479589. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 14, 2026, 10:05 AM ET / 14:05 UTC. |
Problem
#2425 and #2427 removed three copies of a strict decimal-IPv4 check that only ran on a URL-parser-written host after
isIP(...) === 4, so it could never fail. Two more copies remained:apps/controller/src/drivers/compute/kubernetes/index.ts, channel proxy URL:writtenHostis tested against the strict pattern and anoctet > 255check, but only afterwrittenHost !== parsed.hostnamealready threw.scripts/render-installation-profile.mjs,ipv4HostKept:written === url.hostname && strict.test(url.hostname).isIPaccepts only four decimal octets from 0 to 255 with no leading zeros, and the URL parser serializes every IPv4 host that way. At both sites the tested string equalsparsed.hostname, so these terms never change an outcome.This round swept the whole repo (apps, packages, scripts, deploy, internal, cmd) at once, so no further copies are left behind.
Change
octet > 255term; the condition is nowwrittenHost === undefined || writtenHost !== parsed.hostname.ipv4HostKeptreturnswritten === url.hostname.No behaviour change.
Sweep
Searched for
25[0-5],\d{1,3},[0-9]{1,3},[1-9][0-9]{0,2},(?:0|[1-9],isIP(,isIPv4(,> 255/<= 255,octet,leading zero, dotted-quad shapes, and GoParseIP/ParseAddr/Is4.kubernetes/index.tschannel proxy (strict pattern +octet > 255)writtenHost, already equal toparsed.hostname, afterisIP === 4render-installation-profile.mjsipv4HostKepturl.hostnameafterisIP === 4auth/configuration.tsrefuseRewrittenIpv4Host,occ/backends.tsgatewayEndpointRewritesIpv4,openai-endpoint.tsopenAiBaseUrlRewritesIpv4channel/slack.ts:17PROXY_ENDPOINTrender-installation-profile.mjs:68isLiteralIpv4ProxyUrl(+> 255)controller/src/index.tsipv4()/cidrContainsprefixauth/client-address.ts:72prefix patterndocker/index.tsloopbackHosthost:porttextscripts/ci/logging.mjsassertIpv4,assertIpv4Cidr, EndpointSlice filterisIPgateruntime-entrypoints.ts:3264loopbackpeer_addrocc/runtime-logs/sanitize.ts:402CODEX_SOCKET_ADDRESSclient-address.ts:42,render-installation-profile.mjs:800embedded IPv4 tailrender-installation-profile.mjsisIpv4Cidr,isCidr,sourceCidrs, OIDC host;server.mjs,metrics/listener.ts,oidc.ts,postgres-pool.ts,openshell-service-transport.ts,openshell-gateway-client.ts,check-api-database-ca.mjs;scripts/ci/prepare.mjsisIPv4isIP/isIPv4gate only, no extra pattern_helpers.tpl(ipv4Host32,ipv4Cidr, trusted proxy,auth.baseUrlwritten host, IPv4-mapped tails),networkpolicies.yaml:105, observability-demo_helpers.tpl:16internal/occdev/*.gonetip.ParseAddr/ParsePrefix/Is4onlytests/**dotted-quad assertionsVerification
isIP(...) === 4, none fails the strict pattern or has an octet above 255. Old vs new bodies of both functions compared on a fixed list (octal, hex, shorthand, single integer, trailing dot, percent and fullwidth escapes, userinfo, backslashes, missing slashes, leading controls, tabs and newlines inside the host, uppercase scheme, IPv6) plus ~619k fuzzed URLs: 242,534 refusals, 0 differences.tsc --buildforapps/controller, Prettier and ESLint on the touched files: clean.Risks
Low. Two dead terms removed where the tested string provably equals a canonical
isIPIPv4 host. If a future change applied either check to a raw, unparsed host, it would need its own strictness check.