mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 22:15:50 +00:00
fix(ghidra): name the code seed recovery for addresses outside the listing (#10682)
inspect_native_instruction reports `not-in-listing` when an address lies in Ghidra's memory but the listing has no instruction or defined data there. No decode is attempted, so the answer does not show the bytes are data, yet the result named no way forward. #10623 added the declared-seed recovery for procedure_not_found and not_in_procedure; this is the instruction-level sibling, where a `code` seed applies. A not-in-listing answer now carries ghidraNotInListingLimitation(source). It names a `code` seed (or a `function` seed for an entry point) in REA_GHIDRA_SEED_FILE, says which setting to unset first for a selected project or checkpoint, and does not assert that the address holds code. decoded, data and other statuses are unchanged. The installation guide's seed section lists the new carrier. Validation: src/ghidra/GhidraProvider.behavior.test.ts fails 1/298 with the caveat removed and passes 298/298 with it; check:fast passes. No real Ghidra run. Refs morluto/rea#3767
This commit is contained in:
1 parent
e7a023263b
commit
33ecda025f
4 files changed
+61
-2
No files matched your search
@@ -1848,7 +1848,7 @@ Each line is `address<TAB>kind[<TAB>name]`, where kind is `function`, `code` or
|
||||
|
||||
Label seeds can name mapped uninitialized storage such as `.bss`; function and code seeds require initialized bytes.
|
||||
|
||||
When Ghidra has no function for a requested procedure, the error's remediation names this seed recovery. A `resolve_containing_procedure` result of `not_in_procedure` carries it as a limitation. Neither establishes that the address holds code. Seeds apply only to a fresh import, so a session with `REA_GHIDRA_PROJECT_PATH` or `REA_GHIDRA_CHECKPOINT_DIR` names the setting to unset first.
|
||||
When Ghidra has no function for a requested procedure, the error's remediation names this seed recovery. A `resolve_containing_procedure` result of `not_in_procedure` carries it as a limitation, and an `inspect_native_instruction` result with status `not-in-listing` carries the `code` seed variant. None of these establishes that the address holds code. Seeds apply only to a fresh import, so a session with `REA_GHIDRA_PROJECT_PATH` or `REA_GHIDRA_CHECKPOINT_DIR` names the setting to unset first.
|
||||
|
||||
To skip a named Ghidra auto-analyzer (for example, when default auto-analysis
|
||||
stalls in one analyzer on a Swift/Objective-C arm64 Mach-O):
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
ghidraEmptyOutgoingReferencesLimitation,
|
||||
ghidraEmptyXrefsLimitation,
|
||||
ghidraFunctionSeedRecovery,
|
||||
ghidraNotInListingLimitation,
|
||||
ghidraNotInProcedureLimitation,
|
||||
limitationsFor,
|
||||
type GhidraSessionSource,
|
||||
@@ -4144,6 +4145,31 @@ describe("Ghidra empty instruction reference facets", () => {
|
||||
expect(limitations).not.toContain(ghidraEmptyXrefsLimitation);
|
||||
expect(limitations).not.toContain(ghidraEmptyInstructionOutgoingLimitation);
|
||||
});
|
||||
|
||||
it("names the code seed recovery when the address is not in Ghidra's listing", async () => {
|
||||
const limitations = await executeInspect({
|
||||
...compactInstruction(),
|
||||
status: "not-in-listing",
|
||||
bytes: null,
|
||||
length: null,
|
||||
mnemonic: null,
|
||||
raw_disassembly: null,
|
||||
incoming_references: [compactReference()],
|
||||
});
|
||||
expect(
|
||||
limitations.filter((item) => item.includes("REA_GHIDRA_SEED_FILE")),
|
||||
).toEqual([ghidraNotInListingLimitation("fresh-import")]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["decoded", instruction([compactReference()], [compactReference()])],
|
||||
["data", definedData([compactReference()])],
|
||||
])("adds no seed recovery to a %s instruction answer", async (_, result) => {
|
||||
const limitations = await executeInspect(result);
|
||||
expect(
|
||||
limitations.some((item) => item.includes("REA_GHIDRA_SEED_FILE")),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ghidra containing-procedure absence", () => {
|
||||
|
||||
@@ -123,6 +123,15 @@ export const ghidraNotInProcedureLimitation = (
|
||||
): string =>
|
||||
`Ghidra has no function at or containing this address in this session. This reflects the current function inventory, not proof that the address holds no code. ${ghidraFunctionSeedRecovery(source)}`;
|
||||
|
||||
/**
|
||||
* Attached to a not-in-listing instruction: Ghidra attempted no decode, so the
|
||||
* answer does not show the bytes are data. Names the `code` seed recovery.
|
||||
*/
|
||||
export const ghidraNotInListingLimitation = (
|
||||
source: GhidraSessionSource,
|
||||
): string =>
|
||||
`Ghidra's listing has no instruction or defined data at this address in this session, so no decode was attempted; this is not proof that the bytes are not code. If they are initialized code that auto-analysis did not reach, declare the address as a \`code\` seed, or a \`function\` seed for an entry point, in REA_GHIDRA_SEED_FILE for a new REA process${seedSessionRestriction[source]}; that session's seed outcome limitation counts decoded, failed and unmapped seeds.`;
|
||||
|
||||
/** Limitation text for one admitted operation, including the common base. */
|
||||
export const limitationsFor = (
|
||||
operation: string,
|
||||
|
||||
@@ -143,6 +143,7 @@ import {
|
||||
ghidraEmptyInstructionOutgoingLimitation,
|
||||
ghidraEmptyOutgoingReferencesLimitation,
|
||||
ghidraFunctionSeedRecovery,
|
||||
ghidraNotInListingLimitation,
|
||||
ghidraNotInProcedureLimitation,
|
||||
windowsP0Limitations,
|
||||
limitationsFor,
|
||||
@@ -346,6 +347,22 @@ const containingProcedureAbsenceCaveat = (
|
||||
: [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Caveat for an instruction query in mapped memory that Ghidra's listing does
|
||||
* not cover: no decode was attempted, so code there remains possible.
|
||||
*/
|
||||
const instructionListingAbsenceCaveat = (
|
||||
operation: GhidraFunctionOperation,
|
||||
normalized: JsonValue,
|
||||
source: GhidraSessionSource,
|
||||
): readonly string[] => {
|
||||
if (operation !== "inspect_native_instruction") return [];
|
||||
const record = referenceObservationRecord(normalized);
|
||||
return record?.status === "not-in-listing"
|
||||
? [ghidraNotInListingLimitation(source)]
|
||||
: [];
|
||||
};
|
||||
|
||||
/** Build one AnalysisClient for an admitted Ghidra target and profile. */
|
||||
export const createGhidraProviderClient = (input: {
|
||||
readonly config: AppConfig;
|
||||
@@ -1139,7 +1156,14 @@ export const createGhidraProviderClient = (input: {
|
||||
let { value: normalized, ...observation } = result.value;
|
||||
let executionMetadata: GhidraExecutionMetadata = observation;
|
||||
const absenceCaveats = isGhidraFunctionOperation(operation)
|
||||
? emptyReferenceCaveat(operation, normalized)
|
||||
? [
|
||||
...emptyReferenceCaveat(operation, normalized),
|
||||
...instructionListingAbsenceCaveat(
|
||||
operation,
|
||||
normalized,
|
||||
projection.source,
|
||||
),
|
||||
]
|
||||
: containingProcedureAbsenceCaveat(
|
||||
operation,
|
||||
normalized,
|
||||
|
||||
Reference in new issue
Block a user