Skip to content

refactor(browser): take the host in Chromium, Electron and capture adapters - #11130

Merged
morluto merged 9 commits into
mainfrom
refactor/host-platform-browser
Nov 15, 2026
Merged

morluto merged 9 commits into
mainfrom
refactor/host-platform-browser

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

HostPlatform migration (W8), src/browser: Chromium, Electron and capture adapters take the host instead of reading process.platform / process.arch, and their tests inject the platform instead of redefining it. Stacked on #11124.

Problem and expected behavior

src/browser read the host in 10 places. Six tests redefined process.platform to reach Android, Linux or Windows branches; once a module takes its host from HostPlatform, such a test keeps passing without exercising the branch (the failure mode the test-host-platform-stub guard from #11086 counts).

Change and scope

  • Required platform: chromiumSandboxEnabled(environment, platform), safeElectronEnvironment(environment, runId, platform).
  • Optional platform seam, default HOST_PLATFORM.platform: openPlaywrightScenarioBrowser options (platform, used for the Termux environment, the sandbox decision and --single-process), NativeModuleResolver (third constructor argument), PlaywrightElectronActiveProvider (fourth), ElectronCaptureCleanup (fourth), MitmproxyCaptureAdapter (second, carried through snapshotConfiguration), LocalWebScriptArtifacts (third).
  • ElectronProcessCleanup gains systemElectronCleanupHost(platform), the one owner of its default process operations, used by ElectronCaptureCleanup with its platform.
  • PlaywrightElectronActiveFuses reads the host architecture from HOST_PLATFORM (it selects the slice this host launches).
  • Tests switched to injection: ElectronCaptureCleanup, PlaywrightElectronActiveProvider, PlaywrightScenarioBrowser, NativeModuleResolver, historicalCaptureDecoder (the spy calls command on an adapter built with "linux"), webScriptManifestPaths.
  • Baselines: -8 process.platform, -2 process.arch, -14 test stubs.
  • Not included: tests/boundary/filesystem/webScriptExport.test.ts still redefines process.platform for a ChangeTime setting read outside src/browser.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/platform/HostPlatform; systemElectronCleanupHost owns Electron cleanup's default host operations.
  • Contribution scope fit and linked maintainer decision: W8 plan (pure helpers required; host operations and optional seams default to HOST_PLATFORM).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: unchanged on the running host.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Electron cleanup follows the same Windows lineage rule, now from the provider's platform.
  • 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

  • Tests added or updated: the six tests above now pass the platform explicitly; their assertions are unchanged.
  • Base reproduction or other evidence: source-derived; values are unchanged on the running host.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: no Android, Linux or Windows host run.

Validation performed

  • npx tsc --noEmit -p . — passed.
  • npx oxlint src/browser plus the two changed boundary tests — no errors (existing warnings only).
  • node scripts/verify/architecture-guards.mjs --shrink-baselines — passed; baselines lowered.
  • npm run test:focused -- ElectronCaptureCleanup, PlaywrightElectronActiveProvider, PlaywrightScenarioBrowser, NativeModuleResolver, ElectronProcessCleanup, PlaywrightElectronActiveFuses, WebArtifactCleanup, tests/boundary/browser/historicalCaptureDecoder.test.ts, tests/boundary/filesystem/webScriptManifestPaths.test.ts — 9 files, 182 passed, 2 skipped.
  • Pre-push hook (check:fast) — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none (internal signatures).
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: not applicable.

Author readiness

Human owner:

  • 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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T13:02:20.561917Z
We couldn’t complete this review. Comment @codex review to try again.
c810fad PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto force-pushed the refactor/host-platform-application-rest branch from d1edca4 to 8ac7bc0 Compare November 15, 2026 13:06
@morluto
morluto force-pushed the refactor/host-platform-browser branch from c810fad to 799490b Compare November 15, 2026 13:06
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The reviewed changes appear safe to merge, with the previous finding fully addressed.

Summary

The PR moves host choices into HostPlatform and passes them through browser adapters, providers, and server setup.

  • Host-dependent tools now use one selected host throughout each call.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[HOST_PLATFORM default] --> C[Composition]
  B[Caller-selected host] --> C
  C --> D[Provider host checks]
  C --> E[Environment rules]
  C --> F[Command and cleanup choices]
Loading

Reviews (9) · Last reviewed commit: "refactor(config): drop the unused host p..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/host-platform-application-rest branch from 8ac7bc0 to f8c59f5 Compare November 15, 2026 13:52
@morluto
morluto force-pushed the refactor/host-platform-browser branch from 799490b to 970938e Compare November 15, 2026 13:54
@morluto
morluto changed the base branch from refactor/host-platform-application-rest to main November 15, 2026 14:03
…apters

chromiumSandboxEnabled and safeElectronEnvironment take a required platform. The scenario browser, native module resolver, Electron provider and capture cleanup, mitmproxy adapter and web script artifacts take an optional platform seam (default HOST_PLATFORM); Electron fuses read the host architecture from HOST_PLATFORM. Their tests inject the platform instead of redefining process.platform. src/browser no longer reads process.platform or process.arch.
@morluto
morluto force-pushed the refactor/host-platform-browser branch from 970938e to 3dc9c78 Compare November 15, 2026 14:04
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai please review the latest commit (3dc9c78). The branch was rebased onto main after #11124 merged; the last score refers to an older head.

…und and batch launch (#11141)

* refactor(pcap): take the host platform in the packet tools, native bound and batch launch

* test(pcap): cover the selected host in batch launch and capture-host support

* refactor(apktool): take the host platform in launcher selection, version probe and decode (#11164)

* refactor(apktool): take the host platform in launcher selection, version probe and decode

* test(apktool): cover the provider's selected host in launcher selection

* refactor(hopper): give the launcher the provider's host platform

* refactor(native): inject the host into the pwntools decoders and native capability defaults (#11173)

* refactor(native): inject the host into the pwntools decoders and native capability defaults

* fix(native): give composed pwntools services the capability host and drop empty test hooks

* refactor(adb): take the host platform in binary selection and pulled file names (#11176)

* refactor(adb): take the host platform in binary selection and pulled file names

* refactor(cli): pass the resolved host platform through rea mcp add (#11179)

* refactor(cli): pass the resolved host platform through rea mcp add

* refactor(composition): default composition entry points to HOST_PLATFORM and pass it to Hopper and IDA (#11183)

* refactor(kuna): require the host platform in admission and installation, and give it to the session client (#11186)

* refactor(kuna): require the host platform in admission and installation, and give it to the session client

* fix(kuna): pass the host platform from the JavaScript installation callers

verify-real-kuna, both native oracle helpers and the command-lifetime child script call inspectKunaInstallation from dist, where TypeScript cannot see the now-required platform. They passed undefined and got unsupported_host on supported hosts.

* refactor(server): give createServer a host option and pass it to session tools, sigrok and EVM (#11203)

* refactor(server): give createServer a host option and pass it to session tools, sigrok and EVM

createServer read process.platform and process.arch live for its capability services, and registerSessionTools read process.platform for process capture. A host option (default HOST_PLATFORM) now selects both, and composition passes the capability host to the sigrok provider and the EVM provider (execution gate, limiter probe and environment rules), as it does for pwntools.

hostRestrictedAvailabilityMcp selects its host through the option instead of redefining process.platform and process.arch, and moves to the MCP boundary lane since it no longer touches process-global state. evmCleanupRetry passes SIMULATED_LINUX_X64 to the provider instead of 52 property redefinitions; the fixture moves to tests/fixtures/simulatedHost.ts.

* refactor(desktop): require the host platform in build computer and secret folder paths (#11210)

* refactor(desktop): require the host platform in build computer and secret folder paths

buildComputerArchiveDirectory, defaultBuildComputerArchive, resolveBuildComputerEnvironment and buildSecretsDirectory defaulted to process.platform. Every caller but DesktopBuildComputers' secret folder already passed the platform; it now passes HOST_PLATFORM.platform, which it reads for the build environment.

* refactor(filesystem): default caller paths and ChangeTime settling to HOST_PLATFORM (#11212)

appendCallerPath, absoluteCallerPath and the ChangeTime settle seams defaulted to a live process.platform read. Their defaults now come from HOST_PLATFORM: the 59 callers that omit the platform join or settle paths they open on this host, and callers describing another host's layout already pass it.

The webScriptExport case that redefined process.platform to reach the Windows settle budget moves to its own file, which selects Windows by mocking HostPlatform.

* fix(server): report process capture availability for the server's host

sessionAvailabilityPolicy imported platform from node:process, so with a selected host binary_session reported capture_process_scenario from the running host while planning and capture used the selected one. It takes the platform from createServer and registerSessionTools. hostRestrictedAvailabilityMcp checks discovery against a dry-run plan on win32 and linux hosts.

* build(guards): count platform and arch imports from node:process and node:os as ambient host reads

sessionAvailabilityPolicy's named import of platform from node:process escaped the ambient-host-platform guard. The guards now also match named platform/arch imports from node:process or node:os and os.platform()/os.arch(). The one other site, DesktopApplicationCapture's os.arch(), records the capturing host and now reads HOST_PLATFORM.architecture.

* refactor(config): take the host platform in parseConfig and give debugger managers the capability host (#11237)

* refactor(config): take the host platform in parseConfig and give debugger managers the capability host

parseConfig read process.platform for the default Hopper launcher; it takes the platform (default HOST_PLATFORM). GdbSessionManager and RizinDebugSessionManager default their platform to HOST_PLATFORM, and composition passes the capability host that already decides their availability. GDB's /proc descriptor check reads HOST_PLATFORM explicitly: it inspects this host's /proc whatever host the manager models.

* refactor(firmware): give the firmware and Wakaru providers the capability host (#11239)

* refactor(firmware): give the firmware and Wakaru providers the capability host

resolveFirmwareCommand and resolveWakaruCommand read process.platform (and process.arch) for their host gate. They take the platform or host as a parameter; FirmwareProvider and WakaruProvider take a host (default HOST_PLATFORM) for the gate and their environment snapshots, and composition passes the capability host that already decides their availability. The JavaScript analysis source transfer defaults to HOST_PLATFORM.

artifactSelectedCommand passes SIMULATED_LINUX_X64 to both providers instead of redefining process.platform and process.arch, and the Wakaru limiter configuration cases now run on any POSIX host.

* refactor(captures): give tshark the capability host and default Cutter to HOST_PLATFORM (#11240)

* refactor(captures): give tshark the capability host and default Cutter to HOST_PLATFORM

TsharkCaptureProvider and CutterBridgeClient defaulted their platform to process.platform. Both default to HOST_PLATFORM now, and composition passes the capability host to the packet capture service, which already decides its availability.

* refactor(platform): read HOST_PLATFORM explicitly in host-only path checks (#11241)

* refactor(platform): read HOST_PLATFORM explicitly in host-only path checks

Electron's readlink target split, IDA's host path comparison, the inspector's reported runtime path, the server identity check and WABT's executable names all describe paths on the running host. They read HOST_PLATFORM instead of process.platform.

* test(native): select the native UI verifier's host through HostPlatform (#11242)

verify-native-ui.mjs reads its macOS requirement from HOST_PLATFORM, and its action test resolves the script's HostPlatform import to a simulated darwin host instead of redefining process.platform in the child preload. Simulating linux there fails the macOS requirement, so the redirect is effective.

* test(mcp): check that composition forwards the selected host to execution

hostRestrictedAvailabilityMcp ran execution only on darwin, where the runner's own host also refuses. The new case calls the firmware, Wakaru, tshark, sigrok and EVM tools under a darwin and a linux x64 host and requires different outcomes, so dropping a provider's host forwarding fails on any runner (checked by removing the firmware forwarding).

* fix(composition): give the pcap, Apktool and ADB providers the capability host

createServer's selected host decided pcap capture discovery, but the default pcap, Apktool and ADB factories built their providers with HOST_PLATFORM. The factories take the platform (default HOST_PLATFORM) and capabilityServices passes its context platform, so availability and execution follow one host.
# Conflicts:
#	scripts/verify-native-ui.mjs
#	src/server/sessionAvailabilityPolicy.ts
…wser

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
# Conflicts:
#	scripts/verify/baselines/ambient-host-platform.json
#	src/application/McpClientRegistration.formats.test.ts
#	src/browser/PlaywrightElectronActiveFuses.ts
#	src/captures/TsharkCaptureProvider.ts
#	src/composition/binary.ts
#	src/config.test.ts
#	src/config/parseConfig.ts
#	src/cutter/CutterBridgeClient.ts
#	src/electron/ElectronFusePath.ts
#	src/hopper/HopperProvider.ts
#	src/native/NativeMacOSProvider.ts
Comment thread src/config/parseConfig.ts Resolved
@morluto
morluto merged commit cb49383 into main Nov 15, 2026
8 checks passed
@morluto
morluto deleted the refactor/host-platform-browser branch November 15, 2026 20:27
@morluto morluto added area: runtime Process capture and runtime observation provider: electron Analysis provider / engine: electron labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation provider: electron Analysis provider / engine: electron

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant