Skip to content

Commit 1941d34

Browse files
committed
fix(ghidra): preserve omitted PDB identity uncertainty
1 parent c8ba745 commit 1941d34

5 files changed

Lines changed: 78 additions & 4 deletions

File tree

‎src/ghidra/GhidraAnalysisProfile.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const resolveGhidraAnalysisProfile = async (
218218
].sort(),
219219
import_mode: "ephemeral-source-immutable",
220220
...(target.format === "pe"
221-
? { pdb_observations: "program-info-v4" }
221+
? { pdb_observations: "program-info-v5" }
222222
: {}),
223223
annotation_policy: "atomic-function-entry-metadata-v1",
224224
load_image_observations: "source-mappings-entry-context-v2",

‎src/ghidra/GhidraPeProfile.test.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,67 @@ it("reports NB10 declared age without inventing a GUID", () => {
168168
expect(caveats[0]).not.toContain("GUID");
169169
});
170170

171+
it.each([false, null, true])(
172+
"keeps an omitted NB10 GUID unknown with loaded = %s",
173+
(loaded) => {
174+
const pdbPath = "a".repeat(4070) + "\\legacy.pdb";
175+
const legacy = {
176+
...target,
177+
codeView: {
178+
pdbPath,
179+
pdbFileName: "legacy.pdb",
180+
guid: null,
181+
age: 2,
182+
},
183+
};
184+
const pdb = {
185+
...absentAttributes,
186+
file: pdbPath,
187+
age: "2",
188+
signature: "01234567",
189+
version: "NB10",
190+
loaded,
191+
};
192+
expect(ghidraPePdbLimitations(legacy, pdb)).toEqual(
193+
ghidraPdbLimitations(pdb),
194+
);
195+
const omitted: GhidraSessionInfo["pdb"] = {
196+
...pdb,
197+
resource_limit: { omitted_attributes: ["guid"], utf16_budget: 4096 },
198+
};
199+
const caveats = ghidraPePdbLimitations(legacy, omitted);
200+
expect(caveats).toEqual([
201+
...ghidraPdbLimitations(omitted),
202+
expect.stringContaining('PDB "legacy.pdb" (age (decimal) 2)'),
203+
]);
204+
expect(caveats.at(-1)).toContain("equivalence is not established");
205+
},
206+
);
207+
208+
it.each(["signature", "version"] as const)(
209+
"keeps matching NB10 identity when only %s is omitted",
210+
(attribute) => {
211+
const legacy = {
212+
...target,
213+
codeView: {
214+
pdbPath: "legacy.pdb",
215+
pdbFileName: "legacy.pdb",
216+
guid: null,
217+
age: 2,
218+
},
219+
};
220+
const pdb: GhidraSessionInfo["pdb"] = {
221+
...absentAttributes,
222+
file: "legacy.pdb",
223+
age: "2",
224+
resource_limit: { omitted_attributes: [attribute], utf16_budget: 4096 },
225+
};
226+
expect(ghidraPePdbLimitations(legacy, pdb)).toEqual(
227+
ghidraPdbLimitations(pdb),
228+
);
229+
},
230+
);
231+
171232
it("retains missing-report uncertainty without a declared CodeView record", () => {
172233
const { codeView: _, ...withoutReference } = target;
173234
expect(ghidraPePdbLimitations(withoutReference, undefined)).toEqual(

‎src/ghidra/GhidraPeProfile.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const reportedPdbMatchesDeclaration = (
1515
reported: NonNullable<GhidraSessionInfo["pdb"]>,
1616
): boolean => {
1717
if (
18+
reported.resource_limit?.omitted_attributes.some(
19+
(attribute) =>
20+
attribute === "file" || attribute === "guid" || attribute === "age",
21+
) ||
1822
(reported.file !== declared.pdbPath &&
1923
reported.file !== declared.pdbFileName) ||
2024
reported.age === null ||

‎src/ghidra/GhidraProvider.behavior.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ const createElfClient = async (ghidra: GhidraProvider) => {
8585
return ghidra.createClient(target, resolved.value.profile);
8686
};
8787

88-
it.each(["program-info-v1", "program-info-v2", "program-info-v3"])(
88+
it.each([
89+
"program-info-v1",
90+
"program-info-v2",
91+
"program-info-v3",
92+
"program-info-v4",
93+
])(
8994
"retains historical PE PDB Evidence for %s without replaying its old projection",
9095
async (pdbObservations) => {
9196
const target = peTarget("x86_64");
@@ -99,7 +104,11 @@ it.each(["program-info-v1", "program-info-v2", "program-info-v3"])(
99104
});
100105
const operation = "search_procedures";
101106
const parameters = { pattern: "wmain" };
102-
const limitations = ["Legacy projection collapsed unknown PDB load state."];
107+
const limitations = [
108+
pdbObservations === "program-info-v4"
109+
? "Legacy projection discarded NB10 declaration when the reported GUID was omitted."
110+
: "Legacy projection collapsed unknown PDB load state.",
111+
];
103112
const cache = new AnalysisSnapshotCache();
104113
cache.record({
105114
target,

‎tests/boundary/mcp/ghidraInventoryMcp.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ it("retains missing PDB coverage in empty PE name-search Evidence and snapshot r
315315
const evidence = sessionEvidence(harness.session, reply.structuredContent);
316316
expect(evidence.normalized_result).toEqual([]);
317317
expect(evidence.analysis_profile?.parameters.pdb_observations).toBe(
318-
"program-info-v4",
318+
"program-info-v5",
319319
);
320320
const limitation = evidence.limitations.find((value) =>
321321
value.includes(pdb.file),

0 commit comments

Comments
 (0)