Skip to content

fix(javascript): recover inline FunctionExpression bundler IIFEs and Rspack getters - #9500

Closed
saariuslystoned wants to merge 21 commits into
morluto:mainfrom
saariuslystoned:fix/javascript-rspack-iife-bootstrap
Closed

saariuslystoned wants to merge 21 commits into
morluto:mainfrom
saariuslystoned:fix/javascript-rspack-iife-bootstrap

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recover standalone Rspack and Webpack 5 bundler bootstraps where SWC or Terser folds the module loader into an inline named FunctionExpression IIFE (or an unmutated variable-declared function) and support Rspack/Webpack block-body __webpack_require__.n default-interop getters and module-binding aliases during static JavaScript and Electron boundary analysis.

No related GitHub issue is linked; this addresses a concrete static bundler analysis gap observed on minified standalone Rspack and Webpack 5 Electron bundles.

Problem and expected behavior

When a standalone Rspack or Webpack 5 bundle attaches no helper properties onto __webpack_require__, SWC and Terser fold the loader declaration and entry invocation into an inline named FunctionExpression call expression:

(() => {
  "use strict";
  var __webpack_modules__ = {
    91288: (module) => { module.exports = require("electron"); },
    85425: (_unused, _exports, __webpack_require__) => {
      const electron_1 = __webpack_require__(91288);
      const { ipcRenderer } = electron_1;
      ipcRenderer.send("APP_READY");
    }
  };
  var __webpack_module_cache__ = {};
  var __webpack_exports__ = (function __webpack_require__(moduleId) {
    var cachedModule = __webpack_module_cache__[moduleId];
    if (cachedModule !== undefined) return cachedModule.exports;
    var module = (__webpack_module_cache__[moduleId] = { exports: {} });
    return __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__), module.exports;
  })(85425);
})();

