[PR #5888] [CLOSED] fix(native): keep Ghidra data labels out of Objective-C class names #7101

Closed
opened 2026-11-01 21:45:23 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5888
Author: @harshdazz
Created: 10/21/2026
Status: ❌ Closed

Base: main ← Head: fix/objc-class-symbols-ghidra-labels


📝 Commits (1)

  • be4a709 fix(native): keep Ghidra data labels out of Objective-C class names

📊 Changes

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

View changed files

📝 src/domain/native/objcSwiftMetadata.test.ts (+31 -0)
📝 src/domain/native/objcSwiftMetadata.ts (+6 -3)

📄 Description

Summary

Part of #5424 (the first point under its expected behavior). The symbol fallback in inspectNativeDispatchMetadata matched OBJC_CLASS_$_ anywhere in a name, so Ghidra's own labels for class-reference pointers and symbol strings (PTR__OBJC_CLASS_$_NSAlert_100028668, s__OBJC_CLASS_$_NSAlert_10002ed0d) became extra classes. In the issue's run that was 102 of 153 reported classes.

Problem and expected behavior

The class match at src/domain/native/objcSwiftMetadata.ts:412 was unanchored: /(?:OBJC_CLASS_|OBJC_METACLASS_)\$_([^\s]+)/u. Whatever followed $_ in any label became a class name, address suffix included. Expected, from the issue: only names that are the class symbol itself count, optionally after a library prefix like …/AppKit::_OBJC_CLASS_$_NSAlert.

Change and scope

The regex is now anchored: ^(?:.*::)?_?(?:OBJC_CLASS_|OBJC_METACLASS_)\$_([^\s]+)$. A name has to start with the class symbol (with or without the leading _), or have it right after a :: namespace. That covers the plain symbols in the repo's fixtures and the qualified names Ghidra's bridge returns (symbol.getName(true) in ReaGhidraBridge.java). PTR__… and s__… labels don't match anymore.

I didn't add a helper for this. The closest existing ones are CLASS_SYMBOL in src/native/AppleObjcCategories.ts and the check in AppleObjcClassImportBindings.ts, but domain can't import from native, and neither accepts the Library:: prefix. So I anchored the existing regex in the same shape.

Not included: the issue's other two points (recognising Ghidra's Class::selector method labels for the binary's own classes, and splitting imported from defined classes). Those change what the fallback reports rather than fixing a wrong match, so I left them for a separate change.

Contribution scope: not applicable, fix inside existing boundaries.

Contract and boundary impact

  • Semantic owner and earliest changed stage: inspectNativeDispatchMetadata symbol fallback (domain), class-name derivation from the provider name inventory
  • Contribution scope fit and linked maintainer decision: not applicable, routine fix
  • CLI and MCP/tool-catalog contract: no schema change. objc_classes and the objc_class_symbols decoded count drop the label-derived entries.
  • Provider, bridge, target-format, or platform compatibility: affects the symbol fallback for every provider's list_names. Plain _OBJC_CLASS_$_X / OBJC_CLASS_$_X / OBJC_METACLASS_$_X and Library::-qualified names still match.
  • Evidence, artifact, provenance, or reconstruction contract: fewer false class records; real ones unchanged
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable
  • 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: src/domain/native/objcSwiftMetadata.test.ts, new test "derives classes only from class symbols, not provider labels that embed them". It feeds a plain _OBJC_CLASS_$_NSAlert, an OBJC_METACLASS_$_StoreController, an AppKit-qualified …::_OBJC_CLASS_$_NSWindow, and the three Ghidra labels from the issue, and expects exactly NSAlert, NSWindow, StoreController with examined: 6, decoded: 3.
  • Base reproduction or other evidence: on 5eebe2fdf without the fix, the new test fails with the three label classes from the issue in the result (NSAlert_100028668, NSAlert_10002ed0d, NSAppleEventManage_10002ed23). With the fix it passes. Source-level only; I didn't run Ghidra on a real app.
  • User-visible CLI/MCP output (if applicable): not run against a real Ghidra project.
  • Remaining proof gaps: no real Ghidra run, no macOS. Other providers' name formats checked against the repo's fixtures only.

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

On Windows 11, Node 22.19.0:

  • npx vitest run src/domain/native/objcSwiftMetadata.test.ts: 1 failed / 3 passed without the fix, 4 passed with it
  • 18 test files that touch dispatch metadata or class names: 310 passed, 12 failed, 5 skipped. The 12 are all in tests/boundary/providers/native/nativeProvider.test.ts and fail the same way on clean main on Windows.
  • npm run typecheck, npm run lint, npx oxfmt --check (changed files), npm run verify:test-discovery: passed. The two oxlint warnings on inspectNativeDispatchMetadata (complexity, function length) are already there on main.

On WSL Ubuntu, Node 24.18.0:

  • npm run test:focused -- src/domain/native/objcSwiftMetadata.test.ts: 1 failed / 3 passed on 5eebe2fdf without the fix, 4 passed with it
  • npm run test:focused on the same 18 files: 323 passed, 4 skipped (the nativeProvider.test.ts tests that fail on Windows pass here)
  • npm run check: passed (6 of 6 tasks, architecture guards passed)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Callers only stop seeing classes that came from data labels.
  • Real Hopper/Ghidra, browser, or OS coverage: none real. Windows 11 and Linux (WSL) unit and boundary tests only.
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner: @harshdazz

  • 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/5888 **Author:** [@harshdazz](https://github.com/harshdazz) **Created:** 10/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/objc-class-symbols-ghidra-labels` --- ### 📝 Commits (1) - [`be4a709`](https://github.com/morluto/rea/commit/be4a70904f1c54568ebeb780a6d4599d04552e23) fix(native): keep Ghidra data labels out of Objective-C class names ### 📊 Changes **2 files changed** (+37 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/native/objcSwiftMetadata.test.ts` (+31 -0) 📝 `src/domain/native/objcSwiftMetadata.ts` (+6 -3) </details> ### 📄 Description ## Summary Part of #5424 (the first point under its expected behavior). The symbol fallback in `inspectNativeDispatchMetadata` matched `OBJC_CLASS_$_` anywhere in a name, so Ghidra's own labels for class-reference pointers and symbol strings (`PTR__OBJC_CLASS_$_NSAlert_100028668`, `s__OBJC_CLASS_$_NSAlert_10002ed0d`) became extra classes. In the issue's run that was 102 of 153 reported classes. ## Problem and expected behavior The class match at `src/domain/native/objcSwiftMetadata.ts:412` was unanchored: `/(?:OBJC_CLASS_|OBJC_METACLASS_)\$_([^\s]+)/u`. Whatever followed `$_` in any label became a class name, address suffix included. Expected, from the issue: only names that are the class symbol itself count, optionally after a library prefix like `…/AppKit::_OBJC_CLASS_$_NSAlert`. ## Change and scope The regex is now anchored: `^(?:.*::)?_?(?:OBJC_CLASS_|OBJC_METACLASS_)\$_([^\s]+)$`. A name has to start with the class symbol (with or without the leading `_`), or have it right after a `::` namespace. That covers the plain symbols in the repo's fixtures and the qualified names Ghidra's bridge returns (`symbol.getName(true)` in `ReaGhidraBridge.java`). `PTR__…` and `s__…` labels don't match anymore. I didn't add a helper for this. The closest existing ones are `CLASS_SYMBOL` in `src/native/AppleObjcCategories.ts` and the check in `AppleObjcClassImportBindings.ts`, but `domain` can't import from `native`, and neither accepts the `Library::` prefix. So I anchored the existing regex in the same shape. Not included: the issue's other two points (recognising Ghidra's `Class::selector` method labels for the binary's own classes, and splitting imported from defined classes). Those change what the fallback reports rather than fixing a wrong match, so I left them for a separate change. Contribution scope: not applicable, fix inside existing boundaries. ## Contract and boundary impact - Semantic owner and earliest changed stage: `inspectNativeDispatchMetadata` symbol fallback (domain), class-name derivation from the provider name inventory - Contribution scope fit and linked maintainer decision: not applicable, routine fix - CLI and MCP/tool-catalog contract: no schema change. `objc_classes` and the `objc_class_symbols` decoded count drop the label-derived entries. - Provider, bridge, target-format, or platform compatibility: affects the symbol fallback for every provider's `list_names`. Plain `_OBJC_CLASS_$_X` / `OBJC_CLASS_$_X` / `OBJC_METACLASS_$_X` and `Library::`-qualified names still match. - Evidence, artifact, provenance, or reconstruction contract: fewer false class records; real ones unchanged - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable - 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: `src/domain/native/objcSwiftMetadata.test.ts`, new test "derives classes only from class symbols, not provider labels that embed them". It feeds a plain `_OBJC_CLASS_$_NSAlert`, an `OBJC_METACLASS_$_StoreController`, an AppKit-qualified `…::_OBJC_CLASS_$_NSWindow`, and the three Ghidra labels from the issue, and expects exactly `NSAlert`, `NSWindow`, `StoreController` with `examined: 6, decoded: 3`. - Base reproduction or other evidence: on `5eebe2fdf` without the fix, the new test fails with the three label classes from the issue in the result (`NSAlert_100028668`, `NSAlert_10002ed0d`, `NSAppleEventManage_10002ed23`). With the fix it passes. Source-level only; I didn't run Ghidra on a real app. - User-visible CLI/MCP output (if applicable): not run against a real Ghidra project. - Remaining proof gaps: no real Ghidra run, no macOS. Other providers' name formats checked against the repo's fixtures only. 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 On Windows 11, Node 22.19.0: - `npx vitest run src/domain/native/objcSwiftMetadata.test.ts`: 1 failed / 3 passed without the fix, 4 passed with it - 18 test files that touch dispatch metadata or class names: 310 passed, 12 failed, 5 skipped. The 12 are all in `tests/boundary/providers/native/nativeProvider.test.ts` and fail the same way on clean `main` on Windows. - `npm run typecheck`, `npm run lint`, `npx oxfmt --check` (changed files), `npm run verify:test-discovery`: passed. The two oxlint warnings on `inspectNativeDispatchMetadata` (complexity, function length) are already there on `main`. On WSL Ubuntu, Node 24.18.0: - `npm run test:focused -- src/domain/native/objcSwiftMetadata.test.ts`: 1 failed / 3 passed on `5eebe2fdf` without the fix, 4 passed with it - `npm run test:focused` on the same 18 files: 323 passed, 4 skipped (the `nativeProvider.test.ts` tests that fail on Windows pass here) - `npm run check`: passed (6 of 6 tasks, architecture guards passed) ## Compatibility, safety, and release - Breaking changes or migration steps: none. Callers only stop seeing classes that came from data labels. - Real Hopper/Ghidra, browser, or OS coverage: none real. Windows 11 and Linux (WSL) unit and boundary tests only. - Package or release metadata impact: none - Security, privacy, process, or containment review: none ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @harshdazz - [ ] 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 <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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-11-01 21:45:23 +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#7101
No description provided.