[PR #5265] [MERGED] fix(cli): reject an empty JavaScript application path #6845

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5265
Author: @vishal-tambi
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @morluto

Base: main ← Head: fix/5258-javascript-selected-input-path


📝 Commits (1)

  • 1804fc8 fix(cli): reject an empty JavaScript application path

📊 Changes

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

View changed files

📝 src/cli/electronCommands.ts (+3 -1)
📝 tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts (+25 -0)

📄 Description

Summary

rea analyze-javascript-application "" analyzes the current working directory and returns successful Evidence. This PR makes it reject the empty path as invalid input instead.

This PR is now narrowed to that one change. The #5258 provenance fix is already on main in c4aaf813e: Evidence input_path, CLI path anchoring on both routes, the shared verifier assertions and the docs. Those parts have been dropped from this branch, and it is rebased onto main at b44cb5bd3.

There's no separate issue for the empty path. It came up in review on this PR, and the maintainer asked to keep it here.

Problem and expected behavior

Since c4aaf813e, the dedicated route passes absoluteCallerPath(args.path) into analysis. absoluteCallerPath("") returns the working directory (/cwd/ on POSIX, cwd on Windows). An empty argument therefore becomes a valid directory before the input schema ever sees it. A script that runs rea analyze-javascript-application "$APP_PATH" with an unset variable analyzes whatever directory it happens to run in.

Expected: an empty path is rejected as invalid_request on input_path. That matches MCP with input_path: "", and it matches this route before the anchoring change. rea analyze "" already rejects it, because its argument is declared .min(1).

Change and scope

  • src/cli/electronCommands.ts: an empty path is passed through unchanged; every other path is still anchored with absoluteCallerPath, exactly as on main. The existing input schema then rejects "". absoluteElectronFusePath in the same file handles an empty path the same way.
  • I didn't add .min(1) to the CLI argument, because that would change this route's error from the domain invalid_request to the argument parser's VALIDATION_ERROR.
  • I didn't change absoluteCallerPath itself, because it is shared by many other callers.

Not included: the wasm, sqlite, signal, rust, go, evm, capture and binary-diagnostics CLI commands also call absoluteCallerPath(args.path) on an argument without .min(1). That predates this PR and isn't changed here.

Scope decision: not applicable. This is an input-validation fix in an existing CLI route.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI adapter for analyze-javascript-application, before input validation.
  • Contribution scope fit and linked maintainer decision: existing CLI behavior. No decision needed.
  • CLI and MCP/tool-catalog contract: analyze-javascript-application "" now exits 1 with invalid_request instead of analyzing the working directory. Non-empty paths, rea analyze and the MCP tool are unchanged. No schema changes.
  • Provider, bridge, target-format, or platform compatibility: no change.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged for valid input. No Evidence is produced for an empty selection.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): an empty argument no longer selects the working directory as the analysis target.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: 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: one parameterized cliTest appended to tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts. It runs each CLI route with "" from a temp directory that contains a JavaScript file:
    • analyze-javascript-application "": exit 1, invalid_request, with an issue on input_path.
    • analyze "": exit 1, VALIDATION_ERROR. This behavior is unchanged; the case is there so both anchored routes are covered.
  • Base reproduction or other evidence:
    • With main's electronCommands.ts (0e62094b6), the dedicated-route case fails: exit code 0 instead of 1. The analyze case and the existing selected-path test pass.
    • An earlier manual run of the same anchoring code returned Evidence whose subject.local_path and parameters.input_path were the working directory.
  • User-visible CLI/MCP output (if applicable): with this change, analyze-javascript-application "" --json prints the invalid_request error document with an issue on input_path and exits 1. Output for non-empty paths is unchanged.
  • Remaining proof gaps:
    • macOS and Linux were not run.
    • The full CI suite was not run locally.

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 on Windows 11 with Node 24.18.0 and npm 11.16.0. Unless noted, these ran on main at 0e62094b6 plus this commit.

CI on the previous head (44610ab32) failed two tests in shard 4/5: applicationWorkflowCli and applicationExportShapeMcp, both relative-path Evidence ID parity checks. main's own CI at 0e62094b6 failed the same two tests, and b44cb5bd3 fixes them on main, so I rebased onto it. After the rebase:

  • npm run test:focused -- with the seven files listed below plus applicationWorkflowCli and applicationExportShapeMcp: 86 passed, 1 failed, 2 skipped.
    • The failure is applicationExportShapeMcp > "compares exact parser export shapes with inline Evidence".
    • It fails the same way on clean main at b44cb5bd3 on this machine. The checkout is on D: and the temp directory is on C:, so path.relative returns an absolute path. The "relative" selection then equals the absolute one, and the two Evidence IDs match.
    • It is unrelated to this change.
  • npm run check:fast: passed, also as the pre-push hook.

