mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(cli): derive Android dispatch from the selected contract (#16600)
This commit is contained in:
1 parent
de219154c6
commit
d96b027449
1 file changed
+89
-111
+89
-111
@@ -6,6 +6,10 @@ import type { Logger } from "pino";
|
||||
import type { CliInstance } from "./types.js";
|
||||
import { finishCliEvidenceCommand } from "./cliEvidenceCallerPath.js";
|
||||
import { contractNamed } from "./contractCliDescription.js";
|
||||
import type {
|
||||
CliContractProjection,
|
||||
ContractField,
|
||||
} from "./contractCliDescriptionTypes.js";
|
||||
import {
|
||||
registerContractCommand,
|
||||
type ContractCommandContext,
|
||||
@@ -60,126 +64,100 @@ export const registerAndroidCommands = (
|
||||
...(delivery.view === undefined ? {} : { view: delivery.view }),
|
||||
});
|
||||
};
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("inspect_android_jni_bindings"),
|
||||
{
|
||||
description:
|
||||
"Link raw DEX native declarations to static JNI export/table candidates without executing the APK",
|
||||
positionals: ["path"],
|
||||
fieldGroups: {
|
||||
query: {
|
||||
fields: [
|
||||
"class_name",
|
||||
"method_names",
|
||||
"descriptors",
|
||||
"abis",
|
||||
"library_paths",
|
||||
],
|
||||
description:
|
||||
"JSON selection: class_name, method_names, descriptors, abis, library_paths; arrays preserve exact names",
|
||||
invalidJson: "query must be a JSON selection object.",
|
||||
},
|
||||
const register = <Contract extends (typeof ANDROID_TOOL_CONTRACTS)[number]>(
|
||||
selected: Contract,
|
||||
projection: CliContractProjection<ContractField<Contract>>,
|
||||
): void =>
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
selected,
|
||||
projection,
|
||||
run(selected.name),
|
||||
);
|
||||
register(contract("inspect_android_jni_bindings"), {
|
||||
description:
|
||||
"Link raw DEX native declarations to static JNI export/table candidates without executing the APK",
|
||||
positionals: ["path"],
|
||||
fieldGroups: {
|
||||
query: {
|
||||
fields: [
|
||||
"class_name",
|
||||
"method_names",
|
||||
"descriptors",
|
||||
"abis",
|
||||
"library_paths",
|
||||
],
|
||||
description:
|
||||
"JSON selection: class_name, method_names, descriptors, abis, library_paths; arrays preserve exact names",
|
||||
invalidJson: "query must be a JSON selection object.",
|
||||
},
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android-jni collection page; requires --detail summary and --evidence_output",
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android-jni collection page; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
},
|
||||
run("inspect_android_jni_bindings"),
|
||||
);
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("inspect_android_package"),
|
||||
{
|
||||
description:
|
||||
"Inspect APK declarations and decoded manifest without executing it",
|
||||
positionals: ["path"],
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android manifest/components/component-summary view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
});
|
||||
register(contract("inspect_android_package"), {
|
||||
description:
|
||||
"Inspect APK declarations and decoded manifest without executing it",
|
||||
positionals: ["path"],
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android manifest/components/component-summary view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
},
|
||||
run("inspect_android_package"),
|
||||
);
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("search_android_classes"),
|
||||
{
|
||||
description:
|
||||
"Search APK class names; empty query inventories all classes",
|
||||
positionals: ["path", "query"],
|
||||
},
|
||||
run("search_android_classes"),
|
||||
);
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("inspect_android_class"),
|
||||
{
|
||||
description: "Inspect one exact APK class's member inventory",
|
||||
positionals: ["path", "class_name"],
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android-class methods, fields, inner-classes or mapping-symbols view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
});
|
||||
register(contract("search_android_classes"), {
|
||||
description: "Search APK class names; empty query inventories all classes",
|
||||
positionals: ["path", "query"],
|
||||
});
|
||||
register(contract("inspect_android_class"), {
|
||||
description: "Inspect one exact APK class's member inventory",
|
||||
positionals: ["path", "class_name"],
|
||||
fields: {
|
||||
view: {
|
||||
description:
|
||||
"JSON android-class methods, fields, inner-classes or mapping-symbols view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
},
|
||||
run("inspect_android_class"),
|
||||
);
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("inspect_android_method"),
|
||||
{
|
||||
description: "Decompile one APK method with explicit overload selection",
|
||||
positionals: ["path", "class_name", "method_name"],
|
||||
fields: {
|
||||
method_name: { description: "Exact declared method name" },
|
||||
overload_index: {
|
||||
description:
|
||||
"Explicit zero-based index among same-name methods; required when ambiguous",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
});
|
||||
register(contract("inspect_android_method"), {
|
||||
description: "Decompile one APK method with explicit overload selection",
|
||||
positionals: ["path", "class_name", "method_name"],
|
||||
fields: {
|
||||
method_name: { description: "Exact declared method name" },
|
||||
overload_index: {
|
||||
description:
|
||||
"Explicit zero-based index among same-name methods; required when ambiguous",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
},
|
||||
run("inspect_android_method"),
|
||||
);
|
||||
registerContractCommand(
|
||||
cli,
|
||||
logger,
|
||||
contract("trace_android_references"),
|
||||
{
|
||||
description:
|
||||
"Trace APK using nodes for a defined class/method or an externally invoked DEX method",
|
||||
positionals: ["path", "class_name"],
|
||||
fields: {
|
||||
overload_index: {
|
||||
description:
|
||||
"Index among defined methods or observed external prototypes listed by an ambiguous query",
|
||||
},
|
||||
view: {
|
||||
description:
|
||||
"JSON android-references top-classes or references view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
});
|
||||
register(contract("trace_android_references"), {
|
||||
description:
|
||||
"Trace APK using nodes for a defined class/method or an externally invoked DEX method",
|
||||
positionals: ["path", "class_name"],
|
||||
fields: {
|
||||
overload_index: {
|
||||
description:
|
||||
"Index among defined methods or observed external prototypes listed by an ambiguous query",
|
||||
},
|
||||
view: {
|
||||
description:
|
||||
"JSON android-references top-classes or references view; requires --detail summary and --evidence_output",
|
||||
},
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
},
|
||||
run("trace_android_references"),
|
||||
);
|
||||
evidenceDelivery: true,
|
||||
viewDelivery: { invalidJson: "view must be valid JSON" },
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user