Files
rea/src/native/AppleDispatchCoverage.ts
T
a67525cdf1 docs: organize canonical documentation layout and verify new pages (#2791)
* docs: organize canonical documentation layout (URGENTE)

Group all existing authored guides by domain and ownership, expose complete navigation, and preserve their public routes. Update physical path consumers and release configuration while retaining historical records. Document domain-based specs and ADR slugs without global numbering.

Co-Authored-By: Codex <noreply@openai.com>

* fix(docs): honor home layout in all-page route verification

* style: format reviewed source changes

* fix(docs): preserve routes and navigation cache inputs

* fix: repair the static-check failures on the default branch (#2895)

* fix: repair the static-check failures on the default branch

The default branch fails its own required `Static checks` job three ways, so
every pull request reports that job as failed regardless of its own change.

- `npm run format:check` reports `src/domain/functionComparison.test.ts` and
  `src/ida/IdaOperationRunner.ts`.
- `npm run lint` reports a duplicate `import { join } from "node:path"` in
  `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17).
- `npm run typecheck` reports `format: "devin"` missing from the client format
  union in `src/application/SupportedClients.ts`, and an unchecked index in
  `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is
  inferred as `string[][]`.

Apply the pinned formatter, drop the duplicate import, list the `"devin"` format
that its own definition already uses, and mark the pair array `as const`.

Validation: `npm run check:fast` and `npm run format:check` pass.

* fix(setup): keep Devin on the JSON configuration dialect

---------

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>

* fix(docs): update links after guide relocation

* docs: correct verified documentation route counts

* fix(docs): update browser capture guide link after move (#2820)

Refresh gettext protected-link comments alongside the authored href.

Co-authored-by: Codex <noreply@openai.com>

* fix(docs): include http3 lab in stable routes

* fix(docs): preserve historical release evidence and links

* fix(ghidra): restore Windows verifier identity import

* docs(wakaru): preserve pinned upstream policy link

* docs(index): retain recently added guide links

* docs(mcp): preserve parent retention clarification

* fix(cli): preserve standalone import guidance

* fix(test): preserve translated guide link drift coverage

---------

Co-authored-by: Matheus Breguêz <matbrgz@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: morluto <17176810+morluto@users.noreply.github.com>
Co-authored-by: 吴佳浩Alben <35291372+XiaoBinGan@users.noreply.github.com>
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-08 01:42:28 +08:00

259 lines
8.4 KiB
TypeScript

import type { ObjcSwiftMetadata } from "../domain/native/objcSwiftMetadata.js";
import type { PointerFixups } from "./AppleMachoFixups.js";
import type {
DecodeIssue,
FacetDecodeFacts,
} from "./AppleDispatchDecodeFacts.js";
const describeFixups = (fixups: PointerFixups): string => {
const descriptions: string[] = [];
if (fixups.unreadRebaseBytes > 0)
descriptions.push(
`LC_DYLD_INFO rebase opcodes were not decoded (${fixups.unreadRebaseBytes} bytes)`,
);
if (fixups.kind === "chained")
descriptions.push(
`chained fixups: ${fixups.formats.join(", ") || "no fixup segments"}`,
);
if (fixups.legacyRebaseStreams > 0)
descriptions.push("LC_DYLD_INFO rebase opcodes");
if (fixups.legacyBindStreams > 0)
descriptions.push("LC_DYLD_INFO bind opcodes");
return descriptions.length === 0
? "no fixup load commands"
: descriptions.join("; ");
};
/** Append the per-facet coverage of one Apple dispatch metadata decode. */
export const pushDispatchCoverage = (input: {
readonly result: ObjcSwiftMetadata;
readonly failures: readonly string[];
readonly categoryIssues: readonly DecodeIssue[];
readonly examined: number;
readonly categoriesExamined: number;
readonly truncated: boolean;
readonly objcListScanTruncated: boolean;
readonly objcClassListScanTruncated: boolean;
readonly fixups: PointerFixups;
readonly declarations: FacetDecodeFacts;
readonly vtables: FacetDecodeFacts;
readonly swift: FacetDecodeFacts;
}): void => {
const {
result,
failures,
categoryIssues,
examined,
categoriesExamined,
truncated,
objcListScanTruncated,
objcClassListScanTruncated,
fixups,
declarations,
vtables,
swift,
} = input;
const classOwnedMethods = result.objc_dispatch_implementations.filter(
({ category }) => category === undefined,
);
const classRecords = [
...result.objc_classes.flatMap((record) =>
record.decode?.status === "decoded"
? []
: [
`class ${record.name}: ${record.decode?.reason ?? record.decode?.status ?? "decode_status_missing"}`,
],
),
...result.objc_protocol_records.flatMap((record) =>
record.decode.status === "decoded"
? []
: [
`protocol ${record.name}: ${record.decode.reason ?? record.decode.status}`,
],
),
...classOwnedMethods.flatMap((record) =>
record.decode.status === "decoded"
? []
: [
`method ${record.class_name} ${record.method_type} ${record.selector}: ${record.decode.reason ?? record.decode.status}`,
],
),
...result.objc_ivars.flatMap((record) =>
record.decode.status === "decoded"
? []
: [
`ivar ${record.class_name}.${record.name}: ${record.decode.reason ?? record.decode.status}`,
],
),
];
const classReasons = [
...failures,
...classRecords,
...(truncated || objcListScanTruncated ? ["max_records_reached"] : []),
];
const categoryMethods = result.objc_dispatch_implementations.filter(
({ category }) => category !== undefined,
);
const categoryMethodReasons = categoryMethods.flatMap((record) =>
record.decode.status === "decoded"
? []
: [
`category method ${record.category} ${record.class_name} ${record.method_type} ${record.selector}: ${record.decode.reason ?? record.decode.status}`,
],
);
result.coverage.push({
facet: "objc_class_method_ivar_metadata",
status: classReasons.length > 0 ? "partial" : "complete",
reason: classReasons.join("; ") || null,
examined,
decoded: result.objc_classes.filter(
({ decode }) => decode?.status === "decoded",
).length,
});
const relativePointerReasons = [
...(truncated || objcClassListScanTruncated ? ["max_records_reached"] : []),
...(result.relative_pointers.some(
(item) => item.decode.status !== "decoded",
)
? ["relative_pointer_targets_unresolved"]
: []),
];
result.coverage.push({
facet: "binary_relative_pointers",
status: relativePointerReasons.length > 0 ? "partial" : "complete",
reason: relativePointerReasons.join("; ") || null,
examined: result.relative_pointers.length,
decoded: result.relative_pointers.filter(
(item) => item.decode.status === "decoded",
).length,
});
const categoryFailures = categoryIssues.map(
({ code, location, message }) =>
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`,
);
result.coverage.push({
facet: "objc_properties_categories",
status:
truncated ||
objcClassListScanTruncated ||
categoryFailures.length > 0 ||
result.objc_categories.some(
({ decode }) => decode.status !== "decoded",
) ||
categoryMethodReasons.length > 0
? "partial"
: "complete",
reason:
[
...categoryFailures,
...categoryMethodReasons,
...(truncated || objcClassListScanTruncated
? ["max_records_reached"]
: []),
].join("; ") || null,
examined: categoriesExamined,
decoded: result.objc_categories.filter(
({ decode }) => decode.status === "decoded",
).length,
});
const fixupReason = [
describeFixups(fixups),
...fixups.issues.map(
({ code, location, message }) =>
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`,
),
]
.filter((line) => line.length > 0)
.join("; ");
result.coverage.push({
facet: "pointer_fixups",
status:
fixups.issues.length > 0 || fixups.unreadRebaseBytes > 0
? "partial"
: fixups.examined === 0
? "unsupported"
: "complete",
reason: fixupReason.length > 0 ? fixupReason : null,
examined: fixups.examined,
decoded: fixups.decoded,
});
result.coverage.push({
facet: "swift_generic_resilient_witnesses_overrides_async_coroutines",
status: "unsupported",
reason:
"This reader admits Swift nominal type declarations, simple conformance/static witness records and non-generic, non-resilient class vtables; generic/resilient tables and other Swift metadata families are not decoded",
examined: 0,
decoded: 0,
});
result.coverage.push({
facet: "swift_conformances_static_witness_slots",
status:
swift.exhaustive &&
!truncated &&
!result.swift_conformances.some(
({ decode }) => decode.status !== "decoded",
) &&
!result.swift_dispatch_slots.some(
({ table_kind, decode }) =>
table_kind === "witness_table" && decode.status !== "decoded",
)
? "complete"
: "partial",
reason:
[
...swift.issues.map(formatIssue),
...(truncated ? ["max_records_reached"] : []),
...(result.swift_conformances.some(
({ decode }) => decode.status !== "decoded",
) ||
result.swift_dispatch_slots.some(
({ table_kind, decode }) =>
table_kind === "witness_table" && decode.status !== "decoded",
)
? ["swift_records_unresolved"]
: []),
].join("; ") || null,
examined: swift.examined,
decoded: swift.decoded,
});
result.coverage.push({
facet: "swift_declarations",
status: declarations.exhaustive && !truncated ? "complete" : "partial",
reason:
[
...declarations.issues.map(formatIssue),
...(truncated ? ["max_records_reached"] : []),
].join("; ") || null,
examined: declarations.examined,
decoded: declarations.decoded,
});
result.coverage.push({
facet: "swift_class_vtable_descriptors",
status:
vtables.exhaustive &&
!truncated &&
!result.swift_dispatch_slots.some(
({ table_kind, decode }) =>
table_kind === "class_vtable" && decode.status !== "decoded",
)
? "complete"
: "partial",
reason:
[
...vtables.issues.map(formatIssue),
...(truncated ? ["max_records_reached"] : []),
...(result.swift_dispatch_slots.some(
({ table_kind, decode }) =>
table_kind === "class_vtable" && decode.status !== "decoded",
)
? ["vtable_implementations_unresolved"]
: []),
].join("; ") || null,
examined: vtables.examined,
decoded: vtables.decoded,
});
};
const formatIssue = ({ code, location, message }: DecodeIssue): string =>
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`;