Files
rea/src/config/environment.ts
T
N0zoM1z0 fb679b63c2 feat(ghidra): integrate optional NativeAOT metadata recovery (#748)
* feat(ghidra): integrate optional NativeAOT metadata recovery

* fix(ghidra): bind extension snapshots to configured artifacts

* test(ghidra): verify lazy NativeAOT startup failures

* fix(ghidra): preserve NativeAOT failure reasons and coverage

* fix(ghidra): preserve NativeAOT x64 calling conventions

* test(ghidra): guard recovered NativeAOT method conventions

* fix(ghidra): reject blocking extension file inputs

* fix(ghidra): diagnose incompatible NativeAOT extension classes

* test(ghidra): verify real extension initialization failures

* fix(ghidra): keep extension descriptor fields optional
2026-10-07 00:57:08 +08:00

55 lines
1.7 KiB
TypeScript

import { z } from "zod";
import { isAbsolute } from "node:path";
import { ConfigurationError } from "../domain/configurationErrors.js";
import { err, ok, type Result } from "../domain/result.js";
import { analysisProviderSelectorSchema } from "../contracts/providerSelection.js";
const environmentSchema = z.object({
REA_ANALYSIS_PROVIDER: analysisProviderSelectorSchema.default("auto"),
GHIDRA_INSTALL_DIR: z
.string()
.min(1)
.refine(isAbsolute, "GHIDRA_INSTALL_DIR must be absolute")
.optional(),
JAVA_HOME: z
.string()
.min(1)
.refine(isAbsolute, "JAVA_HOME must be absolute")
.optional(),
REA_GHIDRA_NATIVEAOT_JAR: z
.string()
.min(1)
.refine(isAbsolute, "REA_GHIDRA_NATIVEAOT_JAR must be absolute")
.optional(),
REA_ILSPY_CMD_PATH: z
.string()
.min(1)
.refine(isAbsolute, "REA_ILSPY_CMD_PATH must be absolute")
.optional(),
HOPPER_LAUNCHER_PATH: z.string().min(1).optional(),
HOPPER_TARGET_PATH: z.string().min(1).optional(),
HOPPER_TARGET_KIND: z.enum(["executable", "database"]).default("executable"),
HOPPER_LOADER_ARGS_JSON: z.string().optional(),
REA_LOG_LEVEL: z
.enum(["trace", "debug", "info", "warn", "error", "fatal", "silent"])
.default("info"),
REA_REFERENCE_SECRET_PATTERNS_JSON: z.string().default("[]"),
});
export type Environment = z.infer<typeof environmentSchema>;
export const parseEnvironment = (
environment: Readonly<Record<string, string | undefined>>,
): Result<Environment, ConfigurationError> => {
const parsed = environmentSchema.safeParse(environment);
if (!parsed.success) {
return err(
new ConfigurationError("Invalid REA environment configuration", {
cause: parsed.error,
}),
);
}
return ok(parsed.data);
};