[PR #6820] [CLOSED] fix(cli): reject an empty desktop application path #7419

Closed
opened 2026-11-01 21:47:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6820
Author: @amyanger
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/6757-empty-desktop-path


📝 Commits (1)

  • 2a4f498 fix(cli): reject an empty desktop application path

📊 Changes

2 files changed (+28 additions, -1 deletions)

View changed files

📝 src/cli/desktopApplicationCommands.ts (+8 -1)
📝 tests/boundary/cli/desktopApplicationCli.test.ts (+20 -0)

📄 Description

Summary

Fixes #6757.

rea inspect-desktop-application "" silently inspected the current working directory and exited 0. The CLI made the empty path absolute before the service saw it, so the service's non-empty check never ran. The command now passes the empty path through unchanged, and the service rejects it with invalid_request.

Problem and expected behavior

src/cli/desktopApplicationCommands.ts called absoluteCallerPath(args.path). For "", that helper prefixes the working directory, so the selection became the working directory. The desktop inspection input schema (absoluteLocalPathStringSchema, src/domain/localPath.ts) requires a non-empty absolute path and rejects "", which is what MCP callers already get.

Invariant: CLI path anchoring may make a named path absolute, but must not turn a selection that names no file into a different, valid target.

Change and scope

The command now passes args.path === "" ? args.path : absoluteCallerPath(args.path), the same guard and comment that #5265 (1a945ce9f) added to analyze-javascript-application in src/cli/electronCommands.ts.

Not included:

  • Whitespace-only paths. " " is a real file name and becomes <cwd>/ , which fails as target_unavailable. It does not fall back to the working directory, and the precedent guards only "" as well.
  • Other commands. About 27 other CLI commands still call absoluteCallerPath(args.path) without an empty-path guard. They are outside this issue. A shared guard in absoluteCallerPath would be a separate change, since some callers may pass paths that are not user selections.
  • MCP. inspect_desktop_application over MCP never calls absoluteCallerPath and already rejects "".

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI argument anchoring in src/cli/desktopApplicationCommands.ts, before the service call.
  • Contribution scope fit and linked maintainer decision: not applicable, ordinary fix within an existing boundary.
  • CLI and MCP/tool-catalog contract: CLI only. An empty path now yields the existing typed invalid_request refusal instead of a successful inspection of the working directory. MCP is unchanged and already behaved this way.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: an empty selection no longer creates Evidence for the working directory.
  • Target selection, authority, upstream behavior, and cleanup details: the command no longer reads a directory the caller did not select.
  • 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.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/desktopApplicationCli.test.ts, "rejects an empty path instead of inspecting the working directory". It runs the compiled CLI with "" from a temporary working directory that is itself a valid inspection target (it contains resources/app.asar), and expects exit 1 with code: "invalid_request" and category: "invalid_input". It follows the test #5265 added.
  • Base reproduction (executed): on base 1635eadfc with the new test, npm run test:focused -- tests/boundary/cli/desktopApplicationCli.test.ts gives 1 failed, 3 passed, with expected 0 to be 1 on the exit code. Because the temporary directory is a valid target, the base failure is the reported bug, not an unrelated error.
  • Mutation: the fix is one conditional. Reverting it restores the base code, which fails the new test as shown above.
  • User-visible CLI output (executed, from a temporary directory containing resources/app.asar, node scripts/rea.mjs inspect-desktop-application "" --json):
    • Base: exit 0, {"evidence_id":"ev_9da6b7ce...","subject":{"name":"desk",...,"local_path":"<the working directory>"...
    • Branch: exit 1, {"code":"invalid_request","category":"invalid_input","message":"Analysis input is invalid. Check the arguments and try again.",.... The details list path failing minimum: 1 and the absolute-path format.
  • Remaining proof gaps: not run on Windows. The schema rejects "" on every platform, and the guard runs before any platform-specific path handling.

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

All commands ran on macOS arm64 with Node v24.22.1, base 1635eadfc (newest upstream main commit with green CI). Both changed files are identical on that commit and on the current main tip.

  • npm run test:focused -- tests/boundary/cli/desktopApplicationCli.test.ts: 4 tests passed.
  • npm run check:fast: passed.
  • npm run test:changed -- --base 1635eadfc: 3 files, 18 tests passed. This command selects only source-level projects, so the CLI boundary file is covered by the test:focused run above.
  • npm run check: exit 0.
  • Independent review (separate worktree, read-only on the checkout) confirmed the service's rejection, the MCP behavior, whitespace handling and the base failure. It found no doc, fixture or golden that relies on "" meaning the working directory.
  • /code-review (high) on the uncommitted diff reported three findings, all about scope rather than correctness:
    • About 20 other CLI commands pass args.path to absoluteCallerPath without the guard, and a guard inside the helper would fix them all. Verified, not changed. The helper has 55 calls in 36 files, and 18 of them are outside src/cli (for example BinaryTargetResolver, SafeOutputTree, RizinCommand, WasmGlueAdapter). Changing it would change what "" means on those paths too, which needs its own tracing and tests. This PR keeps the per-command guard from #5265.
    • Option paths such as --binary "" in il2cppCommands.ts and capture_path in webNetworkCaptureCommands.ts have the same conversion. Not changed: outside #6757.
    • The guard now exists in three places (electronCommands.ts twice, and this command). Noted. A shared helper guard would remove the copies; that belongs with the first point.
  • Real provider: not applicable. The change is in the CLI argument layer, exercised above through the compiled public CLI.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A caller that relied on "" meaning the working directory can pass ., which the issue shows selects the same directory.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the command no longer reads a directory the caller did not name.

Author readiness

Human owner: @amyanger

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6820 **Author:** [@amyanger](https://github.com/amyanger) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/6757-empty-desktop-path` --- ### 📝 Commits (1) - [`2a4f498`](https://github.com/morluto/rea/commit/2a4f498fd89d53624d60c74b66b9d9d6ed7d51d0) fix(cli): reject an empty desktop application path ### 📊 Changes **2 files changed** (+28 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/desktopApplicationCommands.ts` (+8 -1) 📝 `tests/boundary/cli/desktopApplicationCli.test.ts` (+20 -0) </details> ### 📄 Description ## Summary Fixes #6757. `rea inspect-desktop-application ""` silently inspected the current working directory and exited 0. The CLI made the empty path absolute before the service saw it, so the service's non-empty check never ran. The command now passes the empty path through unchanged, and the service rejects it with `invalid_request`. ## Problem and expected behavior `src/cli/desktopApplicationCommands.ts` called `absoluteCallerPath(args.path)`. For `""`, that helper prefixes the working directory, so the selection became the working directory. The desktop inspection input schema (`absoluteLocalPathStringSchema`, `src/domain/localPath.ts`) requires a non-empty absolute path and rejects `""`, which is what MCP callers already get. Invariant: CLI path anchoring may make a named path absolute, but must not turn a selection that names no file into a different, valid target. ## Change and scope The command now passes `args.path === "" ? args.path : absoluteCallerPath(args.path)`, the same guard and comment that #5265 (`1a945ce9f`) added to `analyze-javascript-application` in `src/cli/electronCommands.ts`. Not included: - Whitespace-only paths. `" "` is a real file name and becomes `<cwd>/ `, which fails as `target_unavailable`. It does not fall back to the working directory, and the precedent guards only `""` as well. - Other commands. About 27 other CLI commands still call `absoluteCallerPath(args.path)` without an empty-path guard. They are outside this issue. A shared guard in `absoluteCallerPath` would be a separate change, since some callers may pass paths that are not user selections. - MCP. `inspect_desktop_application` over MCP never calls `absoluteCallerPath` and already rejects `""`. ## Contract and boundary impact - Semantic owner and earliest changed stage: CLI argument anchoring in `src/cli/desktopApplicationCommands.ts`, before the service call. - Contribution scope fit and linked maintainer decision: not applicable, ordinary fix within an existing boundary. - CLI and MCP/tool-catalog contract: CLI only. An empty path now yields the existing typed `invalid_request` refusal instead of a successful inspection of the working directory. MCP is unchanged and already behaved this way. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: an empty selection no longer creates Evidence for the working directory. - Target selection, authority, upstream behavior, and cleanup details: the command no longer reads a directory the caller did not select. - Generated metadata, package, or installation impact: none. Expected effects: - [x] 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: `tests/boundary/cli/desktopApplicationCli.test.ts`, "rejects an empty path instead of inspecting the working directory". It runs the compiled CLI with `""` from a temporary working directory that is itself a valid inspection target (it contains `resources/app.asar`), and expects exit 1 with `code: "invalid_request"` and `category: "invalid_input"`. It follows the test #5265 added. - Base reproduction (executed): on base `1635eadfc` with the new test, `npm run test:focused -- tests/boundary/cli/desktopApplicationCli.test.ts` gives 1 failed, 3 passed, with `expected 0 to be 1` on the exit code. Because the temporary directory is a valid target, the base failure is the reported bug, not an unrelated error. - Mutation: the fix is one conditional. Reverting it restores the base code, which fails the new test as shown above. - User-visible CLI output (executed, from a temporary directory containing `resources/app.asar`, `node scripts/rea.mjs inspect-desktop-application "" --json`): - Base: exit 0, `{"evidence_id":"ev_9da6b7ce...","subject":{"name":"desk",...,"local_path":"<the working directory>"...` - Branch: exit 1, `{"code":"invalid_request","category":"invalid_input","message":"Analysis input is invalid. Check the arguments and try again.",...`. The details list `path` failing `minimum: 1` and the absolute-path format. - Remaining proof gaps: not run on Windows. The schema rejects `""` on every platform, and the guard runs before any platform-specific path handling. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed All commands ran on macOS arm64 with Node v24.22.1, base `1635eadfc` (newest upstream main commit with green CI). Both changed files are identical on that commit and on the current main tip. - `npm run test:focused -- tests/boundary/cli/desktopApplicationCli.test.ts`: 4 tests passed. - `npm run check:fast`: passed. - `npm run test:changed -- --base 1635eadfc`: 3 files, 18 tests passed. This command selects only source-level projects, so the CLI boundary file is covered by the `test:focused` run above. - `npm run check`: exit 0. - Independent review (separate worktree, read-only on the checkout) confirmed the service's rejection, the MCP behavior, whitespace handling and the base failure. It found no doc, fixture or golden that relies on `""` meaning the working directory. - `/code-review` (high) on the uncommitted diff reported three findings, all about scope rather than correctness: - About 20 other CLI commands pass `args.path` to `absoluteCallerPath` without the guard, and a guard inside the helper would fix them all. Verified, not changed. The helper has 55 calls in 36 files, and 18 of them are outside `src/cli` (for example `BinaryTargetResolver`, `SafeOutputTree`, `RizinCommand`, `WasmGlueAdapter`). Changing it would change what `""` means on those paths too, which needs its own tracing and tests. This PR keeps the per-command guard from #5265. - Option paths such as `--binary ""` in `il2cppCommands.ts` and `capture_path` in `webNetworkCaptureCommands.ts` have the same conversion. Not changed: outside #6757. - The guard now exists in three places (`electronCommands.ts` twice, and this command). Noted. A shared helper guard would remove the copies; that belongs with the first point. - Real provider: not applicable. The change is in the CLI argument layer, exercised above through the compiled public CLI. ## Compatibility, safety, and release - Breaking changes or migration steps: none. A caller that relied on `""` meaning the working directory can pass `.`, which the issue shows selects the same directory. - Real Hopper/Ghidra, browser, or OS coverage: not applicable. - Package or release metadata impact: none. - Security, privacy, process, or containment review: the command no longer reads a directory the caller did not name. ## Author readiness Human owner: @amyanger - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7419
No description provided.