feat(native): admit raw binaries with caller-supplied architecture and entry (#1868)
* feat(native): admit raw binaries with caller-supplied architecture and entry * fix(native): honor raw-binary preparation and entry identity * fix(ghidra): stream raw snapshot attestation with cancellation * fix(native): preserve and validate raw lifecycle entries --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import type { GhidraInstallationInspection } from "./GhidraInstallation.js";
|
||||
import { ghidraMipsProfileParameters } from "./GhidraMipsProfile.js";
|
||||
import { ghidraRawBinaryLanguage } from "./GhidraRawBinaryLanguage.js";
|
||||
|
||||
import {
|
||||
ghidraProcessorUnsupportedReason,
|
||||
@@ -69,6 +70,57 @@ export const resolveGhidraAnalysisProfile = async (
|
||||
: null;
|
||||
if (pspExtension !== null && !pspExtension.ok) return pspExtension;
|
||||
const provider = { ...identity, version: installation.providerVersion };
|
||||
if (target.format === "raw-binary") {
|
||||
if (languageOverride !== undefined)
|
||||
return Promise.resolve(
|
||||
err(
|
||||
new AnalysisUnsupportedTargetError(
|
||||
"resolve_analysis_profile",
|
||||
target.path,
|
||||
"REA_GHIDRA_LANGUAGE_ID cannot override the admitted raw-binary import.",
|
||||
),
|
||||
),
|
||||
);
|
||||
const language = ghidraRawBinaryLanguage(target.architecture);
|
||||
return Promise.resolve(
|
||||
ok({
|
||||
profile: createAnalysisProfile(provider, {
|
||||
target_kind: target.kind,
|
||||
target_format: target.format,
|
||||
architecture: target.architecture,
|
||||
available_architectures: [...target.availableArchitectures].sort(),
|
||||
import_mode: "ephemeral-source-immutable",
|
||||
annotation_policy: "atomic-function-entry-metadata-v1",
|
||||
load_image_observations: "source-mappings-entry-context-v2",
|
||||
function_body_evidence: "complete-inclusive-ranges-v1",
|
||||
function_references: "complete-body-and-entry-reference-manager-v2",
|
||||
string_inventory_evidence: "defined-data-coverage-v1",
|
||||
location_resolution: "explicit-address-exact-entry-symbol-first-v3",
|
||||
instruction_flow_evidence: "decoded-return-pcode-v1",
|
||||
instruction_references: "exact-address-incoming-v1",
|
||||
function_boundary_observations: "ghidra-terminal-call-limitations-v1",
|
||||
no_return_repair:
|
||||
installation.platform === "win32"
|
||||
? "disabled-windows-p0"
|
||||
: "returning-imports-decoded-return-v2",
|
||||
process_launch:
|
||||
installation.platform === "win32"
|
||||
? "official-headless-script-v1"
|
||||
: "inspected-jvm-launch-support-v1",
|
||||
load_image_evidence: "independent-raw-mapping-context-v2",
|
||||
jump_table_evidence: "typed-case-default-blocks-v1",
|
||||
decompiler_jump_loads: true,
|
||||
loader: "BinaryLoader",
|
||||
language_id: language.languageId,
|
||||
compiler_spec_id: language.compilerSpecId,
|
||||
language_selection: "caller-supplied-v1",
|
||||
entry_point: target.entryPoint,
|
||||
entry_seed: "external-entry-and-function-before-analysis-v1",
|
||||
analyzer_preset: "ghidra-default",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
const dosMz = target.format === "dos-mz";
|
||||
const dosCom = target.format === "dos-com";
|
||||
const dos = dosMz || dosCom;
|
||||
|
||||
Reference in New Issue
Block a user