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:
+55
-1
@@ -2,6 +2,11 @@ import {
|
||||
executableFormatHintSchema,
|
||||
type ExecutableFormatHint,
|
||||
} from "../domain/dosCom.js";
|
||||
import type { BinaryArchitecture } from "../domain/binaryTargetTypes.js";
|
||||
import {
|
||||
binaryArchitectureSchema,
|
||||
rawBinaryEntryPointSchema,
|
||||
} from "../domain/rawBinary.js";
|
||||
import { analysisProviderSelectorSchema } from "../contracts/providerSelection.js";
|
||||
import type { AnalysisProviderSelector } from "../contracts/providerSelection.js";
|
||||
import type { Logger } from "pino";
|
||||
@@ -15,16 +20,65 @@ export const providerSelectionOption = analysisProviderSelectorSchema
|
||||
/** Explicit interpretation for headerless native executable formats. */
|
||||
export const formatSelectionOption = executableFormatHintSchema
|
||||
.optional()
|
||||
.describe("Explicit headerless DOS COM interpretation");
|
||||
.describe(
|
||||
"Explicit headerless interpretation (dos-com or raw-binary); omission preserves header-based detection",
|
||||
);
|
||||
|
||||
export const architectureSelectionOption = binaryArchitectureSchema
|
||||
.optional()
|
||||
.describe(
|
||||
"Caller-supplied CPU family; required with --target-format raw-binary",
|
||||
);
|
||||
|
||||
export const entryPointSelectionOption = rawBinaryEntryPointSchema
|
||||
.optional()
|
||||
.describe(
|
||||
"Caller-supplied load and entry address (0xhex); required with --target-format raw-binary",
|
||||
);
|
||||
|
||||
/** Shared CLI flags that bind a native target interpretation. */
|
||||
export const nativeOpenOptionFields = {
|
||||
"target-format": formatSelectionOption,
|
||||
architecture: architectureSelectionOption,
|
||||
"entry-point": entryPointSelectionOption,
|
||||
provider: providerSelectionOption,
|
||||
};
|
||||
|
||||
/** Native CLI flags consumed when opening a target for one-shot analysis. */
|
||||
export interface NativeOpenCliFlags {
|
||||
readonly snapshot?: string | undefined;
|
||||
readonly provider?: AnalysisProviderSelector | undefined;
|
||||
readonly "target-format"?: ExecutableFormatHint | undefined;
|
||||
readonly architecture?: BinaryArchitecture | undefined;
|
||||
readonly "entry-point"?: string | undefined;
|
||||
}
|
||||
|
||||
export const directAnalysisOptions = (
|
||||
logger: Logger,
|
||||
snapshotPath: string | undefined,
|
||||
providerId: AnalysisProviderSelector | undefined,
|
||||
formatHint?: ExecutableFormatHint,
|
||||
architecture?: BinaryArchitecture,
|
||||
entryPoint?: string,
|
||||
) => ({
|
||||
logger,
|
||||
snapshotPath,
|
||||
...(formatHint === undefined ? {} : { formatHint }),
|
||||
...(architecture === undefined ? {} : { architecture }),
|
||||
...(entryPoint === undefined ? {} : { entryPoint }),
|
||||
...(providerId === undefined ? {} : { providerId }),
|
||||
});
|
||||
|
||||
/** Map native CLI flags onto the shared one-shot analysis options. */
|
||||
export const directAnalysisOptionsFromCli = (
|
||||
logger: Logger,
|
||||
options: NativeOpenCliFlags,
|
||||
) =>
|
||||
directAnalysisOptions(
|
||||
logger,
|
||||
options.snapshot,
|
||||
options.provider,
|
||||
options["target-format"],
|
||||
options.architecture,
|
||||
options["entry-point"],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user