Repository navigation
fix(javascript): decide a socket host member by its string type - #9380
XiaoBinGan wants to merge 4 commits into
Conversation
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. |
[Low impact] The reviewed changes appear safe to merge. SummaryThe PR filters socket facts when
Reviews (6) · Last reviewed commit: "fix(javascript): compare the prototype e..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f49bc04281
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
All nine fixed in A call is not a type. The last assignment wins. A Unix path bypasses the host check. Constant expressions fold. Shadowed 43 cases, 13 failing before this commit. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8727f30a2a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
All six fixed in A falsy A later write replaces the path. A non-literal path leaves the overload open. A shadowed
55 cases, 10 failing before this commit. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e75e21fc1d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
All three in A spread can run a getter that rewrites another key.
An empty path still lets
57 cases, 3 failing before this commit; removing the plain-literal guard fails two of them, so it is load-bearing. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 878221eade
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Fixed in
Also moved the One detail worth recording: this only fires when the prototype-mutation collector actually runs, which needs a function, array or loop somewhere in the source. A file with none of those does not collect prototype facts at all, so the finding is not reachable there either way. 59 cases; the inherited-path case fails with the guard reverted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6058bd7a7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
The invocation-timing one is fixed in The intrinsic-alias one I am not fixing here, and I want to be direct about why. What would: teach the collector that 5219 → 5221 + 5100 in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c0d48f3d2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
9657322 to
6ccba4e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ccba4e976
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
You were right, and this is the producer-side fix rather than another consumer check —
Measured on Node 24.22.1,
Two things worth naming in the fix:
4 cases added; reverting the trigger fails 2. The other three open threads on this PR are the intrinsic-alias and opaque-eval cases, which need changes inside |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 471df9a08f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
471df9a to
3297355
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Rebased onto current The two sides are independent additions that share the region's leading
No declaration name is shared, and Validation: a full-project |
Resolved against current main. The branch's socket-host work and the TLS protocol-version work that landed since rewrite the same helper region, so the squash merge conflicted over 370 lines. Both sides are complete additions that share the region's leading `/**` and its trailing `};`: main's side declares TLS_PROTOCOL_VERSIONS, rejectsTlsProtocolVersionLiteral and tlsOptionMerge, while this branch declares staticConstantValue, MemberRead, isPlainOptionsLiteral, defaultPrototypeMaySupply and finalMemberNode. No declaration name is shared, and the branch never touched the three main-side names, so the union keeps both blocks, closes main's function and opens this branch's block at the seam. The acquisition filter now ANDs rejectsTlsProtocolVersionLiteral with rejectsSocketHostMember. Verified with a full-project typecheck: no error names this file (the reported errors are missing modules from an interrupted dependency install). The branch's 203 test cases could not be executed locally because `npm ci` cannot complete against the registry here, so CI is the first test run.
3297355 to
f5a9cca
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…mutator
Two producer findings, both measured on Node 24.22.1.
**A mutator call changes a prototype with no assignment in the source.** The trigger only looked at
assignment, update and delete targets, so `Object.defineProperty(Object.prototype, "path", {value:
"/tmp/a.sock"})` left the prototype facts off and the later `net.connect({port: 0, host: 1})` lost
its acquisition. The call is a write target now, and the spelling test it needs is shared with the
assignment arm so the two cannot drift.
**A write through an alias names the alias, not the owner.** `const p =
Object.getPrototypeOf({}); p.path = "/tmp/a.sock"` reaches `Object.prototype` and connects, but
nothing connected `p` to `Object`. The alias table is built syntactically — bindings are not
resolved at the point the facts are indexed, and `p` is recognisable without them — and a write
whose base is such an alias reports the owner.
The alias is also a fact trigger: the write below spells `p`, so only the call that produced it can
turn the prototype facts on.
`src/domain/javascript` — 5462 passing. Reverting both halves fails the new cases.
|
Both producer findings fixed in A mutator call now counts as a prototype write. An alias is resolved to its owner. The alias table is syntactic, and the reason is worth stating: The alias is also a fact trigger: the write below spells Still open on this PR, and I am not claiming them: the later-options |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae82d8897c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Two host-filter findings, both measured on Node 24.22.1.
**`tls` merges a later options object before the host is read.**
| call | outcome |
| --- | --- |
| `tls.connect({port: 0, host: 1}, {host: "localhost"})` | socket created |
| `tls.connect({port: 0, host: "localhost"}, {host: 1})` | THREW `ERR_INVALID_ARG_TYPE` |
| `tls.connect({port: 0, host: 1}, {})` | THREW — an empty override writes nothing |
The filter read only slot 0, so it decided from a value the merge had replaced. `mergedOptionsLiteral`
returns the later literal when it writes `host`, nothing when it cannot change the host, and
`unknown` when it might, so the overload test and the host read both see the effective object.
**An opaque global effect can patch the intrinsic a value folds through.** `isUnmodifiedGlobalReference`
covers the writes the source shows; it does not cover `globalThis.eval("Number = String")`, which the
analyzer records separately.
| call | outcome |
| --- | --- |
| `globalThis.eval("Number = String"); net.connect({port: 0, host: Number(1)})` | socket created |
| `net.connect({port: 0, host: Number(1)})` | THREW `ERR_INVALID_ARG_TYPE` |
`semanticOpaqueGlobalMayHaveChanged` gates the fold, so a call whose intrinsic may have been replaced
stays undecided.
`src/domain/javascript` — 5462 passing.
|
Both fixed in The merged host. The opaque patch. All four threads on this PR are addressed. The two producer-side ones changed where the facts come from rather than how the filter reads them, which I think is the right split: the filter asked a correct question and the answer table was incomplete. |
…guous alias
Two producer findings.
**`Reflect.defineProperty` has the same effect as the `Object` form.** Measured on Node 24.22.1,
`Reflect.defineProperty(Object.prototype, "path", {value: "/tmp/a.sock"})` then
`net.connect({port: 0, host: 1})` connects over the inherited path. The receiver test only accepted
`Object`. Two of the three mutators take a `Reflect` spelling (`Reflect.apply` and
`Reflect.construct` are not property definitions), so only those two are accepted.
**A name with two different owners is not an alias.** The table was first-wins over the whole
program, so an inner `const p = Object.getPrototypeOf({})` shadowing an outer
`p = Object.getPrototypeOf([])` resolved the inner write to `Array` — a prototype mutation
attributed to the wrong owner. A second declarator with a different owner now makes the name
unusable instead.
That leaves one shape undecided and I would rather say so than guess: the shadowed write reports
nothing, because the table is built from the program rather than from the binding at the write.
Deciding it needs per-write scope resolution, which is a different piece of work. Attributing it to
`Array` was worse — that is a wrong fact, while no fact at least keeps the answer open.
`src/domain/javascript` — 5467 passing.
|
Both fixed in
The first-wins map — you are right, and the failure was worse than a miss: an inner I have not made the inner write correct, and I want to be direct about why. The table is built from the program; it does not know which declarator is in scope at the write, so picking the inner one would be as unfounded as picking the outer. A second declarator with a different owner now makes the name unusable, so the answer stays open instead of being attributed to Deciding it properly needs the scope of the write, which means carrying the binding index into this pass — |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63aca79932
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ); | ||
| } else { | ||
| const owner = globalOwner(value); | ||
| const owner = globalOwner(value) ?? aliasOwner(value); |
There was a problem hiding this comment.
Do not taint prototypes on alias rebinding
When a prototype alias is later rebound, for example let p = Object.getPrototypeOf({}); p = {}; net.connect({ port: 0, host: 1 }), this fallback treats the identifier assignment itself as an Object.prototype mutation. defaultPrototypeMaySupply then makes the absent path unknown and preserves an acquisition, but the rebinding does not touch Object.prototype and Node throws on the numeric host; bare alias writes need to update or retire the alias rather than call taint.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
net and tls connect through options.host || "localhost" and throw ERR_INVALID_ARG_TYPE from the call when that is not a string, so a truthy non-string host leaves no socket. Read the final host, path and TLS socket members through one option reader shared with the TLS protocol-version check, and drop the acquisition only when the host is statically truthy and not a string while no truthy path or TLS socket, or an Object.prototype write that may supply one, skips the host read. The truthy and falsy host tests come from #9380. Its intrinsic-prototype gating changes are not included. Fixes #10002 Co-Authored-By: 吴佳浩 <[email protected]> Co-Authored-By: gensokyo-dev <[email protected]>
net and tls connect through options.host || "localhost" and throw ERR_INVALID_ARG_TYPE from the call when that is not a string, so a truthy non-string host leaves no socket. Read the final host, path and TLS socket members through one option reader shared with the TLS protocol-version check, and drop the acquisition only when the host is statically truthy and not a string while no truthy path or TLS socket, or an Object.prototype write that may supply one, skips the host read. The truthy and falsy host tests come from #9380. Its intrinsic-prototype gating changes are not included. Fixes #10002 Co-Authored-By: 吴佳浩 <[email protected]> Co-Authored-By: gensokyo-dev <[email protected]>
|
Thank you. #10538 reimplemented the socket host decision on the existing TLS option reader and kept your truthy/falsy host tests, crediting you as co-author. The intrinsic-prototype gating commits are not included. Closing this PR as superseded. |
|
Understood — thanks for carrying it over. I re-read main before answering, and the two routes those commits covered are now owned by different modules than the ones I patched:
So I have nothing left to carry over from that branch, and I am not reopening it. If a route is still unproven somewhere, the smallest useful thing I can add is the failing input plus the runtime measurement that shows it, not the patched branch. |
Summary
Fixes #10002.
net/tlsreadoptions.hostand throwERR_INVALID_ARG_TYPEfrom the call itself when the member is truthy and not a string, so no socket exists afterwards. The acquisition filter decided only the port, so a call that throws produced a complete built-in acquisition plus its linked release.Measured on Node 24.22.1
hostundefined,null,"",0,-0,false,0n,NaN,void 0,!1"localhost","0.0.0.0",`x`,String("127.0.0.1"), a resolved helper1,1.5,true,1n,{},[],/x/,Symbol(),() => {},Infinity,!0,-1,+1,!!1ERR_INVALID_ARG_TYPEnew String("x"),new Number(1)ERR_INVALID_ARG_TYPEFour rules follow, and the first version of this check got each of them wrong:
NaNand0n; a boxed string is an object, sonew String("x")is refused.String(...)and any resolved helper returning a string produce a socket; only an unmodified globalSymbol(),Number()orBoolean()has a settled non-string type.{host: 1, host: "localhost"},{host: 1, ["host"]: "…"}and{host: 1, ...{host: "…"}}all connect, so the member is read in write order and a later spread or computed key leaves it undecided.net.connect({path: "/tmp/s.sock", host: 1})connects, andtls's{socket}behaves the same.The positional second argument is a different slot Node does not validate —
net.connect(0, 5)connects — so only the member is decided.Contract and boundary impact
Expected effects:
Validation performed
src/domain/javascript— 5083 passed.npx tsc --noEmit -p .— exit 0npm run build— exit 0npm run format:check— exit 0npm run lint— 0 errorsnpm run knip— exit 0Before merge
type(scope): outcome.Author readiness
Human owner: @XiaoBinGan