Files
reverse-engineering-anything/src/domain/reverseEngineering.ts
T
gensokyo-devandKaoru0822 3ea0d9489e feat(objdump): select native disassembly by symbol (#5171)
Push optional native symbol selection into GNU objdump before collecting Evidence. Preserve native matching, raw output, artifact identity, scoped limitations and the existing full-disassembly default through the shared CLI/MCP workflow.

Fixes #5159

Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
2026-10-19 20:15:20 +08:00

61 lines
1.7 KiB
TypeScript

import { z } from "zod";
export const OBJDUMP_ARTIFACT_OPERATIONS = [
"file_headers",
"section_headers",
"symbols",
"relocations",
"dwarf",
"disassemble",
"disassemble_all",
] as const;
const objdumpArtifactInputSchema = z
.object({
path: z.string().min(1),
operation: z.enum(OBJDUMP_ARTIFACT_OPERATIONS).exclude(["disassemble"]),
follow_debug_links: z.boolean().default(false),
})
.strict();
const objdumpDisassemblyInputSchema = objdumpArtifactInputSchema.extend({
operation: z.literal("disassemble"),
symbol: z
.string()
.min(1)
.regex(/^[^\x00]*$/u)
// Keep UTF-16 checks out of patterns consumed by scalar Unicode engines.
.refine(
(symbol) => !/[\uD800-\uDFFF]/u.test(symbol),
"Symbol must be well-formed Unicode.",
)
.describe(
"Native symbol to disassemble, expressed as well-formed Unicode. Matching and symbol boundaries follow GNU objdump; omitted means all code sections.",
)
.optional(),
});
/** Caller-selected artifact facet or pathless provider capability query. */
export const objdumpInputSchema = z.discriminatedUnion("operation", [
objdumpArtifactInputSchema,
objdumpDisassemblyInputSchema,
z.strictObject({ operation: z.literal("architectures") }),
]);
/** Caller-selected Rizin command against one local artifact. */
export const rizinInputSchema = z
.object({
path: z.string().min(1),
command: z
.string()
.min(1)
.refine(
(value) => !/[\r\n\u0000]/u.test(value),
"A single command line is required",
),
})
.strict();
export type ObjdumpInput = z.input<typeof objdumpInputSchema>;
export type RizinInput = z.input<typeof rizinInputSchema>;