fix(ghidra): preserve Unicode boundaries without breaking sessions

Validate native annotation text before mutation and escape surrogate code units in Java bridge JSON replies. Reject unsupported text with field and index diagnostics while preserving supported Unicode and line endings.

Probe real CLI/MCP annotation, transport, mapping, rollback and cleanup behavior; replace seven redundant unit tests with E2E and SDK boundary coverage.
This commit is contained in:
morluto
2026-10-09 02:50:33 +08:00
parent 64717ad7da
commit bef234d6ce
8 changed files with 222 additions and 174 deletions
-46
View File
@@ -3,7 +3,6 @@ import { describe, expect, it } from "vitest";
import type { JsonValue } from "../domain/jsonValue.js";
import { functionDossierSchema } from "../domain/hopperValues.js";
import {
parseGhidraFunctionInput,
parseGhidraFunctionResult,
type GhidraFunctionOperation,
} from "./GhidraFunctionValues.js";
@@ -16,51 +15,6 @@ import {
ghidraReferenceEdge,
} from "../domain/ghidraValues.fixture.js";
describe("Ghidra function-analysis boundary values", () => {
it("defaults inputs and rejects undeclared or implicit addresses", () => {
expect(
parseGhidraFunctionInput("procedure_info", { procedure: "main" }),
).toEqual({
ok: true,
value: { document: null, procedure: "main" },
});
expect(
parseGhidraFunctionInput("procedure_references", { procedure: "main" }),
).toEqual({
ok: true,
value: {
document: null,
procedure: "main",
direction: "outgoing",
},
});
expect(
parseGhidraFunctionInput("analyze_function", { procedure: "main" }),
).toMatchObject({
ok: true,
value: { procedure: "main" },
});
expect(
parseGhidraFunctionInput("read_function_instructions", {
procedure: "main",
}),
).toEqual({
ok: true,
value: { document: null, procedure: "main" },
});
expect(parseGhidraFunctionInput("xrefs", {})).toMatchObject({
ok: false,
error: { _tag: "AnalysisInputError" },
});
expect(
parseGhidraFunctionInput("procedure_info", {
procedure: "main",
extra: true,
}),
).toMatchObject({ ok: false, error: { _tag: "AnalysisInputError" } });
});
});
describe("Ghidra function-analysis result values", () => {
it("parses provider-classified function facts and reference kinds", () => {
expect(