feat(ghidra): admit set_address_name and set_addresses_names (#1635)
* feat(ghidra): admit set_address_name and set_addresses_names Ghidra sessions rejected the existing naming tools with "operation is not declared by this provider", so agents had to use annotate_native_function, which returns a complete function dossier per rename and cannot name data addresses. The Java bridge now names a local function entry (namespace-aware, like annotate_native_function) or creates/renames the primary label at any other mapped address, verifying readback. set_addresses_names applies each address in its own transaction and reports per-address booleans. Both are mutating capabilities: excluded from read-only (Windows P0) handshakes and from snapshot replay. * fix(ghidra): normalize qualified symbol names and reject empty leaves Share namespace-aware leaf normalization across functions and primary labels. Invalid qualified leaves now return false for naming operations without marking the provider unavailable; function annotations retain typed invalid-input errors. Extend real CLI/MCP namespace verification with namespaced globals, readback replay, failed-name rollback, mixed batches, and capability checks. Validation: 75 focused tests and npm run check pass. Ghidra 12.1.4/JDK 21 namespace verification passes on macOS arm64 with unchanged source bytes and complete cleanup. The full host lane passes this workflow before the existing entry-alias fixture fails because the compiler places its interior label at the function entry. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,10 @@ import { jsonValueSchema, type JsonValue } from "../domain/jsonValue.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
||||
|
||||
/** Read-only direct inventory operations admitted by the Ghidra adapter. */
|
||||
/**
|
||||
* Direct inventory operations admitted by the Ghidra adapter. All are reads
|
||||
* except the naming operations, which edit the ephemeral session database.
|
||||
*/
|
||||
export const GHIDRA_INVENTORY_OPERATIONS = [
|
||||
"inspect_native_load_image",
|
||||
"read_bytes",
|
||||
@@ -28,8 +31,16 @@ export const GHIDRA_INVENTORY_OPERATIONS = [
|
||||
"resolve_containing_procedure",
|
||||
"search_procedures",
|
||||
"search_strings",
|
||||
"set_address_name",
|
||||
"set_addresses_names",
|
||||
] as const;
|
||||
|
||||
/** Inventory operations that write analyst names into the session database. */
|
||||
export const GHIDRA_NAMING_OPERATIONS = [
|
||||
"set_address_name",
|
||||
"set_addresses_names",
|
||||
] as const satisfies readonly GhidraInventoryOperation[];
|
||||
|
||||
/** One direct inventory operation implemented by the packaged Java bridge. */
|
||||
export type GhidraInventoryOperation =
|
||||
(typeof GHIDRA_INVENTORY_OPERATIONS)[number];
|
||||
@@ -83,6 +94,19 @@ const inputSchemas = {
|
||||
.strict(),
|
||||
search_procedures: z.object(searchInput).strict(),
|
||||
search_strings: z.object(searchInput).strict(),
|
||||
set_address_name: z
|
||||
.object({ document, address: explicitAddress, name: z.string().min(1) })
|
||||
.strict(),
|
||||
set_addresses_names: z
|
||||
.object({
|
||||
document,
|
||||
names: z.record(explicitAddress, z.string().min(1)),
|
||||
})
|
||||
.strict()
|
||||
.refine(
|
||||
(value) => Object.keys(value.names).length > 0,
|
||||
"Supply at least one address name",
|
||||
),
|
||||
} satisfies Readonly<Record<GhidraInventoryOperation, z.ZodType>>;
|
||||
|
||||
/** Validate and default one provider request before it crosses the socket. */
|
||||
@@ -281,6 +305,8 @@ const resultSchemas = {
|
||||
resolve_containing_procedure: containingProcedure,
|
||||
search_procedures: z.array(searchItem),
|
||||
search_strings: z.array(searchItem),
|
||||
set_address_name: z.boolean(),
|
||||
set_addresses_names: z.record(z.string(), z.boolean()),
|
||||
} satisfies Readonly<Record<GhidraInventoryOperation, z.ZodType>>;
|
||||
|
||||
/** Validate exact Java-bridge output before creating Evidence. */
|
||||
|
||||
Reference in New Issue
Block a user