[PR #4120] [CLOSED] fix(native): record an empty Objective-C category name as a category failure #6070

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4120
Author: @Ali-Tharwat
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/objc-empty-category-name


📝 Commits (1)

  • 11c03c3 fix(native): record an empty Objective-C category name as a category failure

📊 Changes

2 files changed (+39 additions, -2 deletions)

View changed files

📝 src/native/AppleDispatchMetadata.test.ts (+37 -2)
📝 src/native/AppleObjcCategories.ts (+2 -0)

📄 Description

Summary

A category declaration whose name is an empty (NUL-only) string was accepted as decoded, causing final objcSwiftMetadataSchema.parse validation of objc_categories[].name to fail with ZodError (too_small, minimum 1) and decodeAppleDispatchMetadata to discard all independently decoded classes from the same image. The category decoder now rejects the empty name inside its per-category boundary, mirroring the protocol decoder fix from #4078, so the malformed category is recorded as a partial-coverage failure (category_decode_failed) and valid classes are retained.

Fixes #4115

Problem and expected behavior

In Mach-O targets where __objc_catlist contains a category with an empty name, read.string(read.pointer(category)) returns "". This passed through the per-category try/catch and populated result.objc_categories. At the end of analysis, objcSwiftMetadataSchema.parse(result) threw a ZodError on objc_categories[0].name, aborting metadata inspection and discarding all decoded classes.

Expected: The category decoder rejects the empty name inside the per-category boundary, records an issue with code: category_decode_failed, and preserves valid classes in the same binary image.

Change and scope

  • Added an empty name check (if (name.length === 0) throw new TypeError("Objective-C category has an empty name");) in src/native/AppleObjcCategories.ts inside the per-category try block.
  • The thrown error is caught by the existing catch block, recording category_decode_failed with the empty name message and marking objc_properties_categories facet coverage as partial.
  • Added regression test keeps classes when a category has an empty name to src/native/AppleDispatchMetadata.test.ts.

Scope: Ordinary fix within the native Mach-O metadata parser boundary; no maintainer scope decision required.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/native/AppleObjcCategories.ts (category parser stage).
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: unchanged schema; preserves valid classes and returns partial category coverage on malformed names.
  • Provider, bridge, target-format, or platform compatibility: Mach-O Objective-C metadata parsing.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: none.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added or updated: src/native/AppleDispatchMetadata.test.ts (keeps classes when a category has an empty name).
  • Base reproduction: The test fails on the base revision with ZodError: [ { origin: 'string', code: 'too_small', minimum: 1, path: [ 'objc_categories', 0, 'name' ] } ].
  • Remaining proof gaps: none.

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/native/AppleDispatchMetadata.test.ts — 43 passed (including new reproduction test).
  • npm run test:focused -- src/native/AppleDispatchMetadata.test.ts src/native/AppleMachoFixups.test.ts src/native/AppleMachoSelection.test.ts src/native/AppleSwiftVtables.test.ts src/native/NativeCallObservation.test.ts src/native/NativeMacOSProviderInput.test.ts src/native/NativeMachoInspection.test.ts src/native/NativeUiObservation.test.ts src/native/SignatureTargetBinding.test.ts — 147 passed.
  • npm run check:fast — typecheck and lint passed.
  • npm run docs:check — documentation and license checks passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: in-memory Mach-O parser verification on Windows host.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: safe bounds-checked metadata parser change.

Author readiness

Human owner: @Ali-Tharwat

  • 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/4120 **Author:** [@Ali-Tharwat](https://github.com/Ali-Tharwat) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/objc-empty-category-name` --- ### 📝 Commits (1) - [`11c03c3`](https://github.com/morluto/rea/commit/11c03c3bc9b77cabf53148459fc56d688e147190) fix(native): record an empty Objective-C category name as a category failure ### 📊 Changes **2 files changed** (+39 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/native/AppleDispatchMetadata.test.ts` (+37 -2) 📝 `src/native/AppleObjcCategories.ts` (+2 -0) </details> ### 📄 Description ## Summary A category declaration whose name is an empty (NUL-only) string was accepted as decoded, causing final `objcSwiftMetadataSchema.parse` validation of `objc_categories[].name` to fail with `ZodError` (`too_small`, minimum 1) and `decodeAppleDispatchMetadata` to discard all independently decoded classes from the same image. The category decoder now rejects the empty name inside its per-category boundary, mirroring the protocol decoder fix from #4078, so the malformed category is recorded as a partial-coverage failure (`category_decode_failed`) and valid classes are retained. Fixes #4115 ## Problem and expected behavior In Mach-O targets where `__objc_catlist` contains a category with an empty name, `read.string(read.pointer(category))` returns `""`. This passed through the per-category `try/catch` and populated `result.objc_categories`. At the end of analysis, `objcSwiftMetadataSchema.parse(result)` threw a `ZodError` on `objc_categories[0].name`, aborting metadata inspection and discarding all decoded classes. Expected: The category decoder rejects the empty name inside the per-category boundary, records an issue with `code: category_decode_failed`, and preserves valid classes in the same binary image. ## Change and scope - Added an empty name check (`if (name.length === 0) throw new TypeError("Objective-C category has an empty name");`) in `src/native/AppleObjcCategories.ts` inside the per-category try block. - The thrown error is caught by the existing catch block, recording `category_decode_failed` with the empty name message and marking `objc_properties_categories` facet coverage as `partial`. - Added regression test `keeps classes when a category has an empty name` to `src/native/AppleDispatchMetadata.test.ts`. Scope: Ordinary fix within the native Mach-O metadata parser boundary; no maintainer scope decision required. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/native/AppleObjcCategories.ts` (category parser stage). - Contribution scope fit and linked maintainer decision: not applicable. - CLI and MCP/tool-catalog contract: unchanged schema; preserves valid classes and returns partial category coverage on malformed names. - Provider, bridge, target-format, or platform compatibility: Mach-O Objective-C metadata parsing. - Evidence, artifact, provenance, or reconstruction contract: unchanged. - Target selection, authority, upstream behavior, and cleanup details: none. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Documentation or usability only; no target interaction. ## Evidence and regression coverage - Tests added or updated: `src/native/AppleDispatchMetadata.test.ts` (`keeps classes when a category has an empty name`). - Base reproduction: The test fails on the base revision with `ZodError: [ { origin: 'string', code: 'too_small', minimum: 1, path: [ 'objc_categories', 0, 'name' ] } ]`. - Remaining proof gaps: none. 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 - `npm run test:focused -- src/native/AppleDispatchMetadata.test.ts` — 43 passed (including new reproduction test). - `npm run test:focused -- src/native/AppleDispatchMetadata.test.ts src/native/AppleMachoFixups.test.ts src/native/AppleMachoSelection.test.ts src/native/AppleSwiftVtables.test.ts src/native/NativeCallObservation.test.ts src/native/NativeMacOSProviderInput.test.ts src/native/NativeMachoInspection.test.ts src/native/NativeUiObservation.test.ts src/native/SignatureTargetBinding.test.ts` — 147 passed. - `npm run check:fast` — typecheck and lint passed. - `npm run docs:check` — documentation and license checks passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: in-memory Mach-O parser verification on Windows host. - Package or release metadata impact: none. - Security, privacy, process, or containment review: safe bounds-checked metadata parser change. ## Author readiness Human owner: @Ali-Tharwat - [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-10-31 01:11:37 +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#6070
No description provided.