mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
* fix(limits): admit a ZIP member count on reader limits artifact.member_count now resolves artifact_limits.zip.member_count. Recorded Evidence from before this group may omit zip. * fix(zip): refuse a central directory past the member count Count every central-directory record before retaining it. The refusal omits required_value because later records stay unread. * test(zip): cover a central directory past the member count Three empty members at a count of two refuse through the reader and through the zip format reader. * docs(limits): name zip.member_count on the member-count setting The existing REA_ARTIFACT_MEMBER_COUNT seed already supplies that default. * test(artifacts): select the ZIP member count with the explicit fields The acceptance case ignores an invalid artifact.member_count seed only when every backed field is selected. zip.member_count is one of those fields. * fix(schemas): record the ZIP member-count input summaries extract_artifact and inspect_artifact changed their input compact schema when zip.member_count was advertised. * fix(zip): keep member count on Flutter, Playwright, and SAZ Those readers omitted the session count and described the refusal as a byte budget. They now admit artifact.member_count and report the count. * test(zip): cover member-count refusals outside artifact inventory A two-member archive at a session count of one stays a count for Flutter, Playwright traces, and SAZ. One member still passes that cap. * docs(limits): name the ZIP consumers of artifact.member_count Flutter APK inventory, Playwright trace import, and SAZ decoding use the session count and report it as a count. * fix(capture): read the fixed-limit boundary from the ceiling CaptureFormatError keeps that boundary on ceiling. The SAZ reply read cause.boundary, so a fixed-limit reply omitted the field the parent requires. * fix(limits): recover ZIP member count through the session setting Flutter, Playwright, and SAZ have no artifact_limits argument. The refusal names artifact.member_count, leaves parameter unset, and tells the caller to raise that setting. sessionSettingConstraint owns the error next to the other resource refusals. * fix(android): keep a partial JNI report at the ZIP member count readAndroidJniLibraries already returns a partial inventory when its entry allowance stops the scan. The session member count is that same stop. The reader takes artifact.member_count, and the report names the unexamined remainder instead of aborting the inspection. * fix(zip): resolve the member count from the selected environment ZIP admission and its refusal use the launch environment selected for the runtime. Only SAZ sends that count to the capture decoder. * fix(zip): drop the unused ZipReaderLimits export Knip reports the type because no caller imports it. ZIP limits stay on the schema. * fix(playwright): return an invalid member-count seed as a result The trace catch uses the count captured before the failure. A configuration error stays a Result and keeps the archive hash. * fix(jni): name the member count on a partial library scan The partial report keeps the count that stopped the scan and the recovery for artifact.member_count. * fix(settings): register artifact.member_count for its ZIP consumers Scoped inspection of the Flutter, Playwright, capture, and JNI operations includes the setting. * test(artifacts): parse Evidence that omits the audit-log policy The merged reader-limit schema still accepts a record that omits the Kubernetes audit-log policy.
592 lines
19 KiB
TypeScript
592 lines
19 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { AnalysisSettings } from "./AnalysisSettings.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import {
|
|
DEFAULT_ASAR_MAX_HEADER_BYTES,
|
|
DEFAULT_ASAR_MAX_LISTING_BYTES,
|
|
DEFAULT_GHIDRA_STARTUP_TIMEOUT_MS,
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_EDGES,
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_INPUTS_PER_OPERATION,
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_OPERATIONS,
|
|
DEFAULT_REGEX_MATCHING_DEADLINE_MS,
|
|
} from "../domain/analysisResourceLimits.js";
|
|
import {
|
|
applyWindowsChangeTimeSnapshot,
|
|
resolveWindowsChangeTimeSettle,
|
|
} from "../config/windowsChangeTimeSettle.js";
|
|
import { pwntoolsInputBytes } from "../config/pwntoolsInputLimit.js";
|
|
import { resolveCaptureDecoderHeap } from "../config/captureDecoderHeap.js";
|
|
import { resolveRegexMatchingDeadline } from "../config/regexMatchingDeadline.js";
|
|
import { resolveRegexWorkerHeapRequest } from "../config/regexWorkerHeapRequest.js";
|
|
import { runWithAnalysisOperationSnapshot } from "../domain/analysisOperationSnapshot.js";
|
|
import {
|
|
runtimeAnalysisConfig,
|
|
runtimeAsarHeaderAdmission,
|
|
runtimeCaptureDecoderHeap,
|
|
} from "../config/runtimeAnalysisSettings.js";
|
|
import { parseConfig } from "../config/parseConfig.js";
|
|
|
|
it.each([
|
|
["inspect_native_api", [64, 7]],
|
|
["trace_native_ui_action", []],
|
|
] as const)(
|
|
"reports the decompiler budgets consumed by %s",
|
|
(operation, values) => {
|
|
const store = new AnalysisSettings({
|
|
REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS: "7",
|
|
REA_GHIDRA_DECOMPILE_MAX_PAYLOAD_MIB: "64",
|
|
});
|
|
expect(
|
|
store
|
|
.inspect({
|
|
provider: "ghidra",
|
|
operation,
|
|
settings: [
|
|
"ghidra.decompile_max_payload_mib",
|
|
"ghidra.decompile_timeout_seconds",
|
|
],
|
|
})
|
|
.settings.map(({ value }) => value),
|
|
).toEqual(values);
|
|
},
|
|
);
|
|
|
|
it("updates atomically, restores launch values, and refuses stale or invalid writes", () => {
|
|
const store = new AnalysisSettings({ REA_ASAR_MAX_HEADER_BYTES: "20000000" });
|
|
const inspect = () => store.inspect({ settings: ["asar.max_header_bytes"] });
|
|
expect(inspect().settings[0]).toMatchObject({
|
|
value: 20000000,
|
|
source: "setting",
|
|
});
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 30000000 },
|
|
],
|
|
expected_revision: 0,
|
|
}).ok,
|
|
).toBe(true);
|
|
expect(inspect()).toMatchObject({
|
|
revision: 1,
|
|
settings: [{ value: 30000000, source: "runtime" }],
|
|
});
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 30000000 },
|
|
],
|
|
}),
|
|
).toMatchObject({ ok: true, value: { changed: false, revision: 1 } });
|
|
for (const changes of [
|
|
[
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 100 },
|
|
{ setting: "wasm.command_timeout_ms", action: "set", value: 0 },
|
|
],
|
|
[
|
|
{ setting: "asar.max_header_bytes", action: "reset" },
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 100 },
|
|
],
|
|
[{ setting: "NODE_OPTIONS", action: "set", value: 1 }],
|
|
])
|
|
expect(store.update({ changes }).ok).toBe(false);
|
|
expect(
|
|
store.update({
|
|
changes: [{ setting: "asar.max_header_bytes", action: "reset" }],
|
|
expected_revision: 0,
|
|
}).ok,
|
|
).toBe(false);
|
|
expect(inspect().revision).toBe(1);
|
|
expect(
|
|
store.update({
|
|
changes: [{ setting: "asar.max_header_bytes", action: "reset" }],
|
|
}),
|
|
).toMatchObject({
|
|
ok: true,
|
|
value: { revision: 2, settings: [{ value: 20000000, source: "setting" }] },
|
|
});
|
|
expect(new AnalysisSettings({}).inspect().revision).toBe(0);
|
|
});
|
|
|
|
it("keeps accepted operations and their typed provider views stable across concurrent updates", async () => {
|
|
const store = new AnalysisSettings({});
|
|
const config = parseConfig({});
|
|
if (!config.ok) throw config.error;
|
|
const live = runtimeAnalysisConfig(config.value, store.read);
|
|
const asar = runtimeAsarHeaderAdmission({}, store.read);
|
|
let release!: () => void;
|
|
const barrier = new Promise<void>((resolve) => {
|
|
release = resolve;
|
|
});
|
|
const pending = store.run(async () => {
|
|
await barrier;
|
|
expect(asar.maximumBytes).toBe(DEFAULT_ASAR_MAX_HEADER_BYTES);
|
|
expect(asar.listing?.maximumBytes).toBe(DEFAULT_ASAR_MAX_LISTING_BYTES);
|
|
expect(live.ghidraValueFlowMaxOperations).toBe(
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_OPERATIONS,
|
|
);
|
|
expect(live.ghidraValueFlowMaxInputsPerOperation).toBe(
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_INPUTS_PER_OPERATION,
|
|
);
|
|
expect(live.ghidraValueFlowMaxEdges).toBe(
|
|
DEFAULT_GHIDRA_VALUE_FLOW_MAX_EDGES,
|
|
);
|
|
expect(live.ghidraStartupTimeoutMs).toBe(DEFAULT_GHIDRA_STARTUP_TIMEOUT_MS);
|
|
expect(live.regexMatchingDeadline.deadlineMs).toBe(
|
|
DEFAULT_REGEX_MATCHING_DEADLINE_MS,
|
|
);
|
|
expect(store.read().revision).toBe(0);
|
|
});
|
|
try {
|
|
const changed = store.update({
|
|
changes: [
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 33554432 },
|
|
{ setting: "asar.max_listing_bytes", action: "set", value: 134217728 },
|
|
{
|
|
setting: "ghidra.value_flow_max_operations",
|
|
action: "set",
|
|
value: 6000,
|
|
},
|
|
{
|
|
setting: "ghidra.value_flow_max_inputs_per_operation",
|
|
action: "set",
|
|
value: 128,
|
|
},
|
|
{ setting: "ghidra.value_flow_max_edges", action: "set", value: 24000 },
|
|
{ setting: "ghidra.startup_timeout_ms", action: "set", value: 999999 },
|
|
{ setting: "regex.matching_deadline_ms", action: "set", value: 10000 },
|
|
],
|
|
});
|
|
expect(changed.ok).toBe(true);
|
|
} finally {
|
|
release();
|
|
await Promise.allSettled([pending]);
|
|
}
|
|
await pending;
|
|
store.run(() => {
|
|
expect(asar.maximumBytes).toBe(33554432);
|
|
expect(asar.listing?.maximumBytes).toBe(134217728);
|
|
expect(live.ghidraValueFlowMaxOperations).toBe(6000);
|
|
expect(live.ghidraValueFlowMaxInputsPerOperation).toBe(128);
|
|
expect(live.ghidraValueFlowMaxEdges).toBe(24000);
|
|
expect(live.ghidraStartupTimeoutMs).toBe(999999);
|
|
expect(live.regexMatchingDeadline.deadlineMs).toBe(10000);
|
|
});
|
|
});
|
|
|
|
it("lists artifact.member_count for the ZIP consumers outside artifact inventory", () => {
|
|
const store = new AnalysisSettings({});
|
|
for (const scope of [
|
|
{ provider: "flutter", operation: "identify_flutter_build" },
|
|
{ provider: "flutter", operation: "inspect_dart_aot" },
|
|
{ provider: "rea-playwright-trace", operation: "inspect_playwright_trace" },
|
|
{
|
|
provider: "web-network-capture",
|
|
operation: "inspect_web_network_capture",
|
|
},
|
|
{ provider: "jadx", operation: "inspect_android_jni_bindings" },
|
|
] as const)
|
|
expect(
|
|
store.inspect(scope).settings.map(({ setting }) => setting),
|
|
).toContain("artifact.member_count");
|
|
});
|
|
|
|
it("lists zstd.max_frames for every operation that enforces the cap", () => {
|
|
const store = new AnalysisSettings({});
|
|
for (const operation of [
|
|
"inspect_artifact",
|
|
"extract_artifact",
|
|
"inspect_gpu_code_objects",
|
|
"inspect_dwarf_units",
|
|
"inspect_elf_notes",
|
|
"inspect_binary_hardening",
|
|
"inspect_elf_unwind_ranges",
|
|
"inspect_native_exports",
|
|
"inspect_native_initializers",
|
|
"inspect_kernel_module",
|
|
"inspect_elf_debug_link",
|
|
"inspect_go_binary",
|
|
"inspect_rust_binary",
|
|
"inspect_il2cpp_metadata",
|
|
"inspect_android_jni_bindings",
|
|
])
|
|
expect(
|
|
store.inspect({ operation }).settings.map(({ setting }) => setting),
|
|
).toContain("zstd.max_frames");
|
|
for (const provider of [
|
|
"gpu-code-objects",
|
|
"rea-dwarf-units",
|
|
"rea-elf-notes",
|
|
"rea-binary-hardening",
|
|
"rea-elf-unwind-ranges",
|
|
"rea-native-exports",
|
|
"rea-native-initializers",
|
|
"rea-kernel-module",
|
|
"rea-elf-debug-link",
|
|
"go-build-info",
|
|
"rust-auditable",
|
|
"il2cpp-metadata",
|
|
"jadx",
|
|
])
|
|
expect(
|
|
store.inspect({ provider }).settings.map(({ setting }) => setting),
|
|
).toContain("zstd.max_frames");
|
|
expect(
|
|
store
|
|
.inspect({ operation: "inspect_binary_layout" })
|
|
.settings.map(({ setting }) => setting),
|
|
).not.toContain("zstd.max_frames");
|
|
});
|
|
|
|
it("exposes shared provider controls and preserves the explicit unbounded decompile value", () => {
|
|
const environment = {
|
|
REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS: "7",
|
|
REA_GHIDRA_DECOMPILE_MAX_PAYLOAD_MIB: "64",
|
|
};
|
|
const store = new AnalysisSettings(environment);
|
|
for (const provider of ["ghidra", "hopper"] as const)
|
|
expect(
|
|
store
|
|
.inspect({ provider, operation: "open_binary" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toEqual(
|
|
expect.arrayContaining([
|
|
`${provider}.startup_timeout_ms`,
|
|
"bridge.max_request_bytes",
|
|
]),
|
|
);
|
|
const parsed = parseConfig(environment);
|
|
if (!parsed.ok) throw parsed.error;
|
|
const config = runtimeAnalysisConfig(parsed.value, store.read);
|
|
expect(config.ghidraDecompileMaxPayloadMiB).toBe(64);
|
|
expect(
|
|
store
|
|
.inspect({ provider: "ghidra", operation: "search_strings" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toEqual([
|
|
"ghidra.startup_timeout_ms",
|
|
"bridge.max_request_bytes",
|
|
"bridge.max_reply_bytes",
|
|
]);
|
|
for (const operation of ["list_cutter_sessions", "cutter_command"] as const)
|
|
expect(
|
|
store
|
|
.inspect({ provider: "cutter", operation })
|
|
.settings.map(({ setting }) => setting),
|
|
).toContain("bridge.max_request_bytes");
|
|
expect(
|
|
store
|
|
.inspect({ provider: "ida", operation: "search_strings" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toEqual(["regex.matching_deadline_ms", "regex.worker_heap_request_mib"]);
|
|
expect(
|
|
store
|
|
.inspect({ operation: "inventory_artifact" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toEqual([
|
|
"artifact.member_count",
|
|
"asar.max_listing_bytes",
|
|
"asar.max_header_bytes",
|
|
"windows.change_time_drift_ms",
|
|
"windows.change_time_settle_poll_ms",
|
|
"windows.change_time_settle_max_polls",
|
|
]);
|
|
for (const operation of [
|
|
"open_binary",
|
|
"export_web_scripts",
|
|
"inspect_analysis_view",
|
|
"inspect_android_package",
|
|
"capture_process_scenario",
|
|
]) {
|
|
expect(
|
|
store.inspect({ operation }).settings.map(({ setting }) => setting),
|
|
).toEqual(
|
|
expect.arrayContaining([
|
|
"windows.change_time_drift_ms",
|
|
"windows.change_time_settle_poll_ms",
|
|
"windows.change_time_settle_max_polls",
|
|
]),
|
|
);
|
|
}
|
|
expect(
|
|
store
|
|
.inspect({ provider: "jadx", operation: "inspect_android_package" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toEqual(
|
|
expect.arrayContaining([
|
|
"windows.change_time_drift_ms",
|
|
"windows.change_time_settle_poll_ms",
|
|
"windows.change_time_settle_max_polls",
|
|
]),
|
|
);
|
|
for (const operation of [
|
|
"procedure_pseudo_code",
|
|
"procedure_assembly",
|
|
"analyze_function",
|
|
] as const)
|
|
expect(
|
|
store
|
|
.inspect({ provider: "kuna", operation })
|
|
.settings.map(({ setting }) => setting),
|
|
).toContain("kuna.project_timeout_ms");
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{
|
|
setting: "ghidra.decompile_timeout_seconds",
|
|
action: "set",
|
|
value: null,
|
|
},
|
|
{
|
|
setting: "ghidra.decompile_max_payload_mib",
|
|
action: "set",
|
|
value: null,
|
|
},
|
|
],
|
|
}).ok,
|
|
).toBe(true);
|
|
expect(config.ghidraDecompileTimeoutSeconds).toBeUndefined();
|
|
expect(config.ghidraDecompileMaxPayloadMiB).toBeUndefined();
|
|
expect(
|
|
store.inspect({ settings: ["ghidra.decompile_timeout_seconds"] })
|
|
.settings[0],
|
|
).toMatchObject({ value: null, launch_value: 7, source: "runtime" });
|
|
for (const [setting, value] of [
|
|
["asar.max_header_bytes", null],
|
|
["asar.max_listing_bytes", 0],
|
|
["asar.max_listing_bytes", Number.MAX_SAFE_INTEGER + 1],
|
|
["ghidra.value_flow_max_operations", 0],
|
|
["ghidra.value_flow_max_inputs_per_operation", 2147483648],
|
|
["ghidra.decompile_max_payload_mib", 2048],
|
|
["asar.max_header_bytes", 268435457],
|
|
["javascript.max_heap_mb", 127],
|
|
["regex.matching_deadline_ms", 1.5],
|
|
]) {
|
|
expect(
|
|
store.update({ changes: [{ setting, action: "set", value }] }).ok,
|
|
).toBe(false);
|
|
}
|
|
expect(store.inspect().revision).toBe(1);
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{ setting: "ghidra.decompile_timeout_seconds", action: "reset" },
|
|
],
|
|
}).ok,
|
|
).toBe(true);
|
|
expect(config.ghidraDecompileTimeoutSeconds).toBe(7);
|
|
});
|
|
|
|
it("rejects an out-of-range per-call limit and reads an accepted value from the operation snapshot", () => {
|
|
const store = new AnalysisSettings({});
|
|
const rejected = store.update({
|
|
changes: [
|
|
{ setting: "windows.change_time_drift_ms", action: "set", value: 0 },
|
|
],
|
|
});
|
|
expect(rejected.ok).toBe(false);
|
|
if (!rejected.ok)
|
|
expect(projectAnalysisError(rejected.error)).toMatchObject({
|
|
code: "invalid_request",
|
|
});
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{ setting: "bridge.max_request_bytes", action: "set", value: 1 },
|
|
],
|
|
}).ok,
|
|
).toBe(false);
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{
|
|
setting: "windows.change_time_settle_max_polls",
|
|
action: "set",
|
|
value: 1001,
|
|
},
|
|
],
|
|
}).ok,
|
|
).toBe(false);
|
|
const accepted = store.update({
|
|
changes: [
|
|
{ setting: "windows.change_time_drift_ms", action: "set", value: 5000 },
|
|
{ setting: "pwntools.max_input_bytes", action: "set", value: 65536 },
|
|
{ setting: "bridge.max_request_bytes", action: "set", value: 33554432 },
|
|
],
|
|
});
|
|
expect(accepted.ok).toBe(true);
|
|
if (!accepted.ok) return;
|
|
expect(accepted.value).toMatchObject({
|
|
pending_restart: false,
|
|
});
|
|
const parsed = parseConfig({});
|
|
if (!parsed.ok) throw parsed.error;
|
|
const live = runtimeAnalysisConfig(parsed.value, store.read);
|
|
store.run(() => {
|
|
const windows = resolveWindowsChangeTimeSettle({});
|
|
if (!windows.ok) throw windows.error;
|
|
expect(applyWindowsChangeTimeSnapshot(windows.value)).toMatchObject({
|
|
driftMs: 5000,
|
|
driftSource: "runtime",
|
|
pollSource: "default",
|
|
});
|
|
expect(pwntoolsInputBytes({})).toMatchObject({
|
|
configured: true,
|
|
bytes: 65536,
|
|
source: "runtime",
|
|
});
|
|
expect(live.bridgeMaxRequestBytes).toMatchObject({
|
|
maximumBytes: 33554432,
|
|
source: "runtime",
|
|
});
|
|
expect(live.hopperStartupTimeoutSource).toBe("default");
|
|
});
|
|
expect(pwntoolsInputBytes({})).toMatchObject({
|
|
bytes: 32 * 1024 * 1024,
|
|
source: "default",
|
|
});
|
|
});
|
|
|
|
it("reads an accepted override before an invalid launch seed", () => {
|
|
const resolved = runWithAnalysisOperationSnapshot(
|
|
{
|
|
revision: 1,
|
|
overrides: {
|
|
"capture.decoder_old_generation_mib": 64,
|
|
"regex.matching_deadline_ms": 250,
|
|
"regex.worker_heap_request_mib": 128,
|
|
"asar.max_header_bytes": 8192,
|
|
"asar.max_listing_bytes": 4096,
|
|
},
|
|
},
|
|
() => ({
|
|
capture: resolveCaptureDecoderHeap({
|
|
REA_CAPTURE_DECODER_OLD_GENERATION_MIB: "0",
|
|
}),
|
|
deadline: resolveRegexMatchingDeadline({
|
|
REA_REGEX_MATCHING_DEADLINE_MS: "nope",
|
|
}),
|
|
heap: resolveRegexWorkerHeapRequest({
|
|
REA_REGEX_WORKER_HEAP_REQUEST_MIB: "1",
|
|
}),
|
|
asar: runtimeAsarHeaderAdmission({
|
|
REA_ASAR_MAX_HEADER_BYTES: "nope",
|
|
REA_ASAR_MAX_LISTING_BYTES: "0",
|
|
}),
|
|
}),
|
|
);
|
|
expect(resolved.capture).toMatchObject({
|
|
oldGenerationMiB: 64,
|
|
source: "runtime",
|
|
});
|
|
expect(resolved.deadline).toMatchObject({
|
|
deadlineMs: 250,
|
|
source: "runtime",
|
|
});
|
|
expect(resolved.heap).toMatchObject({ heapMiB: 128, source: "runtime" });
|
|
expect(resolved.asar).toMatchObject({
|
|
maximumBytes: 8192,
|
|
source: "runtime",
|
|
listing: { maximumBytes: 4096, source: "runtime" },
|
|
});
|
|
});
|
|
|
|
it("keeps the Hopper startup deadline source through a runtime override", () => {
|
|
const parsed = parseConfig({ REA_HOPPER_STARTUP_TIMEOUT_MS: "45000" });
|
|
if (!parsed.ok) throw parsed.error;
|
|
const store = new AnalysisSettings({});
|
|
const live = runtimeAnalysisConfig(parsed.value, store.read);
|
|
expect(live.hopperStartupTimeoutSource).toBe("setting");
|
|
expect(
|
|
store.update({
|
|
changes: [
|
|
{ setting: "hopper.startup_timeout_ms", action: "set", value: 8000 },
|
|
],
|
|
}).ok,
|
|
).toBe(true);
|
|
store.run(() => {
|
|
expect(live.hopperStartupTimeoutMs).toBe(8000);
|
|
expect(live.hopperStartupTimeoutSource).toBe("runtime");
|
|
});
|
|
});
|
|
|
|
it("retains invalid ASAR seeds across long-lived views and override resets", async () => {
|
|
const environment = {
|
|
REA_ASAR_MAX_HEADER_BYTES: "invalid",
|
|
REA_ASAR_MAX_LISTING_BYTES: "invalid",
|
|
};
|
|
const store = new AnalysisSettings(environment);
|
|
const admission = runtimeAsarHeaderAdmission(environment, store.read);
|
|
expect(() => admission.maximumBytes).toThrow("REA_ASAR_MAX_HEADER_BYTES");
|
|
expect(() => admission.listing?.source).toThrow("REA_ASAR_MAX_LISTING_BYTES");
|
|
store.update({
|
|
changes: [
|
|
{ setting: "asar.max_header_bytes", action: "set", value: 8192 },
|
|
{ setting: "asar.max_listing_bytes", action: "set", value: 4096 },
|
|
],
|
|
});
|
|
let release!: () => void;
|
|
const barrier = new Promise<void>((resolve) => {
|
|
release = resolve;
|
|
});
|
|
const accepted = store.run(async () => {
|
|
await barrier;
|
|
expect(admission).toMatchObject({
|
|
maximumBytes: 8192,
|
|
source: "runtime",
|
|
listing: { maximumBytes: 4096, source: "runtime" },
|
|
});
|
|
});
|
|
store.update({
|
|
changes: [
|
|
{ setting: "asar.max_header_bytes", action: "reset" },
|
|
{ setting: "asar.max_listing_bytes", action: "reset" },
|
|
],
|
|
});
|
|
release();
|
|
await accepted;
|
|
for (const read of [() => admission.maximumBytes, () => admission.source])
|
|
expect(read).toThrow("REA_ASAR_MAX_HEADER_BYTES");
|
|
for (const read of [
|
|
() => admission.listing?.maximumBytes,
|
|
() => admission.listing?.source,
|
|
])
|
|
expect(read).toThrow("REA_ASAR_MAX_LISTING_BYTES");
|
|
});
|
|
|
|
it("retains an invalid capture heap seed through override and reset", () => {
|
|
const environment = { REA_CAPTURE_DECODER_OLD_GENERATION_MIB: "invalid" };
|
|
const store = new AnalysisSettings(environment);
|
|
const heap = runtimeCaptureDecoderHeap(environment, store.read);
|
|
expect(() => heap.oldGenerationMiB).toThrow(
|
|
"REA_CAPTURE_DECODER_OLD_GENERATION_MIB",
|
|
);
|
|
store.update({
|
|
changes: [
|
|
{
|
|
setting: "capture.decoder_old_generation_mib",
|
|
action: "set",
|
|
value: 64,
|
|
},
|
|
],
|
|
});
|
|
expect(heap).toMatchObject({ oldGenerationMiB: 64, source: "runtime" });
|
|
store.update({
|
|
changes: [
|
|
{ setting: "capture.decoder_old_generation_mib", action: "reset" },
|
|
],
|
|
});
|
|
expect(() => heap.oldGenerationMiB).toThrow(
|
|
"REA_CAPTURE_DECODER_OLD_GENERATION_MIB",
|
|
);
|
|
expect(() => heap.source).toThrow("REA_CAPTURE_DECODER_OLD_GENERATION_MIB");
|
|
});
|
|
|
|
it("includes producer.output_bytes when filtering inspect_analysis_settings by sigrok-recording", () => {
|
|
const store = new AnalysisSettings({});
|
|
expect(
|
|
store
|
|
.inspect({ provider: "sigrok-recording" })
|
|
.settings.map(({ setting }) => setting),
|
|
).toContain("producer.output_bytes");
|
|
});
|