feat(native): add investigation features (#486)
* feat(native): add UI and dispatch investigation workflows * feat(ghidra): support macOS host validation * docs: update native investigation capabilities * feat(artifacts): decode compiled Interface Builder archives * feat(ghidra): expose bounded p-code value flow * test(ghidra): split host and cross-format verification * fix(verify): follow complete result contracts * refactor: remove unused authorization and schema helpers * refactor: remove unused evidence result alias * fix(ghidra): report jump-table evidence precisely * fix(verify): align browser scenario fixture schema * fix(setup): compare parsed client config structurally * test(ghidra): verify AArch64 jump-table mappings * fix(ghidra): recover AArch64 byte jump tables * test(artifacts): verify compiled interface builder archives * feat(native): trace UI actions through handlers * fix(tests): update native trace and shutdown fixtures * fix(verification): diagnose browser scenario failures * fix(browser): wrap scenario snapshots in capture state * fix(native): bind and bound investigation workflows * fix(artifacts): preserve bounded interface builder evidence * fix(ghidra): enforce admitted hosts and preflight tools * fix(native): preserve trace cancellation and bounds * test(application): expect bound analysis target evidence * fix(native): preserve investigation bounds and cancellation * fix(application): preserve bundle and unresolved trace evidence * style(test): format artifact subject fixture
This commit is contained in:
@@ -38,6 +38,7 @@ const exampleInputSchema = z.record(z.string(), jsonValueSchema);
|
||||
const examples: Readonly<Record<string, Readonly<Record<string, unknown>>>> = {
|
||||
inspect_artifact: {},
|
||||
extract_artifact: {},
|
||||
decode_interface_builder: {},
|
||||
};
|
||||
|
||||
const artifact = <
|
||||
@@ -77,6 +78,15 @@ export const ARTIFACT_TOOL_CONTRACTS = [
|
||||
"Extract all regular files from the active archive or application package into a fresh temporary directory chosen by REA. The result includes its location. Rejects traversal and symlink escapes, never overwrites, enforces archive integrity checks, and verifies cleanup.",
|
||||
artifactExtractionInputSchema,
|
||||
),
|
||||
artifact(
|
||||
"decode_interface_builder",
|
||||
"Decode compiled storyboard and nib archives inside the active Apple app bundle, including keyed property lists and NIBArchive object tables, into a bounded object, hierarchy, and connection graph. This is static archive parsing; unrecognized archive classes and unresolved code handlers remain explicit unknowns.",
|
||||
z.strictObject({
|
||||
max_documents: z.number().int().min(1).max(64).default(64),
|
||||
max_objects: z.number().int().min(1).max(20_000).default(20_000),
|
||||
max_connections: z.number().int().min(1).max(40_000).default(40_000),
|
||||
}),
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
/** Provider operations; inventory remains an internal primitive of inspection. */
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const traceLiteralInputSchema = z.strictObject({
|
||||
query: z.string().min(1),
|
||||
case_sensitive: z.boolean().default(false),
|
||||
@@ -7,6 +6,9 @@ const traceLiteralInputSchema = z.strictObject({
|
||||
|
||||
/** Input schemas shared by MCP registration and enhanced application dispatch. */
|
||||
export const enhancedInputSchemas = {
|
||||
inspect_native_dispatch_metadata: z.strictObject({
|
||||
max_records: z.number().int().min(1).max(20_000).default(5_000),
|
||||
}),
|
||||
get_objc_classes: z.strictObject({ pattern: z.string().default("") }),
|
||||
get_objc_protocols: z.strictObject({}),
|
||||
batch_decompile: z.strictObject({
|
||||
@@ -48,6 +50,15 @@ export const enhancedInputSchemas = {
|
||||
.optional(),
|
||||
direction: z.enum(["forward", "backward"]).default("forward"),
|
||||
}),
|
||||
trace_native_ui_action: z.strictObject({
|
||||
action: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("A unique compiled UI action selector or interface object ID"),
|
||||
max_depth: z.number().int().min(0).max(32).default(8),
|
||||
max_nodes: z.number().int().min(1).max(2_000).default(250),
|
||||
max_edges: z.number().int().min(1).max(5_000).default(500),
|
||||
}),
|
||||
} as const;
|
||||
|
||||
export type EnhancedToolName = keyof typeof enhancedInputSchemas;
|
||||
|
||||
@@ -44,6 +44,7 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
trace_feature: { query: "license" },
|
||||
find_code_for_string: { query: "authorization failed" },
|
||||
trace_call_path: { start: "0x1000", goal: "0x1100" },
|
||||
trace_native_ui_action: { action: "buildTapped:" },
|
||||
open_binary: { path: "/tmp/fixture" },
|
||||
export_evidence_bundle: { path: "/tmp/evidence.json" },
|
||||
inspect_address_context: { address: "0x1000" },
|
||||
|
||||
@@ -16,11 +16,12 @@ import { APPLICATION_TOOL_CONTRACTS } from "./applicationToolContracts.js";
|
||||
describe("tool contract inventory", () => {
|
||||
it("publishes the canonical analysis and session tool inventory", () => {
|
||||
expect(OFFICIAL_TOOL_CONTRACTS).toHaveLength(36);
|
||||
expect(ENHANCED_TOOL_CONTRACTS).toHaveLength(12);
|
||||
expect(ENHANCED_TOOL_CONTRACTS).toHaveLength(14);
|
||||
expect(NATIVE_TOOL_CONTRACTS).toHaveLength(5);
|
||||
expect(ARTIFACT_TOOL_CONTRACTS.map(({ name }) => name)).toEqual([
|
||||
"inspect_artifact",
|
||||
"extract_artifact",
|
||||
"decode_interface_builder",
|
||||
]);
|
||||
expect(MANAGED_TOOL_CONTRACTS.map(({ name }) => name)).toEqual([
|
||||
"inspect_managed_artifact",
|
||||
|
||||
@@ -295,6 +295,11 @@ export type OfficialToolName = (typeof OFFICIAL_TOOL_CONTRACTS)[number]["name"];
|
||||
|
||||
/** Workflow tools composed from one or more provider operations. */
|
||||
export const ENHANCED_TOOL_CONTRACTS = [
|
||||
enhanced(
|
||||
"inspect_native_dispatch_metadata",
|
||||
"Inspect the bound provider's name inventory for Objective-C class/method symbols and Swift mangled symbols, returning at most max_records decoded names. Includes target SHA-256 when available, provider identity/version, analysis-profile digest, facet coverage, and per-record Evidence. This is symbol-level evidence, not runtime metadata: ivar layouts, protocol conformances, witness/class tables, and relative pointers are explicitly marked unsupported unless a provider supplies those decoders. The provider controls how its name inventory is acquired.",
|
||||
enhancedInputSchemas.inspect_native_dispatch_metadata,
|
||||
),
|
||||
enhanced(
|
||||
"get_objc_classes",
|
||||
"Discover and deduplicate Objective-C class labels, optionally filtering by literal substring.",
|
||||
@@ -346,6 +351,11 @@ export const ENHANCED_TOOL_CONTRACTS = [
|
||||
"Trace direct callers or callees from one exact procedure address until the graph is exhausted or the optional goal is reached. Returns visited nodes, direct-call edges, a shortest traversal path, provider failures, and residual unknowns; unresolved indirect calls remain unknown.",
|
||||
enhancedInputSchemas.trace_call_path,
|
||||
),
|
||||
enhanced(
|
||||
"trace_native_ui_action",
|
||||
"Trace one unique compiled Interface Builder action selector or object ID through its authored UI connections to symbolized Objective-C handlers and bounded direct callees. REA decodes the active app bundle and reads the selected provider's symbol inventory itself. Authored connections, statically matched handlers, resolved direct calls, and unresolved dynamic dispatch remain distinct; runtime reachability and cross-function value flow are not claimed.",
|
||||
enhancedInputSchemas.trace_native_ui_action,
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
/** Session-owned Evidence bundle export options. */
|
||||
|
||||
@@ -40,6 +40,8 @@ const sessionEvidence = effects({ mutatesSession: true });
|
||||
|
||||
/** Explicit effect audit for every public tool. */
|
||||
export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
inspect_native_dispatch_metadata: evidence,
|
||||
trace_native_ui_action: evidence,
|
||||
address_name: evidence,
|
||||
comment: evidence,
|
||||
current_address: evidence,
|
||||
@@ -99,6 +101,7 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
demangle_swift: nativeEvidence,
|
||||
inspect_artifact: evidence,
|
||||
extract_artifact: effects({ mutatesSession: true, writesFilesystem: true }),
|
||||
decode_interface_builder: evidence,
|
||||
inspect_managed_artifact: evidence,
|
||||
inspect_managed_members: evidence,
|
||||
inspect_managed_native_boundaries: evidence,
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "../domain/nativeInspection.js";
|
||||
import { artifactExtractionResultSchema } from "../domain/artifactGraph.js";
|
||||
import { artifactInspectionResultSchema } from "../domain/artifactInspection.js";
|
||||
import { interfaceBuilderAnalysisSchema } from "../domain/interfaceBuilderGraph.js";
|
||||
import {
|
||||
managedArtifactInspectionSchema,
|
||||
managedMemberInspectionSchema,
|
||||
@@ -40,6 +41,8 @@ import { staticRuntimeCorrelationResultSchema } from "../domain/staticRuntimeCor
|
||||
import { reconstructionVerificationResultSchema } from "../domain/reconstructionVerification.js";
|
||||
import { replayMachineRunOutputSchema } from "../domain/replayMachineRun.js";
|
||||
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
||||
import { nativeDispatchMetadataResultSchema } from "../domain/objcSwiftMetadata.js";
|
||||
import { nativeInvestigationTraceSchema } from "../domain/nativeInvestigationGraph.js";
|
||||
import {
|
||||
addressList,
|
||||
addressedValue,
|
||||
@@ -219,6 +222,10 @@ const callPathTraceOutput = resultOf(
|
||||
|
||||
/** Exact structured-content schemas for composed analysis workflows. */
|
||||
export const enhancedOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
inspect_native_dispatch_metadata: resultOf(
|
||||
nativeDispatchMetadataResultSchema,
|
||||
),
|
||||
trace_native_ui_action: resultOf(nativeInvestigationTraceSchema),
|
||||
get_objc_classes: symbolDiscoveryOutput("classes"),
|
||||
get_objc_protocols: symbolDiscoveryOutput("protocols"),
|
||||
batch_decompile: resultOf(
|
||||
@@ -306,6 +313,7 @@ export const nativeOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
export const artifactOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
inspect_artifact: resultOf(artifactInspectionResultSchema),
|
||||
extract_artifact: resultOf(artifactExtractionResultSchema),
|
||||
decode_interface_builder: resultOf(interfaceBuilderAnalysisSchema),
|
||||
};
|
||||
|
||||
/** Exact Evidence schema for execution-free managed static analysis. */
|
||||
|
||||
Reference in New Issue
Block a user