Skip to content

refactor(keyed): select FIT properties and certificate extensions through uniqueKeyed - #10875

Merged
morluto merged 1 commit into
refactor/macho-slice-selection-ownerfrom
refactor/keyed-fit-apk-lookups
Nov 15, 2026
Merged

morluto merged 1 commit into
refactor/macho-slice-selection-ownerfrom
refactor/keyed-fit-apk-lookups

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

The last two keyed-first-match baseline entries now select through uniqueKeyed. FIT reads a node property by name, and the APK v1 reader reads a certificate's extensions [3]. The baseline reaches zero. Refs plan W7; stacked on #10874.

Problem and expected behavior

  • FitStructure.propertyOf returned the first property with a name via node.properties.find(...).
  • apkV1SignatureBlock.certificateIdentity took the first [3] field of tbsCertificate via fields.find(...). Inside it, a repeated subjectKeyIdentifier extension silently let the last one win.

What a repeat means, by spec:

  • FDT property. The devicetree parser (DevicetreeParser.ts) already refuses a repeated property name in one node as malformed ("Empty or duplicate FDT property name"), matching dtc's duplicate_property_names error check. A repeat is malformed, not a limitation.
  • Context tag [3]. RFC 5280 §4.1 defines TBSCertificate as a SEQUENCE with at most one extensions [3] EXPLICIT. X.690 SEQUENCE components appear once, in order. RFC 5280 §4.2 says a certificate MUST NOT include more than one instance of a particular extension. A repeat is not a TBSCertificate: malformed for identity purposes.

Change and scope

  • FitStructure.propertyOf: uniqueKeyed(keyedBy(node.properties, name)). A repeat throws the reader's existing formatFailure ("FIT is malformed: declares property more than once"). The parser reaches that state first today, so this keeps the FIT reader's own rule explicit rather than first-wins.
  • apkV1SignatureBlock.certificateIdentity:
    • A repeated [3] throws malformed("tbsCertificate declares extensions more than once").
    • A second subjectKeyIdentifier extension throws the matching message.
    • Both land in the existing unavailableIdentityInterpretation path: the certificate is still reported, but it names no SignerInfo (certificateIndex: null).
  • Baseline: keyed-first-match loses FitStructure.ts and apkV1SignatureBlock.ts and is now empty.
  • Not included: other FIT child lookups by node name (cipher, hash*). Node names are unique per path by the same parser (Duplicate FDT node path), and the guard does not match them.

Contribution scope: not applicable (refactor inside existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/apkSignature/apkV1SignatureBlock.ts certificate identity; src/artifacts/fit/FitStructure.ts property access over the devicetree parser's nodes.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. An APK v1 certificate whose tbsCertificate repeats extensions [3] or subjectKeyIdentifier no longer identifies a signer.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: the certificate bytes are still reported; only the signer association is withheld.
  • 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: apkV1SignatureBlock.test.ts "names no certificate whose tbsCertificate repeats its extensions". It uses a new fixture helper, withRepeatedExtensions, in tests/fixtures/apkSignature/v1SignatureBlock.ts.
  • Base reproduction or other evidence: with the base apkV1SignatureBlock.ts restored, the new test fails (1 failed | 23 passed): the signer was associated with the first [3]. It passes with the change.
  • User-visible CLI/MCP output (if applicable): none for well-formed inputs.
  • Remaining proof gaps:
    • No test for a repeated subjectKeyIdentifier extension (source-derived).
    • The FIT duplicate-property branch is not reachable through the devicetree parser, which refuses the repeat first. The parser's refusal has no dedicated test today, and the FIT fixture writer cannot express a repeated property name.

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 check:fast — passed.
  • node scripts/verify/architecture-guards.mjs --shrink-baselines — passed; keyed-first-match baseline emptied.
  • npm run test:local -- src/domain/apkSignature/apkV1SignatureBlock.test.ts src/domain/apkSignature/apkV1Signature.test.ts src/apkSignature/apkV1Signers.test.ts — 46 passed.
  • npm run test:local -- src/artifacts/fit/FitStructure.test.ts — 32 passed.
  • npm run test:focused -- tests/boundary/filesystem/keyedFirstMatchGuard.test.ts src/native/AppleMachoSelection.test.ts src/native/MachoArchitectureSelection.test.ts src/domain/apkSignature/apkV1SignatureBlock.test.ts — 106 passed (after rebasing onto the collapsed refactor(native): select ELF sections through the keyed owner #10780).
  • Base check: new APK test against base apkV1SignatureBlock.ts — 1 failed, as expected.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none needed; parsers only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: a malformed certificate no longer names a signer by an arbitrary copy of its extensions.

Author readiness

Human owner:

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T07:42:35.457233Z 9a3b751 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable defects were found.

Summary

FIT property reads and APK certificate extension reads now use uniqueKeyed.

  • APK v1 signers stay unnamed when certificate extension fields repeat.
  • FIT reads now require one property for each name.

Reviews (2) · Last reviewed commit: "refactor(keyed): select FIT properties a..." · Reviewed by Greptile

@morluto
morluto merged commit b21fbba into refactor/macho-slice-selection-owner Nov 15, 2026
1 check passed
@morluto
morluto deleted the refactor/keyed-fit-apk-lookups branch November 15, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant