[PR #1677] [CLOSED] fix(native): report missing and non-file PE resource targets as input errors #4746

Closed
opened 2026-10-31 00:54:38 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1677
Author: @kaoru0822-kitauji
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: fix/pe-resources-input-selection


📝 Commits (2)

  • e1def2b fix(native): report missing and non-file PE resource targets as input errors
  • 7aee990 Merge remote-tracking branch 'origin/main' into fix/pe-resources-input-selection

📊 Changes

2 files changed (+76 additions, -44 deletions)

View changed files

📝 src/native/pe/PeResourcesProvider.ts (+58 -41)
📝 tests/boundary/filesystem/peResources.test.ts (+18 -3)

📄 Description

Summary

inspect_pe_resources reports a mistaken caller selection as an artifact fault. On main:

$ rea inspect-pe-resources ./nope.bin --format json
{"code":"artifact_operation_failed","category":"execution_failure",
 "message":"Artifact could not be read or written. Check file access and try again.",
 "details":{"operation":"inspect_pe_resources","reason":"io","detail":"ENOENT: no such file or directory, lstat '…/nope.bin'"}}

A directory and a symlink also get artifact_operation_failed, with reason: "path". File access is not the problem in either case. The caller chose a target that cannot be a PE image. The other artifact commands from the same sweep (inspect-macho, inspect-artifact, list-architectures, …) return target_unavailable. The sibling inspect_evm_interface read, from the same binary-diagnostics family, already maps this case to AnalysisInputError (src/evm/EvmoleFailures.ts).

Change

PeResourcesProvider now maps failures the same way as the EVM carrier read:

Failure Before After
directory or symlink (ArtifactReaderFailure path) artifact_operation_failed invalid_request, issue path / invalid_format, with the reader's message
ENOENT / ENOTDIR artifact_operation_failed invalid_request, issue path / invalid_value, naming the code and path
file changed during the read (integrity) artifact_operation_failed AnalysisArtifactChangedError
limit, cancellation, EACCES/EPERM, other I/O unchanged unchanged

The mapping moved into peResourcesFailure(), which keeps inspect under the complexity limit.

After the change:

$ rea inspect-pe-resources ./nope.bin --format json
{"code":"invalid_request","category":"invalid_input",…,"details":{"operation":"inspect_pe_resources",
 "issues":[{"path":["path"],"reason":"invalid_value","message":"Selected PE image could not be read (ENOENT): …/nope.bin."}]}}

Verification

  • tests/boundary/filesystem/peResources.test.ts previously pinned ArtifactOperationError for these cases. It now asserts the typed issue for a directory, a symlink, a missing file and a path below a regular file (ENOTDIR). It fails against main's provider and passes here.
  • npm run test:focused -- that test plus src/native/pe/PeResourceParser.test.ts and src/application/binaryDiagnostics/PeResourcesService.test.ts: 27 passed. tests/acceptance/applications/peResources.test.ts (CLI/MCP, after build:cached): passed.
  • Ran the built CLI on a missing path, a directory and an ENOTDIR path.
  • npm run typecheck and oxlint are clean on the changed files. jscpd is 2.485%.

No Hopper/Ghidra involvement.

🤖 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/1677 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/pe-resources-input-selection` --- ### 📝 Commits (2) - [`e1def2b`](https://github.com/morluto/rea/commit/e1def2bf1ae5806f5d440b2b197fcfe8db721ad6) fix(native): report missing and non-file PE resource targets as input errors - [`7aee990`](https://github.com/morluto/rea/commit/7aee9900da5a0e9e4c393d369d85181b61073831) Merge remote-tracking branch 'origin/main' into fix/pe-resources-input-selection ### 📊 Changes **2 files changed** (+76 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `src/native/pe/PeResourcesProvider.ts` (+58 -41) 📝 `tests/boundary/filesystem/peResources.test.ts` (+18 -3) </details> ### 📄 Description ## Summary `inspect_pe_resources` reports a mistaken caller selection as an artifact fault. On main: ```text $ rea inspect-pe-resources ./nope.bin --format json {"code":"artifact_operation_failed","category":"execution_failure", "message":"Artifact could not be read or written. Check file access and try again.", "details":{"operation":"inspect_pe_resources","reason":"io","detail":"ENOENT: no such file or directory, lstat '…/nope.bin'"}} ``` A directory and a symlink also get `artifact_operation_failed`, with `reason: "path"`. File access is not the problem in either case. The caller chose a target that cannot be a PE image. The other artifact commands from the same sweep (`inspect-macho`, `inspect-artifact`, `list-architectures`, …) return `target_unavailable`. The sibling `inspect_evm_interface` read, from the same binary-diagnostics family, already maps this case to `AnalysisInputError` (`src/evm/EvmoleFailures.ts`). ## Change `PeResourcesProvider` now maps failures the same way as the EVM carrier read: | Failure | Before | After | |---|---|---| | directory or symlink (`ArtifactReaderFailure` `path`) | `artifact_operation_failed` | `invalid_request`, issue `path` / `invalid_format`, with the reader's message | | ENOENT / ENOTDIR | `artifact_operation_failed` | `invalid_request`, issue `path` / `invalid_value`, naming the code and path | | file changed during the read (`integrity`) | `artifact_operation_failed` | `AnalysisArtifactChangedError` | | limit, cancellation, EACCES/EPERM, other I/O | unchanged | unchanged | The mapping moved into `peResourcesFailure()`, which keeps `inspect` under the complexity limit. After the change: ```text $ rea inspect-pe-resources ./nope.bin --format json {"code":"invalid_request","category":"invalid_input",…,"details":{"operation":"inspect_pe_resources", "issues":[{"path":["path"],"reason":"invalid_value","message":"Selected PE image could not be read (ENOENT): …/nope.bin."}]}} ``` ## Verification - `tests/boundary/filesystem/peResources.test.ts` previously pinned `ArtifactOperationError` for these cases. It now asserts the typed issue for a directory, a symlink, a missing file and a path below a regular file (ENOTDIR). It fails against main's provider and passes here. - `npm run test:focused --` that test plus `src/native/pe/PeResourceParser.test.ts` and `src/application/binaryDiagnostics/PeResourcesService.test.ts`: 27 passed. `tests/acceptance/applications/peResources.test.ts` (CLI/MCP, after `build:cached`): passed. - Ran the built CLI on a missing path, a directory and an ENOTDIR path. - `npm run typecheck` and oxlint are clean on the changed files. jscpd is 2.485%. No Hopper/Ghidra involvement. 🤖 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-31 00:54:38 +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#4746
No description provided.