Skip to content

fix(cli): keep file URLs out of operator-relative path resolution - #2882

Merged
morluto merged 1 commit into
morluto:mainfrom
shubhamahuja9999:fix/cli-electron-file-url-paths
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
shubhamahuja9999:fix/cli-electron-file-url-paths

Conversation

@shubhamahuja9999

Copy link
Copy Markdown
Contributor

Summary

Fixes #2577

CLI path normalization (resolveCliJsonPaths) resolved every nonblank selected string against the operator's working directory. A file URL in an Electron path field, such as executable_path: "file:///opt/electron", became an invented local path (<cwd>/file:/opt/electron, or <cwd>\file:\opt\electron on Windows). The CLI then reported ENOENT for that invented location instead of the field's local-filesystem-path requirement.

Problem and expected behavior

Smallest trigger: rea capture-electron-scenario '{"executable_path":"file:///opt/electron","application_path":"<abs>/main.js"}' --format json.

  • Before: invalid_request with Cannot resolve executable_path <cwd>\file:\opt\electron: ENOENT …. The caller's input was rewritten and they are pointed at the wrong location.
  • After: invalid_request on executable_path with the shared schema message "Electron executable, application, and root paths must be absolute local filesystem paths …". No filesystem lookup of an invented path happens.

Violated invariant (AGENTS.md): absolute paths, file URLs and HTTP paths have different semantics, and caller-selected inputs must be preserved.

Change and scope

  • src/cliJsonInput.ts: resolveCliJsonPaths leaves values matching file: or scheme:// unchanged, so the shared schema's existing absolute-local-path refinement rejects them. One-letter prefixes stay paths, so Windows drive paths (C:\…) and relative names containing a colon (release:v1/electron) still resolve exactly as before.
  • This is the single CLI owner of operator-relative path normalization, used by capture-electron-scenario and the browser scenario browser.executable_path, so both get the fix.
  • Not included: file URLs are not converted to paths. They are rejected, as the issue's restoration check asks, because the MCP contract defines these fields as local filesystem paths.

Contribution scope: ordinary CLI input fix; maintainer decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI JSON path normalization before shared schema validation.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. URL inputs to CLI path fields now get the documented field error instead of an ENOENT for an invented path. MCP is unchanged; it never resolved relative values.
  • Provider, bridge, target-format, or platform compatibility: none. Windows drive paths are covered by a test.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: URL inputs are rejected before any filesystem lookup or Electron launch.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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.

None of these apply: input validation only.

Evidence and regression coverage

  • tests/acceptance/applications/electronInvalidPaths.test.ts, "rejects a file URL path field without resolving an invented local path": runs the compiled CLI. It asserts exit code 1, invalid_request on executable_path with the local-path message, and no ENOENT.
  • src/cliJsonPaths.test.ts: file:///opt/electron, FILE:electron and https://example.test/app stay unchanged and are rejected by electronActiveObservationInputSchema on executable_path. Controls bin/electron, release:v1/electron and C:\Electron\electron.exe still resolve.
  • Base reproduction: with only src/cliJsonInput.ts reverted, the 3 URL unit cases and the CLI case fail. The CLI received Cannot resolve executable_path C:\…\rea\file:\opt\electron: ENOENT. The controls pass both before and after.
  • Representative CLI output after the fix: {"code":"invalid_request", … "issues":[{"path":["executable_path"], … "message":"Electron executable, application, and root paths must be absolute local filesystem paths (for example /Applications/Electron.app/Contents/MacOS/Electron)"}]}
  • Remaining proof gaps: verified on Windows only; POSIX behaviour follows the same regex, and the issue reproduced on macOS.

Validation performed

Windows 11, Node.js 24.18.0, npm 11.16.0, on main at 688defca0:

  • npm run test:local -- src/cliJsonPaths.test.ts: 3 failed without the fix; 13/13 with it.
  • npm run test:focused -- tests/acceptance/applications/electronInvalidPaths.test.ts: the new case failed without the fix; 2/2 with it.
  • npm run test:focused -- the 38 test files referencing Electron/browser scenario paths or executable_path: the same 23 tests fail with and without this change, which makes them pre-existing on Windows. For example, scenarioCliInputDiagnostics looks for raw C:\… paths inside JSON-escaped output. The only differences between the runs are the 4 new tests, which fail without the fix and pass with it.
  • npm run check:fast (typecheck and lint): passed, including as the pre-push hook.
  • npm run verify:module-boundaries and oxfmt --check on changed files: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Previously a URL in these fields always failed, with a misleading ENOENT; it now fails with the correct field error.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows; no Electron or browser launch is involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: prevents a rewritten filesystem lookup; no new execution.

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.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T16:40:45.849406Z c270092 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 Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

resolveCliJsonPaths now preserves file URLs and multi-letter scheme:// URLs so shared schemas reject them without inventing local paths.

  • CLI path fields keep URLs intact for local-path validation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI JSON input] --> B[resolveCliJsonPaths]
  B -->|Local path| C[Resolve against working directory]
  B -->|URL| D[Preserve original value]
  C --> E[Shared schema]
  D --> E
  E -->|URL rejected| F[Field error]
  E -->|Valid input| G[Create provider and run scenario]
Loading

Reviews (2) · Last reviewed commit: "fix(cli): keep file URLs out of operator..." · Reviewed by Greptile

CLI path normalization resolved every nonblank selected string against
the working directory, so executable_path "file:///opt/electron" became
an invented local path and failed with ENOENT for that location instead
of the field's local-path requirement. Leave `file:` and `scheme://`
references unchanged so the shared schema rejects them as non-local
paths. One-letter prefixes stay paths, so Windows drive paths and
relative names containing a colon resolve as before.

Fixes morluto#2577

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@shubhamahuja9999
shubhamahuja9999 force-pushed the fix/cli-electron-file-url-paths branch from d10ba1d to c270092 Compare October 13, 2026 16:36
@morluto
morluto merged commit f652709 into morluto:main Oct 13, 2026
9 of 12 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto

morluto commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Thank you, @shubhamahuja9999, for fixing the Electron path handling in #2882. Keeping file URLs out of working-directory resolution means callers now get the right local-path validation error instead of an ENOENT for a fabricated path, while Windows drive paths remain covered.

@morluto morluto added the area: cli CLI adapter and one-shot commands label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands 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.

fix(cli): file URLs become invented local paths in Electron requests

2 participants