Earlier runs, on 0e62094b6:

  • npm run test:focused -- tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts, with main's electronCommands.ts swapped in: 1 failed (dedicated route, exit 0) and 2 passed.
  • npm run test:focused -- with javascriptSelectedPathEvidence, javascriptAnalysisLimits, javascriptApplicationJsonOutput, electronCli, javascriptApplicationInputSelection, javascriptApplicationCancellation and javascriptClientVerifier: 45 passed, 2 skipped (both platform-guarded).
  • npm run test:focused -- with 111 JavaScript, Electron CLI/MCP and Evidence-parsing boundary/acceptance files: 872 passed, 62 failed, 29 skipped.
    • The same 62 tests (61 unique names, in the same 9 files) also fail on clean main at 0e62094b6 on this machine.
    • All 62 are Windows host limits:
      • fixture filenames containing ?, # or a tab;
      • EPERM creating file symlinks without the privilege;
      • "Safe no-follow file opens are unavailable", because a source checkout has no Windows native addon;
      • one spawn ENAMETOOLONG.
    • None of them comes from this change.
  • npm run check: exit 0 (typecheck; lint with 0 errors and 1,761 warnings, none in the changed files; oxfmt; knip; metadata; module boundaries; architecture guards).
  • npm run docs:check: passed.
  • npm run verify:test-discovery: 1,668 test files, each assigned once.
  • npm run format:check and git diff --check: passed.
  • npm run check:fast: passed as the pre-push hook.