Separately, Rspack and Webpack 5 emit block-body __webpack_require__.n compatibility getters (var getter = module && module.__esModule ? () => module.default : () => module; __webpack_require__.d(getter, { a: getter }); return getter; and SWC/Terser's comma-sequence form return __webpack_require__.d(getter, { a: getter }), getter;) alongside two-step module-binding imports (var e0 = __webpack_require__(91288); var d0 = __webpack_require__.n(e0); d0().ipcRenderer.send(...) or const { ipcRenderer } = electron_1).

Previously:

  • javascriptBootstrapAt and proveJavaScriptBootstrapIntegrity only admitted FunctionDeclaration loaders invoked by a separate statement, producing 0 bundler_registrations, 0 recovered modules, and 0 Electron IPC/window findings on inline FunctionExpression IIFE and variable-declared bootstraps.
  • isCanonicalGetter in javascriptBundledRequireOrigin.ts only admitted single-expression conditional arrows, and semanticBundledRequireOrigin did not follow stable module-binding aliases into destructuring/member reads or two-step .n(moduleAlias) calls.

Expected behavior:

  • Standalone inline named FunctionExpression loader IIFEs (in expression statements, variable declarators, assignments, and return statements) and unmutated variable-declared loaders recover bundler registrations, entry module edges, and external require(...) origins whenever the loader, module table, and cache satisfy all existing bootstrap integrity invariants.
  • Canonical block-body __webpack_require__.n getters (multi-statement and comma-sequence return forms) and stable local module-binding aliases preserve CommonJS external identity without admitting uncalled getters or mutated bindings.

Change and scope

Follow the contribution scope.

  • Extend src/domain/javascript/javascriptBootstrap.ts (javascriptBootstrapAt) to recognize unmutated inline named FunctionExpression loader IIFEs in the bootstrap body (outside nested functions) and unmutated variable-declared function/arrow loaders initialized before top-level use, recording loaderSelfBindingIds and inlineCall while verifying single non-assignment definitions and zero writes.
  • Generalize src/domain/javascript/javascriptBootstrapIntegrity.ts (proveJavaScriptBootstrapIntegrity) from t.FunctionDeclaration to Bootstrap["loader"], tracking loaderSelfBindingIds in tracked loader references and enforcing read-only containment (identifierRole === "read"), unconditional single dispatch (m[id](...) or m[id].call(...), including SequenceExpression return tails), and cache/table confinement. Any reassignment, shadowing, unproven slot write, or mismatched third factory argument continues to reject recovery.
  • Update src/domain/javascript/javascriptStaticAnalysisBundler.ts (inspectBundlerBootstrap) so inline bootstrap calls record their entry module key on the recovered bundler_registrations entry.
  • Update src/domain/javascript/javascriptBundledRequireOrigin.ts to:
    • admit canonical arrow and FunctionExpression block-body .n getters (return <cond>, var g = <cond>; return g;, var g = <cond>; r.d(g, { a: g }); return g;, and var g = <cond>; return r.d(g, { a: g }), g; including shorthand { a }), verifying single definitions, zero writes/member writes on the module parameter and local getter binding, exact <loader>.d descriptor shape, and installation before entry dispatch (including top-level SequenceExpression statements and inline bootstrap IIFEs);
    • resolve stable local aliases of bundled external module calls (const electron_1 = r(91288); const { ipcRenderer } = electron_1;, member aliases, and two-step var e0 = r(91288); var d0 = r.n(e0); d0()...) within SEMANTIC_ALIAS_SELECTION_LIMIT and opaque-effect checks while proving definite initialization before same-activation and deferred hoisted-function reads (semanticStableBindingInitializedBeforeRead), indexing member writes across captured reassigned bindings in indexJavaScriptElectronIdentitySteps, and rejecting uncalled .n getters.
  • Intentionally out of scope: cross-file chunk assembly changes, non-canonical custom interop helpers, or dynamic/mutated module tables.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Static JavaScript bundler bootstrap recognition (src/domain/javascript/javascriptBootstrap.ts), bootstrap integrity proof (src/domain/javascript/javascriptBootstrapIntegrity.ts), bundler entry inspection (src/domain/javascript/javascriptStaticAnalysisBundler.ts), and bundled external require origin recovery (src/domain/javascript/javascriptBundledRequireOrigin.ts), consumed by static Electron and JavaScript application graph reconstruction.
  • Contribution scope fit and linked maintainer decision: Ordinary static analysis bug fix within existing JavaScript/Electron boundaries; maintainer scope decision not applicable.
  • CLI and MCP/tool-catalog contract: None; existing schemas, CLI flags, and MCP tool signatures are unchanged.
  • Provider, bridge, target-format, or platform compatibility: Improves static coverage of SWC/Terser-minified Rspack and Webpack 5 standalone bundles across all platforms without executing target code.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves exact webpack-bootstrap chunk/module node provenance, bundler-entry-module load edges, and require resolution provenance on recovered external calls.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Not applicable; purely static AST analysis over existing artifact files.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): None.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

Evidence is executed via unit and filesystem boundary test suites (including node:vm runtime parity checks on synthetic bundles).

  • Tests added or updated:
    • src/domain/javascript/javascriptRspackBootstrapIdentity.test.ts (33 tests): covers declarator, assignment (.call + SequenceExpression return), expression-statement, and return-statement inline named FunctionExpression IIFEs with node:vm parity; const arrow and var FunctionExpression loaders (including uncomputed r module-table keys and meta.r member properties before the loader declaration); multi-statement and comma-sequence block-body __webpack_require__.n getters (including { a } shorthand and top-level SequenceExpression installation); destructured, member-alias, and hoisted deferred-function Electron module reads; uncalled getter and overwritten member exclusions; and 17 tamper/shadowing/mutation/pre-init soundness rejections.
    • tests/boundary/filesystem/javascript-applications/javascriptBundlerAdapters.test.ts (1 test added, 3 total): verifies end-to-end reconstructJavaScriptFixture recovery of webpack-bootstrap@0, entry/external module nodes, bundler-entry-module load edge, electron_summary.ipc, and ipc-channel graph nodes from a standalone Rspack inline FunctionExpression preload bundle.
  • Base reproduction or other evidence: On base revision 88cf49803, analyzeJavaScriptStaticSource on the inline FunctionExpression IIFE fixture returns bundler_registrations: [], electron.browser_windows: [], and electron.ipc: [], and isCanonicalGetter returns false on block-body .n getters.
  • User-visible CLI/MCP output (if applicable): analyze_javascript_application and project_electron_application_graph now populate bundler_registrations, javascript-chunk/javascript-module nodes, and Electron window/IPC findings for standalone Rspack/SWC inline-IIFE bundles instead of reporting zero registrations and zero IPC channels.
  • Remaining proof gaps: None within static single-file standalone Webpack/Rspack bootstrap recovery; multi-file split-chunk runtimes remain covered by existing chunk-push adapters.

Boundary regressions covered: JavaScript bundler adapter reconstruction (tests/boundary/filesystem/javascript-applications/javascriptBundlerAdapters.test.ts) and Electron static boundary reconstruction (tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts). Lifecycle regressions are not applicable because no persistent sessions, child processes, or external bridges are modified.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx oxfmt . && npx oxfmt --check . — passed (All matched files use the correct format across 7,232 files)
  • npm run test:prepare && npm run build:cached && npm run check:fast — passed (typecheck, lint, verify:module-boundaries, and catalog builds clean)
  • Multi-Node Vitest matrix (npx vitest run src/domain/javascript/javascriptRspackBootstrapIdentity.test.ts src/domain/javascript/electronBundledRequireIdentity.test.ts src/domain/javascript/electronModuleInterop.test.ts src/domain/javascript/javascriptBundlerRegistrationIdentity.test.ts tests/boundary/filesystem/javascript-applications/javascriptBundlerAdapters.test.ts tests/boundary/filesystem/javascript-applications/electronApplicationAnalysis.test.ts):
    • Node v22.23.4 (darwin-arm64) — passed (6 passed test files, 353 passed tests)
    • Node v24.22.2 (darwin-arm64) — passed (6 passed test files, 353 passed tests)
    • Node v26.13.0 (darwin-arm64) — passed (6 passed test files, 353 passed tests)
  • npm run verify:architecture-guards && npm run verify:test-discovery && npm run scan:todos — passed (2,548 source files, 3,197 test files, 0 tech-debt markers)
  • npm run jscpd && npm run knip && npm run knip:production && npm run metadata:check && npm run mcp-catalog:check && npm run docs:check — passed (0 Knip issues; 3.45% duplicated lines; readmeConsistency.test.ts 9/9 passed)
  • npm run lint:typed — passed (6,676 files, 0 errors)
  • End-to-end CLI (node scripts/rea.mjs analyze-javascript-application <dir> --format json) and stdio MCP (analyze_javascript_application) probe against a synthetic Electron application with a standalone Rspack inline FunctionExpression IIFE preload bundle — passed (browser_windows: 1, preload_entrypoints: 1, ipc.operations: 1, ipc.renderer_transmissions: 1, electron_semantics: "recovered")

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Not applicable; pure TypeScript static AST analysis in src/domain/javascript/.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Static AST traversal only; never executes analyzed bundle code, preserves SEMANTIC_ALIAS_SELECTION_LIMIT cycle/depth bounds, and retains strict fail-closed rejection whenever bootstrap table, cache, loader self-binding, or .n getter bindings are mutated, shadowed, or escaped.

Author readiness

Human owner: @saariuslystoned

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T00:18:34.325306Z 760406e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 2/5

[Medium impact] The PR changes results from static JavaScript and Electron application analysis.

The PR should not merge until the three missed method-replacement paths are fixed.

Findings

  1. P1 Computed writes lose earlier keys ▶
  2. P1 Async mapper aliases disappear ▶
  3. P1 Descriptor getters hide replacements ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptSemanticAnalysis.ts:3514-3516
`enqueueFromEntriesSources` keeps only the last matching entry, even when the selected key is unknown. For `const a = Object.fromEntries([["ipc", e.ipcRenderer], ["other", {}]]); a[globalThis.key].send = () => {};`, both keys match the unknown selection. The second entry discards the Electron alias.

If `globalThis.key` is `"ipc"`, the analyzer misses the replacement and can report a later `e.ipcRenderer.send("FALSE")` as real IPC. Apply last-write-wins separately for each actual key. An unknown selection must retain all surviving keys.

### Issue 2
src/domain/javascript/javascriptSemanticAnalysis.ts:3631-3640
`enqueueArrayFromAsyncSources` follows mapper return expressions without binding the mapper's parameters to the input elements. For `const a = await Array.fromAsync([e], x => x); a[0].ipcRenderer.send = () => {};`, the search reaches `x` with no call frame and never reaches `e`.

The mapper is fully resolved, so the fallback does not run. A later Electron call can be reported even though its method was replaced. Carry the mapper's arguments and receiver through the shared call-frame path, as the `Array.from` branch does.

### Issue 3
src/domain/javascript/javascriptSemanticAnalysis.ts:3835-3839
The `Object.create` and `Object.defineProperties` paths follow descriptor `value` fields but ignore getter results. For `const a = Object.create(null, { ipc: { get: () => e.ipcRenderer } }); a.ipc.send = () => {};`, the search looks for `ipc.value`, finds nothing, and misses the Electron method replacement. The same happens with `Object.defineProperties({}, ...)`.

A later call can be reported as IPC even though it invokes the replacement. Reuse the descriptor path that follows both values and getter returns instead of treating these descriptors as value-only.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR recovers inline and variable-declared bundler loaders, block-body interop getters, and more Electron aliases.

  • Standalone bundle analysis recovers folded loader calls.
  • Bundled Electron imports keep their identity through Rspack getters and aliases.
  • Electron findings stay tied to modules through aliases and deferred reads.
  • Import and test-only edits leave behavior unchanged.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Bundler bootstrap] --> B[Prove loader and module origins]
  B --> C[Recover Electron aliases]
  C --> D[Trace writes through calls and containers]
  D --> E[Exclude replaced methods]
  E --> F[Report Electron IPC]
Loading

