[PR #4418] [MERGED] fix(managed): report stream-name errors at file offsets #6226

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4418
Author: @duckhunt113
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @morluto

Base: main ← Head: fix/managed-stream-name-offsets


📝 Commits (1)

  • 09d647a fix(managed): report stream-name errors at file offsets

📊 Changes

2 files changed (+80 additions, -3 deletions)

View changed files

📝 src/dotnet/ManagedArtifactFailures.test.ts (+75 -0)
📝 src/dotnet/ManagedMetadataLayout.ts (+5 -3)

📄 Description

Summary

Fixes #4372.

Report artifact file offsets for malformed .NET metadata stream names.

Problem and expected behavior

When a metadata stream name contains non-printable ASCII or lacks a bounded
null terminator, REA reports its offset within the metadata root as though
it were an offset within the artifact file.

For example, a name 40 bytes into metadata starting at file offset 768
was reported at byte 40. The correct file offset is 808.

Change and scope

Pass the metadata root’s file offset into readStreamName and include it
in both malformed-name diagnostics. Keep parsing positions relative to
the metadata buffer.

This is a focused correction to existing format inspection and evidence
reporting. An advance maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: stream-name parsing in ManagedMetadataLayout.ts.
  • Contribution scope fit and linked maintainer decision: ordinary bug fix within existing inspection behavior; no advance decision required.
  • CLI and MCP/tool-catalog contract: no schema or tool-catalog changes. Diagnostics consumed by these workflows receive corrected offsets.
  • Provider, bridge, target-format, or platform compatibility: no provider or bridge changes; existing .NET PE parsing rules remain unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: coverage issue offsets and classification evidence now identify the stream name’s actual artifact file location.
  • Target selection, authority, upstream behavior, and cleanup details: no changes.
  • Generated metadata, package, or installation impact: none.

Expected effects of the affected inspection workflow:

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

The fix changes diagnostic locations only and adds no target execution,
mutation, network access, or cleanup behavior.

Evidence and regression coverage

  • Tests added or updated: four parameterized regression cases in ManagedArtifactFailures.test.ts, covering non-printable and unterminated names at two raw-section positions.
  • Base reproduction or other evidence: all four new cases failed before the fix, reporting 40 instead of 808 or 1320. All pass after the fix.
  • Assertions cover artifact coverage issues, classification evidence, and member-inspection diagnostics. Each case also verifies that the unmodified fixture parses with complete coverage.
  • User-visible CLI/MCP output: not exercised; verification used production inspectors directly.
  • Remaining proof gaps: synthetic PE fixtures were used. Compiled CLI/MCP workflows and real-provider integrations were not tested.

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

Executed on macOS using Node.js 24.18.0 and npm 11.16.0:

  • npm run test:focused -- src/dotnet/ManagedArtifactFailures.test.ts before the fix — four new regression cases failed; three existing tests passed.
  • npm run test:focused -- src/dotnet/ManagedArtifactFailures.test.ts src/dotnet/ManagedMetadataExtraData.test.ts after the fix — all 18 tests passed.
  • ./node_modules/.bin/vitest run src/dotnet — all 342 tests across 14 files passed.
  • npm run check — passed, including typechecking, lint, formatting, unused-code checks, metadata checks, and architecture guards. Lint reported warnings without errors.
  • npm run verify:test-discovery — all 1,415 test files discovered exactly once.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; incorrect diagnostic offsets are corrected.
  • Real Hopper/Ghidra, browser, or OS coverage: no real-provider workflows ran. Production-inspector tests ran on macOS with synthetic files.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new execution authority, target mutation, network behavior, or credential handling. The change preserves existing malformed-input rejection.

Author readiness

Human owner: @duckhunt113

  • 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/4418 **Author:** [@duckhunt113](https://github.com/duckhunt113) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/managed-stream-name-offsets` --- ### 📝 Commits (1) - [`09d647a`](https://github.com/morluto/rea/commit/09d647acb534f5506747bc272776ab8e5948f705) fix(managed): report stream-name errors at file offsets ### 📊 Changes **2 files changed** (+80 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedArtifactFailures.test.ts` (+75 -0) 📝 `src/dotnet/ManagedMetadataLayout.ts` (+5 -3) </details> ### 📄 Description ## Summary Fixes #4372. Report artifact file offsets for malformed .NET metadata stream names. ## Problem and expected behavior When a metadata stream name contains non-printable ASCII or lacks a bounded null terminator, REA reports its offset within the metadata root as though it were an offset within the artifact file. For example, a name 40 bytes into metadata starting at file offset 768 was reported at byte 40. The correct file offset is 808. ## Change and scope Pass the metadata root’s file offset into `readStreamName` and include it in both malformed-name diagnostics. Keep parsing positions relative to the metadata buffer. This is a focused correction to existing format inspection and evidence reporting. An advance maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: stream-name parsing in `ManagedMetadataLayout.ts`. - Contribution scope fit and linked maintainer decision: ordinary bug fix within existing inspection behavior; no advance decision required. - CLI and MCP/tool-catalog contract: no schema or tool-catalog changes. Diagnostics consumed by these workflows receive corrected offsets. - Provider, bridge, target-format, or platform compatibility: no provider or bridge changes; existing .NET PE parsing rules remain unchanged. - Evidence, artifact, provenance, or reconstruction contract: coverage issue offsets and classification evidence now identify the stream name’s actual artifact file location. - Target selection, authority, upstream behavior, and cleanup details: no changes. - Generated metadata, package, or installation impact: none. Expected effects of the affected inspection workflow: - [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. The fix changes diagnostic locations only and adds no target execution, mutation, network access, or cleanup behavior. ## Evidence and regression coverage - Tests added or updated: four parameterized regression cases in `ManagedArtifactFailures.test.ts`, covering non-printable and unterminated names at two raw-section positions. - Base reproduction or other evidence: all four new cases failed before the fix, reporting 40 instead of 808 or 1320. All pass after the fix. - Assertions cover artifact coverage issues, classification evidence, and member-inspection diagnostics. Each case also verifies that the unmodified fixture parses with complete coverage. - User-visible CLI/MCP output: not exercised; verification used production inspectors directly. - Remaining proof gaps: synthetic PE fixtures were used. Compiled CLI/MCP workflows and real-provider integrations were not tested. 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 Executed on macOS using Node.js 24.18.0 and npm 11.16.0: - `npm run test:focused -- src/dotnet/ManagedArtifactFailures.test.ts` before the fix — four new regression cases failed; three existing tests passed. - `npm run test:focused -- src/dotnet/ManagedArtifactFailures.test.ts src/dotnet/ManagedMetadataExtraData.test.ts` after the fix — all 18 tests passed. - `./node_modules/.bin/vitest run src/dotnet` — all 342 tests across 14 files passed. - `npm run check` — passed, including typechecking, lint, formatting, unused-code checks, metadata checks, and architecture guards. Lint reported warnings without errors. - `npm run verify:test-discovery` — all 1,415 test files discovered exactly once. - `git diff --check` — passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none; incorrect diagnostic offsets are corrected. - Real Hopper/Ghidra, browser, or OS coverage: no real-provider workflows ran. Production-inspector tests ran on macOS with synthetic files. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new execution authority, target mutation, network behavior, or credential handling. The change preserves existing malformed-input rejection. ## Author readiness Human owner: @duckhunt113 - [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:12:51 +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#6226
No description provided.