Repository navigation
fix(electron): reject active scenario capture when inspect fuse is disabled (#3453) - #3605
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; all previous findings are addressed and no new blocking issue was found. SummaryAdds a fuse check before active Electron capture launches the target.
All three previous findings are addressed. No new actionable issue or security concern was established. Available local history showed no superseding change. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Capture request] --> B[Find executable or macOS framework]
B --> C[Read fuses within startup deadline]
C --> D{Inspect fuse state}
D -->|Disabled or removed| E[Return unsupported target]
D -->|Enabled or unknown| F[Capture process baseline]
F --> G[Launch original executable]
C -->|Deadline reached| H[Return timeout without launch]
Reviews (2) · Last reviewed commit: "fix(electron): resolve macOS framework b..." · Reviewed by Greptile |
…dline on fuse preflight (morluto#3453)
rahul05ranjan
left a comment
There was a problem hiding this comment.
Verified the preflight is at the right layer: PlaywrightElectronActiveProvider is the only implementation of the ElectronActiveObservationPort (wired once in src/composition/electronScenario.ts), and the check runs before both captureBaseline and launch(), so no active-capture entry point skips it. The passive CDP path (inspect_electron_page) is correctly untouched.
Ran src/browser/PlaywrightElectronActiveFuses.test.ts on arm64 Linux: 9/9 pass, including the ELF/PE rejection cases, the no-sentinel fail-open, and the universal-binary slice selection (arm64 slice enabled resolves on an arm64 host). The provider integration test also asserts launchSpy is never invoked on a fuse-disabled binary, so the fast-fail happens before any process spawn — no orphan process or supervisor tracking.
Two things I'd think about:
-
The .app fallback in appBundleDirectoryOf: when resolveElectronFuseTarget throws (e.g. the app ships a renamed framework instead of Electron Framework.framework), the catch silently falls back to reading the launcher binary, which typically has no sentinel — the preflight passes and the user is back to the original 60-second hang. Missing/unknown fuse state failing open is fine and documented, but a resolver failure is a different failure mode: the fuse wire likely exists and we just couldn't reach it. Should a resolver failure on a confirmed bundle at least be distinguishable from a genuinely unknown state?
-
The deadline wrapping: runWithExecutionLimits races the preflight against startupDeadline but doesn't cancel the underlying read, so on timeout the fuse scan (which also computes a full sha256 of a possibly ~1 GiB file per the reader's admission bounds) keeps running in the background after capture has already failed, and the shared deadline shortens the effective launch timeout for slow reads. Not a blocker — but the new tests cover the rejection and fail-open paths well, and there's nothing covering the deadline-expiry path.
|
@rahul05ranjan Appreciate you running the test suite on arm64 Linux and verifying the layer boundaries! Regarding the two points:
|
baron
left a comment
There was a problem hiding this comment.
Reviewed exact head 1369fcdf1ce8551893c6c0f451d0214f551affec against fresh origin/main, the fuse reader/path producer, active provider consumer, tests, documentation and existing review threads.
This is a routine refusal fix within existing capture authority, not a new execution/injection capability requiring a separate advance scope decision. The owner’s three readiness declarations are complete. The preflight consumes parsed fuse facts, resolves the normal macOS framework layout while leaving Playwright’s executable selection unchanged, and rejects before baseline capture/launch. Missing/unparseable fuse state remains unknown rather than being misrepresented as enabled. Passive inspection is unchanged.
The previous macOS-path, startup-deadline and cancellation-test findings have concrete fixes. I also accounted for the still-discussed limitations rather than treating them as solved: resolver failure intentionally falls back to unknown/normal launch, and the execution-limit race does not cancel its bounded underlying file scan on timeout. I agree these are nonblocking here: unknown is not a refusal claim, and deadline expiry prevents target launch; the latter resource/cancellation improvement belongs at the shared execution-limit owner rather than as a duplicate downstream timeout mechanism. No new blocking source/design issue was established.
Local verification on macOS arm64 with Node 24.19.0 (repository pins 24.18.0): all 9 fuse tests and the new provider no-launch regression passed. The combined focused run was 13 passed / 3 failed: three pre-existing provider launch/partial-capture cases failed before reaching their expected mocked path. I reran the provider file at the PR merge-base and observed the same three failures (3 passed / 3 failed); this environment does not independently establish those provider paths, and I do not claim a fully passing local suite or real Electron reproduction. Dependencies were independently installed in an isolated temporary checkout because its lock digest differs from the allowed shared-dependency digest.
Immediately before submission, the head remained unchanged and MERGEABLE. All 34 repository check/status contexts are successful or intentionally skipped, with no pending/failing context, including all five shards, browser, portable aggregation, CI required and PR readiness. Approval is based on the source/design review and that current-head CI, with the local limitations above.
Summary
Fixes #3453. In active Electron scenario capture (
capture_electron_scenario), Playwright attaches to the target Electron main process using Node CLI inspect arguments (--inspect=0or--remote-debugging-port=0). When an Electron executable has theEnableNodeCliInspectArgumentsfuse explicitly disabled or removed, the runtime silently ignores inspection flags, causing Playwright to hang for the full 60-second startup deadline before timing out.This PR adds a pre-flight fuse inspection before process launch. If the executable explicitly disables or removes
EnableNodeCliInspectArguments,capture()immediately fails fast with a typedAnalysisUnsupportedTargetError("unsupported_target") without spawning processes or waiting for the startup deadline.Problem and expected behavior
capture_electron_scenarioon an Electron target binary where theEnableNodeCliInspectArgumentsfuse is disabled (e.g. Obsidian or production Electron distributions).PlaywrightElectronActiveProviderattempts to launch the binary with inspect flags. Playwright hangs for 60 seconds awaiting the DevTools connection, ultimately throwing a generic startup timeout error.PlaywrightElectronActiveProviderreads the binary's fuses prior to launch and returns an immediateAnalysisUnsupportedTargetErroradvising the caller to use passive CDP inspection (inspect_electron_page) or run against an unrestricted development binary. If the fuse state is unknown, missing, or unparseable, launch proceeds normally.Change and scope
assertNodeCliInspectArgumentsSupportedhelper insrc/browser/PlaywrightElectronActiveFuses.tsutilizing existingreadElectronFuseImage.PlaywrightElectronActiveProvider.capture()before process baseline capture and launch.readFuseImageintoPlaywrightElectronActiveProviderfor isolated unit testing.docs/electron-observation.md.Contribution scope: Not applicable (ordinary fix within existing provider boundaries).
Contract and boundary impact
src/browser/PlaywrightElectronActiveProvider.ts(provider pre-launch stage).AnalysisUnsupportedTargetError.docs/public/product-catalog.json), package, or installation impact: None.Expected effects:
Evidence and regression coverage
src/browser/PlaywrightElectronActiveFuses.test.ts(8 tests covering disabled, enabled, unknown/missing wire, unparseable, Mach-O universal, Windows PE, Linux ELF, and AbortSignal cancellation).src/browser/PlaywrightElectronActiveProvider.test.ts(rejects active capture before launch when EnableNodeCliInspectArguments fuse is disabled).eab789aed, calling capture on a fuse-disabled binary invokedlaunch()and timed out after 60s. With this change,launch()is never called andAnalysisUnsupportedTargetErroris returned immediately.AnalysisUnsupportedTargetError: Target binary disables the EnableNodeCliInspectArguments fuse; Node CLI inspector arguments are ignored and active scenario capture cannot attach.For evidence-bearing changes:
Validation performed
npm run check:fast— 2/2 tasks passed (typecheck & lint clean).npm run verify:module-boundaries— 1887 files checked, 0 violations.npm run test:focused -- src/browser/PlaywrightElectronActiveFuses.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts— 15/15 tests passed.npm run verify:test-discovery— 1280 files discovered exactly once.npm run docs:check— 6/6 tasks passed (docs & catalogs consistent).npm run build:cached— 3/3 tasks passed (runtime bundle compiled cleanly).Compatibility, safety, and release
Author readiness
Human owner: @HarsH-1877
Before merge
type(scope): outcome.