Skip to content

fix(javascript): exclude overwritten Electron API identities - #1664

Merged
morluto merged 5 commits into
mainfrom
fix/electron-overwritten-namespace-1656
Oct 11, 2026
Merged

morluto merged 5 commits into
mainfrom
fix/electron-overwritten-namespace-1656

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Visible writes through Electron namespace aliases can leave an ordinary replacement object reported as a real IPC handler. Index direct/destructuring assignment, loop, update and delete targets with the existing property-path coverage trie and exclude affected call identities, including direct require("electron") writes and unknown write keys. Preserve unrelated members and literal key boundaries.

Forward an explicit static identity limitation into public application results, including empty findings. Add compiled CLI/stdio MCP controls for valid aliases and unavailable identities, preserving source-range Evidence and IPC pairing. This inspects inert source; it does not execute Electron or establish runtime side effects. Follow-up to #1656.

Also format the existing real-Electron verifier to clear an inherited format gate failure. Fix existing Electron fixtures to import their API while retaining range assertions. Give only the full-catalog runtime probe a 30-second test budget: two parallel-CI runs exhausted 15 seconds; actual single-CPU runs take about 8–9 seconds. Its complete-catalog, lifecycle and fatal-record assertions remain intact.

Validation (349 focused tests across nine files passed):

  • npm run test:focused -- tests/acceptance/applications/applicationWorkflowCli.test.ts src/domain/javascript/javascriptSemanticAnalysisSteps.test.ts src/domain/javascript/electronStaticAnalysisOptions.test.ts src/domain/javascript/javascriptStaticPathResolution.test.ts src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts
  • npm run test:focused -- src/application/javascript/JavaScriptArtifactPathResolution.test.ts (59 passed after fixing its missing Electron import; assertions retained)
  • npm run test:focused -- tests/acceptance/applications/electronPreloadOverridesCli.test.ts tests/acceptance/applications/runtime.test.ts (CLI/MCP preload assertions retained; runtime catalog passed twice locally; two macOS-only local skips)
  • npm run test:focused -- tests/composition/javascript-applications/electronOptionKeys.test.ts (15 passed; API imports corrected, assertions retained)
  • npm run check:ci
  • npm run docs:check
  • Native Qwen0.25.0, Pi1.1.0, Hermes ordinary/sticky-profile runs at28f2b3d5: all170 tools, actual stdio MCP analysis, skill loading, full Evidence, Qwen result-artifact read, verified empty owned process lineages. Deterministic loopback model endpoint; no live model-provider claim.

Host: Linux x64, Node 24.18.0. No real Electron, Hopper, Ghidra, or GUI verification claimed by this follow-up.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maintainer self-review of 28f2b3d: visible writes now invalidate the affected Electron identity through direct/aliased namespaces, destructuring and loops, updates, and deletes. Exact property segments preserve unrelated members and reject dotted lookalikes. The coverage limitation reaches public CLI/MCP results even with empty findings.

271 focused regressions, check:ci, and docs:check passed. Native Qwen/Pi/Hermes ordinary and sticky-profile cases passed with all 170 tools, real MCP analysis/Evidence and verified empty process lineages (loopback model fixture). Final merge waits for all applicable exact-head CI checks and fresh review-thread verification.

@morluto
morluto merged commit 29cc1b8 into main Oct 11, 2026
20 checks passed
@morluto
morluto deleted the fix/electron-overwritten-namespace-1656 branch October 11, 2026 01:25

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maintainer self-review of 372ad95: Electron identity now excludes visible member writes while retaining exact paths, unrelated members, and public CLI/MCP coverage limitations. Inherited Electron fixtures retain their original range assertions; only the full-catalog runtime test receives a measured 30-second budget.

349 focused tests passed (two macOS-only local skips), plus check:ci and docs:check. Four native Qwen/Pi/Hermes runs passed again on integrated main 29cc1b8 with 170 tools, real analysis/Evidence, Qwen artifact read, and empty owned lineages. Production/runtime digests remain identical after test-only follow-ups; model endpoint was a deterministic loopback fixture. All applicable exact-head CI checks subsequently passed.

@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran this on Linux against a real open-source Electron app. It merged while I ran. Stretchly gives the same IPC results on base and on head, plus the new limitation line. When I add visible overwrites of Electron's ipcMain, the replaced handlers now drop out, as the PR says.

Edit, 11 October, 04:50 UTC: a default import is now read as Electron. That came with fe574c0 (#1673). I checked it on main in my #1673 comment.

This PR merged as 29cc1b8 (#1664) while I ran. I tested the PR head at merge, 372ad95. Every file the PR changes is the same in 29cc1b8. That head adds one test-only commit over d42d2bc.

Results

Check (head 372ad95, 9 test files, 349 pass, 2 skip) Node 22.23.1 Node 24.18.0 Node 26.11.1
Pass / skip 349 / 2 349 / 2 349 / 2

The 2 skips are the process.platform === "darwin" cases in runtime.test.ts.

Same 9 files on base d21132f (Node 24.18.0) Result
Failing tests, workflow CLI file (31 tests) 15
Fail on a wrong IPC count (the bug) 6
Fail at the new limitation check (the IPC counts checked before it matched) 9
Other 8 files pass

I copied the head versions of the 5 changed test files into the base tree. Base has no javascriptElectronMemberWrites.js, so I put the limitation string into that test file by hand.

Real app: Stretchly 1.22.1 (BSD-2-Clause), app/ folder, CLI and stdio MCP

What I counted Base d21132f Head 372ad95
Main-process handlers (on 18, handle 12) 30 30
Handler nodes / handles edges 36 / 36 36 / 36
Renderer sends / invokes 31 / 27 31 / 27
Paired / unpaired renderer sends 27 / 0 27 / 0
Source ranges the reference same as d21132f
New limitation line no yes
MCP result (through export_evidence_bundle) equals CLI result yes yes

With every limitations field removed, the whole result differs in 3 values only: the graph ids. Those are hashes that change when the limitation list changes.

Overwrite cases: Stretchly main.js plus one added line. I added it on the last import line, so no line moves. I only parsed these files. I never ran them.

Added statement Base on / handle Head on / handle
ipcMain.handle = () => {} 18 / 12 18 / 0
({ handle: ipcMain.handle } = {...}) 18 / 12 18 / 0
for (ipcMain.handle of [...]) {} 18 / 12 18 / 0
ipcMain.handle++ 18 / 12 18 / 0
delete ipcMain.on 18 / 12 0 / 12
ipcMain[k] = ... (k unknown) 18 / 12 0 / 0
import * as ns from 'electron'; ns.ipcMain = {...} 18 / 12 0 / 0
Control: ipcMain.unrelated = 1 18 / 12 18 / 12
Control: electron['ipcMain.handle'] = ... (dotted key) 18 / 12 18 / 12
Control: anApp.handle = ... (other API) 18 / 12 18 / 12

Base kept all 30 handlers in every row. Head also printed the limitation in every row, including the controls. Each overwrite drops the whole affected group, not only the line that was written. After ipcMain.handle = ..., all 12 handle handlers go, and 13 renderer sends lose their pair.

Also seen

  • The real app is too big for MCP. The result passes the 10 MiB stdio limit on base and on head, even for main.js alone. I got the same result through export_evidence_bundle, and it equals the CLI result.
  • A default import (import electron from "electron"; electron.ipcMain = ...) is not read as an Electron namespace on base or on head. So no handler is found there, and nothing is misreported.
  • Small CommonJS fixtures, my own code: a require("electron") namespace write, a direct require("electron").ipcMain.handle = ... write, and an unknown key write. Base keeps the handle and the on handler in all three. Head drops the one or two that the write reaches.

Not run

  • One part of npm run check: verify:module-boundaries. It needs git ls-files, and these trees have no git. The rest ran alone and passed. Those are the type check, the linter, the format check, knip, the metadata check and the guard script. Oxlint gave warnings only.
  • docs:check, npm run check:ci and the full test suite.
  • Real Electron, a GUI, Hopper, Ghidra, and the Qwen, Pi and Hermes runs in the PR body.
  • Windows and macOS. The 2 macOS-only tests skipped.
  • I did not install Stretchly's packages. Its other imports stay unresolved.
The new limitation line
Electron API identity follows proven lexical module aliases. Reassigned bindings, dynamic selections, and visibly overwritten namespace members are unresolved; missing findings do not establish absence. Arbitrary call side effects and runtime registration are not evaluated.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 372ad95
  • Base: d21132f
  • Merge: 29cc1b8
  • Other: the app is Stretchly 1.22.1 (BSD-2-Clause). I used the source of tag v1.22.1. I never installed or ran it.
Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- <the 9 test files>
rea analyze-javascript-application <stretchly>/app --json

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working provider: electron Analysis provider / engine: electron

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants