[PR #4472] [CLOSED] fix(native): reject empty Swift protocol or type names in conformance descriptors #6262

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4472
Author: @kevinjosh10
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-4368-empty-swift-conformance-names


📝 Commits (2)

  • 316d68a fix(native): reject empty Swift protocol or type names in conformance descriptors
  • f4d50fc test(native): restore witness slot facts assertion and verify valid sibling conformance survival

📊 Changes

2 files changed (+110 additions, -0 deletions)

View changed files

📝 src/native/AppleSwiftDispatchFacets.ts (+8 -0)
📝 src/native/AppleSwiftVtables.test.ts (+102 -0)

📄 Description

Summary

Fixes #4368.

When decoding __swift5_proto conformances in decodeSwiftDispatchFacets, an empty protocol name or type name ("") was accepted without validation and added into result.swift_conformances. Because swiftConformanceSchema requires type_name: z.string().min(1) and protocol_name: z.string().min(1), whole-result validation in decodeAppleDispatchMetadata failed with a ZodError outside the per-conformance recovery block, causing the entire metadata operation to throw and losing independently collected dispatch metadata.

This PR adds explicit validation for non-empty protocol and type names in src/native/AppleSwiftDispatchFacets.ts, allowing descriptor-level error recovery to record partial coverage and retain all other independently collected metadata.

Problem and expected behavior

  • Observed behavior: A Swift conformance descriptor resolving to an empty protocol or type name string caused whole-result validation to fail (too_small at swift_conformances[...].type_name or protocol_name), failing the operation and discarding independently decoded records.
  • Expected behavior: Malformed conformance descriptors with empty protocol or type names should be caught by per-conformance recovery, recorded as conformance_decode_failed with partial coverage, while valid independent conformances and records are retained.

Change and scope

  • Added if (protocolName.length === 0) throw new TypeError("Empty Swift protocol name in conformance descriptor"); in src/native/AppleSwiftDispatchFacets.ts.
  • Added if (typeName.length === 0) throw new TypeError("Empty Swift type name in conformance descriptor"); in src/native/AppleSwiftDispatchFacets.ts.
  • Added unit tests in src/native/AppleSwiftVtables.test.ts verifying that empty protocol and type names are caught and reported as conformance_decode_failed while preserving coverage.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Swift protocol conformance descriptor decoder (AppleSwiftDispatchFacets.ts)

  • Contribution scope fit and linked maintainer decision: Not applicable (pure native bug fix within existing contract)

  • CLI and MCP/tool-catalog contract: none

  • Provider, bridge, target-format, or platform compatibility: all platforms

  • Evidence, artifact, provenance, or reconstruction contract: none

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none

  • Generated metadata impact: none

  • 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/native/AppleSwiftVtables.test.ts
  • Base reproduction or other evidence: Verified that empty protocol and type names trigger entry recovery and record conformance_decode_failed without throwing whole-result ZodErrors.
  • User-visible CLI/MCP output (if applicable): none
  • Remaining proof gaps: none

Validation performed

  • npm run test:local -- src/native/AppleSwiftVtables.test.ts — 5 passed (100%)
  • npm run test:local -- src/native/AppleDispatchMetadata.test.ts — 43 passed (100%)
  • npx turbo run typecheck lint --force — 2 tasks successful (0 errors)
  • npm run format:check — All 3765 files formatted properly

Compatibility, safety, and release

  • Breaking changes or migration steps: None
  • Real Hopper/Ghidra, browser, or OS coverage: Platform-independent Mach-O static byte decoding
  • Package or release metadata impact: None
  • Security, privacy, process, or containment review: Pure metadata validation fix

Author readiness

Human owner: @kevinjosh10

  • 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/4472 **Author:** [@kevinjosh10](https://github.com/kevinjosh10) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-4368-empty-swift-conformance-names` --- ### 📝 Commits (2) - [`316d68a`](https://github.com/morluto/rea/commit/316d68a168fa84a4a48b2e13e7d5642f7e31c9c5) fix(native): reject empty Swift protocol or type names in conformance descriptors - [`f4d50fc`](https://github.com/morluto/rea/commit/f4d50fc60eb8ab94e4ac190c2f558b8295e5283e) test(native): restore witness slot facts assertion and verify valid sibling conformance survival ### 📊 Changes **2 files changed** (+110 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/native/AppleSwiftDispatchFacets.ts` (+8 -0) 📝 `src/native/AppleSwiftVtables.test.ts` (+102 -0) </details> ### 📄 Description ## Summary Fixes #4368. When decoding `__swift5_proto` conformances in `decodeSwiftDispatchFacets`, an empty protocol name or type name (`""`) was accepted without validation and added into `result.swift_conformances`. Because `swiftConformanceSchema` requires `type_name: z.string().min(1)` and `protocol_name: z.string().min(1)`, whole-result validation in `decodeAppleDispatchMetadata` failed with a `ZodError` outside the per-conformance recovery block, causing the entire metadata operation to throw and losing independently collected dispatch metadata. This PR adds explicit validation for non-empty protocol and type names in `src/native/AppleSwiftDispatchFacets.ts`, allowing descriptor-level error recovery to record partial coverage and retain all other independently collected metadata. ## Problem and expected behavior - **Observed behavior**: A Swift conformance descriptor resolving to an empty protocol or type name string caused whole-result validation to fail (`too_small` at `swift_conformances[...].type_name` or `protocol_name`), failing the operation and discarding independently decoded records. - **Expected behavior**: Malformed conformance descriptors with empty protocol or type names should be caught by per-conformance recovery, recorded as `conformance_decode_failed` with partial coverage, while valid independent conformances and records are retained. ## Change and scope - Added `if (protocolName.length === 0) throw new TypeError("Empty Swift protocol name in conformance descriptor");` in `src/native/AppleSwiftDispatchFacets.ts`. - Added `if (typeName.length === 0) throw new TypeError("Empty Swift type name in conformance descriptor");` in `src/native/AppleSwiftDispatchFacets.ts`. - Added unit tests in `src/native/AppleSwiftVtables.test.ts` verifying that empty protocol and type names are caught and reported as `conformance_decode_failed` while preserving coverage. ## Contract and boundary impact - Semantic owner and earliest changed stage: Swift protocol conformance descriptor decoder (`AppleSwiftDispatchFacets.ts`) - Contribution scope fit and linked maintainer decision: Not applicable (pure native bug fix within existing contract) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: all platforms - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details (if applicable): none - Generated metadata impact: none - [ ] 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/native/AppleSwiftVtables.test.ts` - Base reproduction or other evidence: Verified that empty protocol and type names trigger entry recovery and record `conformance_decode_failed` without throwing whole-result ZodErrors. - User-visible CLI/MCP output (if applicable): none - Remaining proof gaps: none ## Validation performed - `npm run test:local -- src/native/AppleSwiftVtables.test.ts` — 5 passed (100%) - `npm run test:local -- src/native/AppleDispatchMetadata.test.ts` — 43 passed (100%) - `npx turbo run typecheck lint --force` — 2 tasks successful (0 errors) - `npm run format:check` — All 3765 files formatted properly ## Compatibility, safety, and release - Breaking changes or migration steps: None - Real Hopper/Ghidra, browser, or OS coverage: Platform-independent Mach-O static byte decoding - Package or release metadata impact: None - Security, privacy, process, or containment review: Pure metadata validation fix ## Author readiness Human owner: @kevinjosh10 - [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:13:07 +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#6262
No description provided.