Reviews (12) · Last reviewed commit: "fix(javascript): keep the last Object.fr..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 087aa60afa

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e2e9610a9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44b356e0b6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80da36e603

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89a7105ea0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20cd9e9653

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5eaba3a88

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ssigned params, and filter generator completion returns

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e1beb2ce9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f26d4483dc

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25c8d8bba1

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7cc3fa8984

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d47d0fc82e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b52810f0e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c296587eb2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03273bb93f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45b1218200

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3488 to +3491
ctx.pending.push({
...current,
node: vNode,
suffix: remaining,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect duplicate-key overwrite order in Object.fromEntries

For CommonJS code with e = require("electron"), const a = Object.fromEntries([["ipc", e.ipcRenderer], ["ipc", {}]]); a.ipc.send = () => {}; e.ipcRenderer.send("REAL"); only modifies the fresh object from the last entry. This loop nevertheless queues both matching values, attributing the write to Electron's original send method and suppressing the genuine IPC finding. Represent the last surviving entry in the owning result projection instead of retaining every matching value.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

Comment on lines +3983 to +3987
if (receiver !== undefined && t.isExpression(receiver))
ctx.pending.push({
...current,
node: receiver,
suffix: [propKey, ...current.suffix],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Reflect.get receivers out of data-property result identities

With e = require("electron"), const a = Reflect.get({ x: {} }, "x", { x: e }); a.ipcRenderer = {}; e.ipcRenderer.send("REAL"); only modifies the fresh target value: a data-property read ignores the receiver. This branch unconditionally forwards receiver[propKey] as another result identity, so it follows e, records an Electron namespace overwrite, and suppresses the genuine IPC finding. Resolve the target descriptor through the property/getter owner and use the receiver only as getter this, rather than as an alternate property source.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +3594 to +3598
const mapped = ctx.returnQueries.awaited(mapFn, undefined, current.callFrame);
for (const ref of mapped.references)
ctx.pending.push({
...current,
node: ref.node,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply mapper invocation facts to Array.fromAsync results

Inside an async CommonJS function with e = require("electron"), const a = await Array.fromAsync([{}], (x = e) => x); a[0].ipcRenderer = {}; e.ipcRenderer.send("REAL"); never uses the mapper default. Unlike the synchronous Array.from path, this new async branch queues the returned parameter without constructing the mapper frame or marking inactive defaults. Following x therefore leaves its default e eligible, records an unrelated Electron overwrite, and suppresses the real IPC observation. Consume the shared mapper invocation/default-activation facts here as well.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +4179 to +4182
for (const gen of gens) {
const list = collector.byGenerator.get(gen) ?? [];
list.push(firstArg);
collector.byGenerator.set(gen, list);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude iterator-start arguments from generator resume sources

For function* g() { const a = yield {}; a.ipcRenderer = {}; }, the sequence const it = g(); it.next(e); it.next({}); e.ipcRenderer.send("REAL");, with e bound to Electron, cannot mutate Electron because the argument to the initial next() is ignored. The new collector nevertheless adds that argument to the generator's resume sources, attributing the yield-expression result to e and suppressing the genuine IPC finding. Represent iterator startup separately from suspended-yield resumes before transferring argument identities.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

saariuslystoned and others added 2 commits November 10, 2026 18:59
…ck-iife-bootstrap

Keep main's alias-selection budget and the branch's candidate/frame projection for returned references.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d key

Main replaced the fixed alias-selection cap with caller semantic precision, so the merged rspack projection uses that budget. A later static key overwrites earlier fromEntries values and no longer suppresses a real IPC send.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 760406ede5

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

t.isExpression(proto) &&
!t.isNullLiteral(unwrapJavaScriptExpression(proto).node)
)
ctx.pending.push({ ...current, node: proto, capturedSelections });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor own properties before following prototype sources

For CommonJS input with e = require("electron"), const a = Object.create(e, { ipcRenderer: { value: {} } }); a.ipcRenderer.send = () => {}; e.ipcRenderer.send("REAL"); only modifies the fresh own child. This branch nevertheless queues e with the ipcRenderer suffix despite the shadowing descriptor, causing write coverage to mark Electron's send as replaced and suppress the genuine IPC observation. Object.setPrototypeOf({ ipcRenderer: {} }, e) reaches the same unconditional prototype forwarding in enqueueTargetArgumentIntrinsicSources. Resolve the selected own slot before consulting the prototype instead of retaining both identities.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +4508 to +4512
const remaining = suffix.slice(targetMembers.length);
for (const rhs of assignmentValueSources(cur))
ctx.pending.push({
...current,
node: rhs,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude superseded assignments from constructor result slots

When a constructor definitely replaces a field before returning, such as class Box { constructor(ipc) { this.ipc = ipc; this.ipc = {}; } }, the sequence const a = new Box(e.ipcRenderer); a.ipc.send = () => {}; e.ipcRenderer.send("REAL"); with e = require("electron") only modifies a fresh object. This walk enqueues every matching assignment's RHS, including the superseded ipc, so it falsely records an Electron send overwrite and suppresses the genuine IPC observation. Derive the selected instance slot at constructor completion, including ordered replacements, rather than unioning every store found in the constructor body.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +3721 to +3723
node: target,
suffix: [propKey, ...remaining],
readAt: current.readAt ?? callNode,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture descriptor values at the intrinsic call boundary

For CommonJS input with e = require("electron"), const box = { x: {} }; const desc = Object.getOwnPropertyDescriptor(box, "x"); box.x = e; desc.value.ipcRenderer = {}; e.ipcRenderer.send("REAL"); leaves Electron unchanged because the descriptor retains the original fresh object. This new descriptor projection reuses the consumer's readAt without adding a call-time capture, so semanticProjectedSourceFactsAtRead follows the later box.x = e and incorrectly invalidates the genuine IPC observation. The plural property-descriptors branch has the same omission. Preserve the copied value's snapshot boundary using capturedSelections, as the Object.values path already does, rather than treating the descriptor as a live property lookup.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Closing this. It grew to about 10k lines over many review rounds and still has open automated findings, so it is not a reviewable fix in this form. If Rspack/IIFE bootstrap recovery is still wanted, I'll come back with a small, focused PR. Thanks for the reviews. ☁️

@morluto morluto added the bug Something isn't working label Nov 22, 2026
Comment on lines +3514 to +3516
if (kStatic !== null && keyMatches(kStatic)) {
definiteValue = vNode;
maybeValues.length = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Computed writes lose earlier keys

enqueueFromEntriesSources keeps only the last matching entry, even when the selected key is unknown. For const a = Object.fromEntries([["ipc", e.ipcRenderer], ["other", {}]]); a[globalThis.key].send = () => {};, both keys match the unknown selection. The second entry discards the Electron alias.

If globalThis.key is "ipc", the analyzer misses the replacement and can report a later e.ipcRenderer.send("FALSE") as real IPC. Apply last-write-wins separately for each actual key. An unknown selection must retain all surviving keys.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticAnalysis.ts
Line: 3514-3516

Comment:
**Computed writes lose earlier keys**

`enqueueFromEntriesSources` keeps only the last matching entry, even when the selected key is unknown. For `const a = Object.fromEntries([["ipc", e.ipcRenderer], ["other", {}]]); a[globalThis.key].send = () => {};`, both keys match the unknown selection. The second entry discards the Electron alias.

If `globalThis.key` is `"ipc"`, the analyzer misses the replacement and can report a later `e.ipcRenderer.send("FALSE")` as real IPC. Apply last-write-wins separately for each actual key. An unknown selection must retain all surviving keys.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +3631 to +3640
const mapped = ctx.returnQueries.awaited(mapFn, undefined, current.callFrame);
for (const ref of mapped.references)
ctx.pending.push({
...current,
node: ref.node,
suffix: [...ref.projection, ...elementSuffix],
readAt: current.readAt ?? callNode,
...(filteredAwaitDepths.length === 0
? { awaitDepths: undefined }
: { awaitDepths: filteredAwaitDepths }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Async mapper aliases disappear

enqueueArrayFromAsyncSources follows mapper return expressions without binding the mapper's parameters to the input elements. For const a = await Array.fromAsync([e], x => x); a[0].ipcRenderer.send = () => {};, the search reaches x with no call frame and never reaches e.

The mapper is fully resolved, so the fallback does not run. A later Electron call can be reported even though its method was replaced. Carry the mapper's arguments and receiver through the shared call-frame path, as the Array.from branch does.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticAnalysis.ts
Line: 3631-3640

Comment:
**Async mapper aliases disappear**

`enqueueArrayFromAsyncSources` follows mapper return expressions without binding the mapper's parameters to the input elements. For `const a = await Array.fromAsync([e], x => x); a[0].ipcRenderer.send = () => {};`, the search reaches `x` with no call frame and never reaches `e`.

The mapper is fully resolved, so the fallback does not run. A later Electron call can be reported even though its method was replaced. Carry the mapper's arguments and receiver through the shared call-frame path, as the `Array.from` branch does.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +3835 to +3839
ctx.pending.push({
...current,
node: descriptors,
suffix: [current.suffix[0]!, "value", ...current.suffix.slice(1)],
readAt: current.readAt ?? callNode,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Descriptor getters hide replacements

The Object.create and Object.defineProperties paths follow descriptor value fields but ignore getter results. For const a = Object.create(null, { ipc: { get: () => e.ipcRenderer } }); a.ipc.send = () => {};, the search looks for ipc.value, finds nothing, and misses the Electron method replacement. The same happens with Object.defineProperties({}, ...).

A later call can be reported as IPC even though it invokes the replacement. Reuse the descriptor path that follows both values and getter returns instead of treating these descriptors as value-only.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptSemanticAnalysis.ts
Line: 3835-3839

Comment:
**Descriptor getters hide replacements**

The `Object.create` and `Object.defineProperties` paths follow descriptor `value` fields but ignore getter results. For `const a = Object.create(null, { ipc: { get: () => e.ipcRenderer } }); a.ipc.send = () => {};`, the search looks for `ipc.value`, finds nothing, and misses the Electron method replacement. The same happens with `Object.defineProperties({}, ...)`.

A later call can be reported as IPC even though it invokes the replacement. Reuse the descriptor path that follows both values and getter returns instead of treating these descriptors as value-only.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants