[PR #1197] [MERGED] fix(domain): report target read-permission denials as access_denied #2710

Closed
opened 2026-10-17 21:09:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1197
Author: @kaoru0822-kitauji
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/target-admission-access-denied


📝 Commits (2)

  • d0ff57a fix(domain): report target read-permission denials as access_denied
  • 9f5dc52 fix(hopper): keep the OS error when the FAT64 source cannot be reopened

📊 Changes

8 files changed (+131 additions, -5 deletions)

View changed files

📝 src/domain/analysisErrorPresentation.ts (+4 -1)
📝 src/domain/analysisErrorProjection.test.ts (+36 -0)
📝 src/domain/analysisErrorProjection.ts (+9 -1)
📝 src/domain/configurationErrors.ts (+9 -0)
➕ src/hopper/HopperMachOImage.test.ts (+37 -0)
📝 src/hopper/HopperMachOImage.ts (+10 -2)
📝 tests/boundary/cli/nativePlistSelectionFailureCli.test.ts (+2 -1)
📝 tests/boundary/filesystem/binaryTarget.test.ts (+24 -0)

📄 Description

Summary

Opening an executable the current user cannot read returned target_unavailable, the same code as a missing file, through both the CLI and MCP. The reason text said EACCES, but clients that branch on the code could not choose read-access recovery. The boundary contract separates host permission denial from unavailable targets, and AnalysisAccessDeniedError already projects access_denied for denied reads elsewhere.

Fixes #1188

Change

  • src/domain/configurationErrors.ts: BinaryTargetError records systemCode (EACCES or EPERM) when its cause is an OS error with that code. Every admission site already passes the OS error as cause: target access/open, app bundle paths, Info.plist inspection, reading, and decoding, program-file resolution, and selected-plist reads. So no site needed to change, and the reported value is the OS code itself, not a guess from text.
  • src/domain/analysisErrorProjection.ts: BinaryTargetError projects as access_denied when systemCode is set and as target_unavailable otherwise. Its details add system_code and boundary: "filesystem-read", the same fields AnalysisAccessDeniedError reports, while keeping its specific reason and path.
  • src/domain/analysisErrorPresentation.ts: these errors get the existing read-access remediation ("Check the current process's read access to the selected path. Retry with a readable local file.").

Missing paths (ENOENT/ENOTDIR), directories, and malformed headers keep target_unavailable.

Built CLI (chmod 000 copy of a thin Mach-O)

{"code":"access_denied","category":"unavailable",
 "remediation":{"action":"Check the current process's read access to the selected path. Retry with a readable local file."},
 "details":{"path":"…/unreadable","reason":"permission denied while reading target: EACCES: permission denied, access '…/unreadable'","system_code":"EACCES","boundary":"filesystem-read"}}

On main the same call returned target_unavailable with the generic "Check that the path exists…" advice.

Tests

  • src/domain/analysisErrorProjection.test.ts: EACCES/EPERM causes project as access_denied with these details and remediation; an ENOENT cause still projects as target_unavailable.
  • tests/boundary/filesystem/binaryTarget.test.ts: a real chmod 000 target fails admission with systemCode: "EACCES" and projects as access_denied (skipped on Windows and as root). The existing app Info.plist permission cases now also assert systemCode.
  • tests/boundary/cli/nativePlistSelectionFailureCli.test.ts: reports a permission denial instead of a malformed plist expected target_unavailable for a chmod 000 plist. It now expects access_denied with system_code: "EACCES", the same OS denial reported consistently.
  • 5 cases fail on main.

Verification

  • npm run check:fast, npm run jscpd, npm run docs:check
  • npm run test:focused -- every test mentioning BinaryTargetError, target_unavailable, access_denied, EACCES, or permission-denied text (31 files: 331 passed, 61 skipped). One failure, classifies a real hdiutil verify refusal…, also fails on main on this machine (local hdiutil) and is unrelated.

No Hopper/Ghidra verification was needed: admission fails before any provider starts.

🤖 Generated with Claude Code


🔄 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/1197 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/target-admission-access-denied` --- ### 📝 Commits (2) - [`d0ff57a`](https://github.com/morluto/rea/commit/d0ff57a45c8da8938e7ae16d00bfd5ec63310af3) fix(domain): report target read-permission denials as access_denied - [`9f5dc52`](https://github.com/morluto/rea/commit/9f5dc52be8420fb5e874595d63312bf80d07a3a2) fix(hopper): keep the OS error when the FAT64 source cannot be reopened ### 📊 Changes **8 files changed** (+131 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/analysisErrorPresentation.ts` (+4 -1) 📝 `src/domain/analysisErrorProjection.test.ts` (+36 -0) 📝 `src/domain/analysisErrorProjection.ts` (+9 -1) 📝 `src/domain/configurationErrors.ts` (+9 -0) ➕ `src/hopper/HopperMachOImage.test.ts` (+37 -0) 📝 `src/hopper/HopperMachOImage.ts` (+10 -2) 📝 `tests/boundary/cli/nativePlistSelectionFailureCli.test.ts` (+2 -1) 📝 `tests/boundary/filesystem/binaryTarget.test.ts` (+24 -0) </details> ### 📄 Description ## Summary Opening an executable the current user cannot read returned `target_unavailable`, the same code as a missing file, through both the CLI and MCP. The reason text said `EACCES`, but clients that branch on the code could not choose read-access recovery. The boundary contract separates host permission denial from unavailable targets, and `AnalysisAccessDeniedError` already projects `access_denied` for denied reads elsewhere. Fixes #1188 ## Change - `src/domain/configurationErrors.ts`: `BinaryTargetError` records `systemCode` (`EACCES` or `EPERM`) when its cause is an OS error with that code. Every admission site already passes the OS error as `cause`: target `access`/`open`, app bundle paths, `Info.plist` inspection, reading, and decoding, program-file resolution, and selected-plist reads. So no site needed to change, and the reported value is the OS code itself, not a guess from text. - `src/domain/analysisErrorProjection.ts`: `BinaryTargetError` projects as `access_denied` when `systemCode` is set and as `target_unavailable` otherwise. Its details add `system_code` and `boundary: "filesystem-read"`, the same fields `AnalysisAccessDeniedError` reports, while keeping its specific `reason` and `path`. - `src/domain/analysisErrorPresentation.ts`: these errors get the existing read-access remediation ("Check the current process's read access to the selected path. Retry with a readable local file."). Missing paths (`ENOENT`/`ENOTDIR`), directories, and malformed headers keep `target_unavailable`. ## Built CLI (`chmod 000` copy of a thin Mach-O) ```json {"code":"access_denied","category":"unavailable", "remediation":{"action":"Check the current process's read access to the selected path. Retry with a readable local file."}, "details":{"path":"…/unreadable","reason":"permission denied while reading target: EACCES: permission denied, access '…/unreadable'","system_code":"EACCES","boundary":"filesystem-read"}} ``` On `main` the same call returned `target_unavailable` with the generic "Check that the path exists…" advice. ## Tests - `src/domain/analysisErrorProjection.test.ts`: `EACCES`/`EPERM` causes project as `access_denied` with these details and remediation; an `ENOENT` cause still projects as `target_unavailable`. - `tests/boundary/filesystem/binaryTarget.test.ts`: a real `chmod 000` target fails admission with `systemCode: "EACCES"` and projects as `access_denied` (skipped on Windows and as root). The existing app `Info.plist` permission cases now also assert `systemCode`. - `tests/boundary/cli/nativePlistSelectionFailureCli.test.ts`: `reports a permission denial instead of a malformed plist` expected `target_unavailable` for a `chmod 000` plist. It now expects `access_denied` with `system_code: "EACCES"`, the same OS denial reported consistently. - 5 cases fail on `main`. ## Verification - `npm run check:fast`, `npm run jscpd`, `npm run docs:check` - `npm run test:focused --` every test mentioning `BinaryTargetError`, `target_unavailable`, `access_denied`, `EACCES`, or permission-denied text (31 files: 331 passed, 61 skipped). One failure, `classifies a real hdiutil verify refusal…`, also fails on `main` on this machine (local `hdiutil`) and is unrelated. No Hopper/Ghidra verification was needed: admission fails before any provider starts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:22 +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#2710
No description provided.