[PR #4801] [CLOSED] fix(native): report PE resource subject architecture #6418

Closed
opened 2026-10-31 01:14:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4801
Author: @AniketR10
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/pe-resources-subject-architecture


📝 Commits (4)

  • c5654bb fix(native): report PE resource subject architecture
  • 22086d1 refactor(native): match PE machine handling to fuse inspection
  • 43e7143 fix(native): keep conflicting PE resource headers unknown
  • 250c9d7 Merge remote-tracking branch 'upstream/main' into fix/pe-resources-subject-architecture

📊 Changes

5 files changed (+61 additions, -5 deletions)

View changed files

📝 src/application/binaryDiagnostics/PeResourcesService.test.ts (+23 -0)
📝 src/application/binaryDiagnostics/PeResourcesService.ts (+24 -0)
📝 src/domain/binaryTarget.ts (+7 -5)
📝 src/domain/peMachine.ts (+6 -0)
📝 tests/acceptance/applications/peResources.test.ts (+1 -0)

📄 Description

Summary

Fixes #4800

inspect-pe-resources now reports subject.architecture from the COFF machine it already parses, like the other PE readers. Before, it was always null.

Problem and expected behavior

PeResourcesService built the Evidence subject without an architecture, although the report carries machine. Expected: a recognized machine names the architecture (x86, x86_64, arm, arm64); anything else stays unknown.

Change and scope

  • PeResourcesService maps report.machine through the domain owner decodePeMachine.
  • The architecture stays unknown when the machine is unrecognized, when it is a ReadyToRun OS-override machine (the resource reader does not inspect the CLI header, so it cannot confirm a managed image), or when the optional-header magic the report already carries contradicts the machine (for example AMD64 with PE32 magic).
  • The machine-to-magic rule was private to binaryTarget.ts. It moves to peMachine.ts as peOptionalHeaderMagic, next to decodePeMachine, and both the binary-target parser and this service use it, so the rule has one owner.
  • Not included: no change to the resource parser, the report schema, or resource output.

Contribution scope: ordinary fix within the existing read-only boundary; maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: decodePeMachine (domain) owns machine names; the change is in the Evidence subject projection in PeResourcesService.
  • Contribution scope fit and linked maintainer decision: fits existing scope; not applicable.
  • CLI and MCP/tool-catalog contract: schema unchanged; subject.architecture was already optional and is now filled when known.
  • Provider, bridge, target-format, or platform compatibility: PE32/PE32+ only; unchanged otherwise.
  • Evidence, artifact, provenance, or reconstruction contract: subject gains the architecture; normalized_result is unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged.
  • 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: PeResourcesService.test.ts adds a case table (i386 PE32 → x86, ARM64 PE32+ → arm64; AMD64 with PE32 magic, i386 with PE32+ magic, a ReadyToRun Linux override, and an unknown machine → unknown). The existing binaryTarget.test.ts case "rejects malformed PE optional-header commitments" covers the shared rule on the parser side.. tests/acceptance/applications/peResources.test.ts now asserts the subject architecture for its PE32 (x86) and PE32+ (x86_64) CLI fixtures.

  • Base reproduction (executed): with the service change reverted, the two known-architecture service cases fail (expected null to be 'x86' / 'arm64'); the three unknown cases pass.

  • User-visible CLI output (executed, built CLI, real PE files from npm packages):

    File machine before after
    fastlist-0.3.0-x86.exe 332 null x86
    clipboard_x86_64.exe 34404 null x86_64
    clipboard_aarch64.exe 43620 null arm64
    winpty.dll 34404 null x86_64
  • Remaining proof gaps: MCP output for the subject was not asserted separately (it goes through the same service, and the acceptance test's MCP path still passes). Not run on Windows. Costs not measured; the change adds no I/O.

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

  • npm run test:focused -- src/application/binaryDiagnostics/PeResourcesService.test.ts tests/acceptance/applications/peResources.test.ts src/domain/binaryTarget.test.ts tests/boundary/filesystem/binaryTarget.test.ts tests/boundary/filesystem/peResources.test.ts src/electron/ElectronFuseArchitecture.test.ts, after merging current main: 6 files, 134 passed, 1 skipped.
  • Same service test with the fix reverted: 2 failed, 9 passed.
  • npm run check:fast: passed.
  • npm run format:check: changed files clean. One unrelated file already unformatted on main (tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts) is still reported.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; Linux only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: read-only; no new reads or side effects.

Author readiness

Human owner: @AniketR10

  • 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/4801 **Author:** [@AniketR10](https://github.com/AniketR10) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/pe-resources-subject-architecture` --- ### 📝 Commits (4) - [`c5654bb`](https://github.com/morluto/rea/commit/c5654bb8a8b49e792f8fc58b898b92fac0105379) fix(native): report PE resource subject architecture - [`22086d1`](https://github.com/morluto/rea/commit/22086d1d5d9c7b16e2552fbc358cd243ca3fb682) refactor(native): match PE machine handling to fuse inspection - [`43e7143`](https://github.com/morluto/rea/commit/43e71439597fb0ac14a74720fa4482280c47f9bf) fix(native): keep conflicting PE resource headers unknown - [`250c9d7`](https://github.com/morluto/rea/commit/250c9d726f23c9c13d632581c48e67a987717b0c) Merge remote-tracking branch 'upstream/main' into fix/pe-resources-subject-architecture ### 📊 Changes **5 files changed** (+61 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/application/binaryDiagnostics/PeResourcesService.test.ts` (+23 -0) 📝 `src/application/binaryDiagnostics/PeResourcesService.ts` (+24 -0) 📝 `src/domain/binaryTarget.ts` (+7 -5) 📝 `src/domain/peMachine.ts` (+6 -0) 📝 `tests/acceptance/applications/peResources.test.ts` (+1 -0) </details> ### 📄 Description ## Summary Fixes #4800 `inspect-pe-resources` now reports `subject.architecture` from the COFF machine it already parses, like the other PE readers. Before, it was always `null`. ## Problem and expected behavior `PeResourcesService` built the Evidence subject without an architecture, although the report carries `machine`. Expected: a recognized machine names the architecture (`x86`, `x86_64`, `arm`, `arm64`); anything else stays unknown. ## Change and scope - `PeResourcesService` maps `report.machine` through the domain owner `decodePeMachine`. - The architecture stays unknown when the machine is unrecognized, when it is a ReadyToRun OS-override machine (the resource reader does not inspect the CLI header, so it cannot confirm a managed image), or when the optional-header magic the report already carries contradicts the machine (for example AMD64 with PE32 magic). - The machine-to-magic rule was private to `binaryTarget.ts`. It moves to `peMachine.ts` as `peOptionalHeaderMagic`, next to `decodePeMachine`, and both the binary-target parser and this service use it, so the rule has one owner. - Not included: no change to the resource parser, the report schema, or resource output. Contribution scope: ordinary fix within the existing read-only boundary; maintainer scope decision not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `decodePeMachine` (domain) owns machine names; the change is in the Evidence subject projection in `PeResourcesService`. - Contribution scope fit and linked maintainer decision: fits existing scope; not applicable. - CLI and MCP/tool-catalog contract: schema unchanged; `subject.architecture` was already optional and is now filled when known. - Provider, bridge, target-format, or platform compatibility: PE32/PE32+ only; unchanged otherwise. - Evidence, artifact, provenance, or reconstruction contract: subject gains the architecture; `normalized_result` is unchanged. - Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged. - 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. - [ ] 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: `PeResourcesService.test.ts` adds a case table (i386 PE32 → `x86`, ARM64 PE32+ → `arm64`; AMD64 with PE32 magic, i386 with PE32+ magic, a ReadyToRun Linux override, and an unknown machine → unknown). The existing `binaryTarget.test.ts` case "rejects malformed PE optional-header commitments" covers the shared rule on the parser side.. `tests/acceptance/applications/peResources.test.ts` now asserts the subject architecture for its PE32 (`x86`) and PE32+ (`x86_64`) CLI fixtures. - Base reproduction (executed): with the service change reverted, the two known-architecture service cases fail (`expected null to be 'x86'` / `'arm64'`); the three unknown cases pass. - User-visible CLI output (executed, built CLI, real PE files from npm packages): | File | `machine` | before | after | | --- | --- | --- | --- | | `fastlist-0.3.0-x86.exe` | 332 | `null` | `x86` | | `clipboard_x86_64.exe` | 34404 | `null` | `x86_64` | | `clipboard_aarch64.exe` | 43620 | `null` | `arm64` | | `winpty.dll` | 34404 | `null` | `x86_64` | - Remaining proof gaps: MCP output for the subject was not asserted separately (it goes through the same service, and the acceptance test's MCP path still passes). Not run on Windows. Costs not measured; the change adds no I/O. 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 - `npm run test:focused -- src/application/binaryDiagnostics/PeResourcesService.test.ts tests/acceptance/applications/peResources.test.ts src/domain/binaryTarget.test.ts tests/boundary/filesystem/binaryTarget.test.ts tests/boundary/filesystem/peResources.test.ts src/electron/ElectronFuseArchitecture.test.ts`, after merging current `main`: 6 files, 134 passed, 1 skipped. - Same service test with the fix reverted: 2 failed, 9 passed. - `npm run check:fast`: passed. - `npm run format:check`: changed files clean. One unrelated file already unformatted on `main` (`tests/boundary/cli/keyedArchivePrototypeKeyCli.test.ts`) is still reported. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; Linux only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: read-only; no new reads or side effects. ## Author readiness Human owner: @AniketR10 - [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 - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:14:19 +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#6418
No description provided.