mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
* refactor(analysis): centralize resource budgets and recovery facts * feat(analysis): expose ASAR and Ghidra runtime admission controls * feat(artifacts): expose reader admission and preserve limited recognition * feat(javascript): expose recoverable semantic precision budgets * feat(web): add recoverable source-map budgets and compact retained views * feat(web): make historical capture decoding budgets recoverable * fix(desktop): enforce selected view policies across capture and export * feat(runtime): make Frida and LLDB retention budgets selectable * feat(native): expose diagnostic budgets and preserve exhaustion causes * feat(managed): expose recoverable snapshot and representation budgets * feat(metadata): make Go and Rust inspection budgets recoverable * feat(wasm): expose representation and producer admissions * feat(evm): expose per-call worker resource budgets * feat(android): make resource and string-pool omissions recoverable * feat(producers): expose command and recorded-capture budgets * docs(analysis): record recovery contracts and integrated validation * fix(docs): link calibration oracle from published verification pages * fix(docs): restore desktop task anchors and receipt links * test(analysis): align fixtures with selectable budget contracts * fix(analysis): remove source-location projector dependency cycle * test(analysis): refresh budget recovery and verifier regressions * test(analysis): preserve format and publication recovery expectations * test(windows): align conformance with owned runtime admission * fix(desktop): preserve selected alias kinds in exported state * test(analysis): align provider fixtures with recoverable budgets * test(desktop): validate emitted alias metadata structurally * fix(ghidra): classify bounded Windows endpoint refusals * test(cli): assert selectable artifact admission recovery * fix(cli): preserve capture provenance in environment builds
68 lines
3.0 KiB
TypeScript
68 lines
3.0 KiB
TypeScript
import { err, ok } from "../domain/result.js";
|
|
import type { z } from "zod";
|
|
import type { AnalysisSettingId } from "../domain/analysisSettings.js";
|
|
import { analysisSettingDefinition } from "../domain/analysisSettingDefinitions.js";
|
|
import { ConfigurationError } from "../domain/configurationErrors.js";
|
|
import { asarMaxHeaderBytesSchema } from "./asarHeaderAdmission.js";
|
|
import { asarMaxListingBytesSchema } from "./asarListingAdmission.js";
|
|
import {
|
|
ghidraValueFlowCountSchema,
|
|
ghidraDecompilePayloadMiBSchema,
|
|
} from "./ghidraValueFlowLimits.js";
|
|
import {
|
|
providerStartupTimeoutSchema,
|
|
ghidraDecompileTimeoutSchema,
|
|
} from "./providerStartupTimeout.js";
|
|
import { regexMatchingDeadlineMsSchema } from "./regexMatchingDeadline.js";
|
|
import { regexWorkerHeapRequestMiBSchema } from "./regexWorkerHeapRequest.js";
|
|
import { captureDecoderOldGenerationMiBSchema } from "./captureDecoderHeap.js";
|
|
import { parseNativeMatchingAllowance } from "./nativeMatchingAllowance.js";
|
|
const environmentSchemas: Readonly<Record<string, z.ZodType<number, string>>> =
|
|
{
|
|
REA_ASAR_MAX_HEADER_BYTES: asarMaxHeaderBytesSchema,
|
|
REA_ASAR_MAX_LISTING_BYTES: asarMaxListingBytesSchema,
|
|
REA_GHIDRA_VALUE_FLOW_MAX_OPERATIONS: ghidraValueFlowCountSchema,
|
|
REA_GHIDRA_VALUE_FLOW_MAX_INPUTS_PER_OPERATION: ghidraValueFlowCountSchema,
|
|
REA_GHIDRA_VALUE_FLOW_MAX_EDGES: ghidraValueFlowCountSchema,
|
|
REA_GHIDRA_DECOMPILE_MAX_PAYLOAD_MIB: ghidraDecompilePayloadMiBSchema,
|
|
REA_GHIDRA_STARTUP_TIMEOUT_MS: providerStartupTimeoutSchema,
|
|
REA_HOPPER_STARTUP_TIMEOUT_MS: providerStartupTimeoutSchema,
|
|
REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS: ghidraDecompileTimeoutSchema,
|
|
REA_JADX_OPERATION_TIMEOUT_MS: providerStartupTimeoutSchema,
|
|
REA_REGEX_MATCHING_DEADLINE_MS: regexMatchingDeadlineMsSchema,
|
|
REA_REGEX_WORKER_HEAP_REQUEST_MIB: regexWorkerHeapRequestMiBSchema,
|
|
REA_CAPTURE_DECODER_OLD_GENERATION_MIB:
|
|
captureDecoderOldGenerationMiBSchema,
|
|
};
|
|
export const launchAnalysisSetting = (
|
|
id: AnalysisSettingId,
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
) => {
|
|
if (id === "native.matching_representation_bytes") {
|
|
const parsed = parseNativeMatchingAllowance(environment);
|
|
return parsed.ok
|
|
? ok({ value: parsed.value.maximumBytes, source: parsed.value.source })
|
|
: parsed;
|
|
}
|
|
const definition = analysisSettingDefinition(id);
|
|
const raw =
|
|
definition.environment === undefined
|
|
? undefined
|
|
: environment[definition.environment];
|
|
if (raw === undefined)
|
|
return ok({ value: definition.defaultValue, source: "default" as const });
|
|
const parsed = environmentSchemas[definition.environment!]?.safeParse(raw);
|
|
if (parsed?.success !== true)
|
|
return err(
|
|
new ConfigurationError(`Invalid ${definition.environment}`, {
|
|
settings: [
|
|
{
|
|
setting: definition.environment!,
|
|
constraint: `Expected an integer from ${definition.minimum} to ${definition.maximum} ${definition.unit}`,
|
|
},
|
|
],
|
|
}),
|
|
);
|
|
return ok({ value: parsed.data, source: "setting" as const });
|
|
};
|