fix(ghidra): return complete native analysis results
This commit is contained in:
@@ -73,20 +73,19 @@ export function assertDenseSwitchDossier(dossier, address) {
|
||||
requireAssembly: true,
|
||||
requireMultiBlock: true,
|
||||
});
|
||||
const truncated = dossier.native_api.jump_tables.find(
|
||||
({ mappings_truncated: mappingsTruncated }) => mappingsTruncated,
|
||||
const denseTable = dossier.native_api.jump_tables.find(
|
||||
({ mappings }) => mappings.length > 32,
|
||||
);
|
||||
if (
|
||||
truncated === undefined ||
|
||||
truncated.mappings.length !== 32 ||
|
||||
truncated.mappings.some(
|
||||
denseTable === undefined ||
|
||||
denseTable.mappings.some(
|
||||
({ target_address: target, evidence }) =>
|
||||
!/^0x[0-9a-f]+$/u.test(target) ||
|
||||
!evidence.some(({ kind }) => kind === "jump-table"),
|
||||
)
|
||||
)
|
||||
throw new Error(
|
||||
`Ghidra dense jump-table truncation drifted: ${JSON.stringify(dossier.native_api.jump_tables)}`,
|
||||
`Ghidra dense jump-table completeness drifted: ${JSON.stringify(dossier.native_api.jump_tables)}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,8 +93,6 @@ function assertNativeApiBoundary(observed, requireJumpTable) {
|
||||
if (
|
||||
observed?.available !== true ||
|
||||
observed.provenance !== "ghidra-high-function" ||
|
||||
observed.parameters_truncated !== false ||
|
||||
observed.jump_tables_truncated !== false ||
|
||||
!["low", "medium", "high"].includes(observed.return_type?.confidence) ||
|
||||
!observed.return_type?.evidence?.some(
|
||||
({ source }) => source === "ghidra-high-function",
|
||||
@@ -111,14 +108,7 @@ function assertNativeApiBoundary(observed, requireJumpTable) {
|
||||
if (
|
||||
observed.jump_tables.length === 0 ||
|
||||
!observed.jump_tables.some(
|
||||
({
|
||||
data_sources: sources,
|
||||
data_sources_truncated: sourcesTruncated,
|
||||
mappings,
|
||||
mappings_truncated: mappingsTruncated,
|
||||
}) =>
|
||||
!sourcesTruncated &&
|
||||
!mappingsTruncated &&
|
||||
({ data_sources: sources, mappings }) =>
|
||||
sources.length > 0 &&
|
||||
sources.every(
|
||||
({ address, evidence }) =>
|
||||
|
||||
@@ -191,33 +191,29 @@ async function verifyNativeApiCli(targetPath) {
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
maxBuffer: 2 * 1024 * 1024,
|
||||
maxBuffer: 72 * 1024 * 1024,
|
||||
},
|
||||
);
|
||||
const evidence = JSON.parse(stdout);
|
||||
const boundary = evidence.normalized_result?.boundary;
|
||||
const truncated = boundary?.jump_tables?.find(
|
||||
({ mappings_truncated: mappingsTruncated }) => mappingsTruncated === true,
|
||||
const denseTable = boundary?.jump_tables?.find(
|
||||
({ mappings }) => mappings.length > 32,
|
||||
);
|
||||
const omittedQuestion =
|
||||
"Which additional data sources or targets were omitted";
|
||||
if (
|
||||
evidence.operation !== "inspect_native_api" ||
|
||||
evidence.provider?.id !== "rea-workflow" ||
|
||||
evidence.analysis_profile?.provider?.id !== "rea-workflow" ||
|
||||
boundary?.available !== true ||
|
||||
truncated?.mappings?.length !== 32 ||
|
||||
!evidence.normalized_result?.residual_unknowns?.some((question) =>
|
||||
question.includes(omittedQuestion),
|
||||
)
|
||||
denseTable === undefined ||
|
||||
evidence.normalized_result?.residual_unknowns?.length !== 0
|
||||
)
|
||||
throw new Error(
|
||||
`The shipped inspect-native-api CLI did not preserve dense jump-table truncation: ${stdout}`,
|
||||
`The shipped inspect-native-api CLI did not preserve complete dense jump-table output: ${stdout}`,
|
||||
);
|
||||
return {
|
||||
operation: evidence.operation,
|
||||
provider: evidence.provider,
|
||||
mappings_returned: truncated.mappings.length,
|
||||
mappings_returned: denseTable.mappings.length,
|
||||
residual_unknowns: evidence.normalized_result.residual_unknowns.length,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user