Not run: the native client verifiers (this change doesn't touch them), macOS, Linux and the full CI suite.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for valid input. analyze-javascript-application "" now fails instead of analyzing the working directory. A caller that relied on that behavior should pass . explicitly.
  • Real Hopper/Ghidra, browser, or OS coverage: no provider is involved. Only Windows was run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: this stops an empty argument from silently selecting the working directory for analysis.

Author readiness

Human owner: @vishal-tambi

  • 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/5265 **Author:** [@vishal-tambi](https://github.com/vishal-tambi) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/5258-javascript-selected-input-path` --- ### 📝 Commits (1) - [`1804fc8`](https://github.com/morluto/rea/commit/1804fc82a44bde716741d1eb0a0505103c2915bb) fix(cli): reject an empty JavaScript application path ### 📊 Changes **2 files changed** (+28 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/electronCommands.ts` (+3 -1) 📝 `tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts` (+25 -0) </details> ### 📄 Description ## Summary `rea analyze-javascript-application ""` analyzes the current working directory and returns successful Evidence. This PR makes it reject the empty path as invalid input instead. This PR is now narrowed to that one change. The #5258 provenance fix is already on `main` in c4aaf813e: Evidence `input_path`, CLI path anchoring on both routes, the shared verifier assertions and the docs. Those parts have been dropped from this branch, and it is rebased onto `main` at b44cb5bd3. There's no separate issue for the empty path. It came up in review on this PR, and the maintainer asked to keep it here. ## Problem and expected behavior Since c4aaf813e, the dedicated route passes `absoluteCallerPath(args.path)` into analysis. `absoluteCallerPath("")` returns the working directory (`/cwd/` on POSIX, `cwd` on Windows). An empty argument therefore becomes a valid directory before the input schema ever sees it. A script that runs `rea analyze-javascript-application "$APP_PATH"` with an unset variable analyzes whatever directory it happens to run in. Expected: an empty path is rejected as `invalid_request` on `input_path`. That matches MCP with `input_path: ""`, and it matches this route before the anchoring change. `rea analyze ""` already rejects it, because its argument is declared `.min(1)`. ## Change and scope - `src/cli/electronCommands.ts`: an empty path is passed through unchanged; every other path is still anchored with `absoluteCallerPath`, exactly as on `main`. The existing input schema then rejects `""`. `absoluteElectronFusePath` in the same file handles an empty path the same way. - I didn't add `.min(1)` to the CLI argument, because that would change this route's error from the domain `invalid_request` to the argument parser's `VALIDATION_ERROR`. - I didn't change `absoluteCallerPath` itself, because it is shared by many other callers. Not included: the wasm, sqlite, signal, rust, go, evm, capture and binary-diagnostics CLI commands also call `absoluteCallerPath(args.path)` on an argument without `.min(1)`. That predates this PR and isn't changed here. Scope decision: not applicable. This is an input-validation fix in an existing CLI route. ## Contract and boundary impact - Semantic owner and earliest changed stage: the CLI adapter for `analyze-javascript-application`, before input validation. - Contribution scope fit and linked maintainer decision: existing CLI behavior. No decision needed. - CLI and MCP/tool-catalog contract: `analyze-javascript-application ""` now exits 1 with `invalid_request` instead of analyzing the working directory. Non-empty paths, `rea analyze` and the MCP tool are unchanged. No schema changes. - Provider, bridge, target-format, or platform compatibility: no change. - Evidence, artifact, provenance, or reconstruction contract: unchanged for valid input. No Evidence is produced for an empty selection. - Target selection, authority, upstream behavior, and cleanup details (if applicable): an empty argument no longer selects the working directory as the analysis target. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [x] Launch or attach to a process. - [x] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [x] Contact network services. - [x] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [x] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: one parameterized `cliTest` appended to `tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts`. It runs each CLI route with `""` from a temp directory that contains a JavaScript file: - `analyze-javascript-application ""`: exit 1, `invalid_request`, with an issue on `input_path`. - `analyze ""`: exit 1, `VALIDATION_ERROR`. This behavior is unchanged; the case is there so both anchored routes are covered. - Base reproduction or other evidence: - With `main`'s `electronCommands.ts` (0e62094b6), the dedicated-route case fails: exit code 0 instead of 1. The `analyze` case and the existing selected-path test pass. - An earlier manual run of the same anchoring code returned Evidence whose `subject.local_path` and `parameters.input_path` were the working directory. - User-visible CLI/MCP output (if applicable): with this change, `analyze-javascript-application "" --json` prints the `invalid_request` error document with an issue on `input_path` and exits 1. Output for non-empty paths is unchanged. - Remaining proof gaps: - macOS and Linux were not run. - The full CI suite was not run locally. 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 on Windows 11 with Node 24.18.0 and npm 11.16.0. Unless noted, these ran on `main` at 0e62094b6 plus this commit. CI on the previous head (44610ab32) failed two tests in shard 4/5: `applicationWorkflowCli` and `applicationExportShapeMcp`, both relative-path Evidence ID parity checks. `main`'s own CI at 0e62094b6 failed the same two tests, and b44cb5bd3 fixes them on `main`, so I rebased onto it. After the rebase: - `npm run test:focused --` with the seven files listed below plus `applicationWorkflowCli` and `applicationExportShapeMcp`: 86 passed, 1 failed, 2 skipped. - The failure is `applicationExportShapeMcp` > "compares exact parser export shapes with inline Evidence". - It fails the same way on clean `main` at b44cb5bd3 on this machine. The checkout is on `D:` and the temp directory is on `C:`, so `path.relative` returns an absolute path. The "relative" selection then equals the absolute one, and the two Evidence IDs match. - It is unrelated to this change. - `npm run check:fast`: passed, also as the pre-push hook. Earlier runs, on 0e62094b6: - `npm run test:focused -- tests/boundary/javascript/javascriptSelectedPathEvidence.test.ts`, with `main`'s `electronCommands.ts` swapped in: 1 failed (dedicated route, exit 0) and 2 passed. - `npm run test:focused --` with `javascriptSelectedPathEvidence`, `javascriptAnalysisLimits`, `javascriptApplicationJsonOutput`, `electronCli`, `javascriptApplicationInputSelection`, `javascriptApplicationCancellation` and `javascriptClientVerifier`: 45 passed, 2 skipped (both platform-guarded). - `npm run test:focused --` with 111 JavaScript, Electron CLI/MCP and Evidence-parsing boundary/acceptance files: 872 passed, 62 failed, 29 skipped. - The same 62 tests (61 unique names, in the same 9 files) also fail on clean `main` at 0e62094b6 on this machine. - All 62 are Windows host limits: - fixture filenames containing `?`, `#` or a tab; - `EPERM` creating file symlinks without the privilege; - "Safe no-follow file opens are unavailable", because a source checkout has no Windows native addon; - one `spawn ENAMETOOLONG`. - None of them comes from this change. - `npm run check`: exit 0 (typecheck; lint with 0 errors and 1,761 warnings, none in the changed files; oxfmt; knip; metadata; module boundaries; architecture guards). - `npm run docs:check`: passed. - `npm run verify:test-discovery`: 1,668 test files, each assigned once. - `npm run format:check` and `git diff --check`: passed. - `npm run check:fast`: passed as the pre-push hook. Not run: the native client verifiers (this change doesn't touch them), macOS, Linux and the full CI suite. ## Compatibility, safety, and release - Breaking changes or migration steps: none for valid input. `analyze-javascript-application ""` now fails instead of analyzing the working directory. A caller that relied on that behavior should pass `.` explicitly. - Real Hopper/Ghidra, browser, or OS coverage: no provider is involved. Only Windows was run. - Package or release metadata impact: none. - Security, privacy, process, or containment review: this stops an empty argument from silently selecting the working directory for analysis. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @vishal-tambi - [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. - [x] 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:43:29 +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#6845
No description provided.