From 680c83f88cf78cd4490bbefcef265c5b92ddbb85 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:40:58 +0800 Subject: [PATCH] feat(errors): carry the value of Go, Rust, IL2CPP, sigrok, Electron fuse, CDP, projection and assetutil allowances (#11645) Each of these fixed allowances now passes limit and unit, traced to the constant or parse refusal that produced it. The Electron fuse, CDP runtime retention and assetutil names no longer embed the value. --- .../apple/AppleAssetCatalogAnalysis.test.ts | 3 + .../apple/AppleAssetCatalogAnalysis.ts | 8 +-- .../execution/CdpRuntimeRetention.test.ts | 4 ++ src/browser/execution/CdpRuntimeRetention.ts | 6 +- .../WebNetworkProjectionAccumulator.ts | 1 + src/electron/ElectronFuseFailures.ts | 35 ++++++++--- src/electron/ElectronFuseProvider.test.ts | 20 ++++++- src/go/GoBinaryProvider.ts | 1 + src/il2cpp/Il2cppGhidraSeeds.ts | 60 ++++++++++++------- src/il2cpp/Il2cppMetadataProvider.ts | 13 +++- src/rust/RustBinaryProvider.ts | 4 ++ src/signals/SigrokRecordingProvider.ts | 1 + .../boundary/il2cpp/il2cppGhidraSeeds.test.ts | 8 +++ .../il2cpp/il2cppMetadataProvider.test.ts | 1 + 14 files changed, 123 insertions(+), 42 deletions(-) diff --git a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts index c84a076d8b..99c188f678 100644 --- a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts +++ b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts @@ -553,6 +553,9 @@ it.each([ diagnostics: { catalog_path: "Assets.car" }, capturedOutput: { stderr: "specific catalog diagnostic" }, ...(code === "ETIMEDOUT" ? { timeoutMs: 60000 } : {}), + ...(code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" + ? { fixedAllowance: { limit: 64 * 1024 * 1024, unit: "bytes" } } + : {}), }); }, ); diff --git a/src/artifacts/apple/AppleAssetCatalogAnalysis.ts b/src/artifacts/apple/AppleAssetCatalogAnalysis.ts index 4d10322dd6..4766d40222 100644 --- a/src/artifacts/apple/AppleAssetCatalogAnalysis.ts +++ b/src/artifacts/apple/AppleAssetCatalogAnalysis.ts @@ -477,10 +477,10 @@ const assetUtilFailure = (cause: unknown, entry: ArtifactEntry): unknown => { { maximum_output_bytes: MAX_CATALOG_BYTES }, { ...options, - ...fixedAllowanceOptions( - "the fixed 64 MiB assetutil capture allowance", - "capture", - ), + ...fixedAllowanceOptions("The assetutil capture allowance", "capture", { + limit: MAX_CATALOG_BYTES, + unit: "bytes", + }), }, ); if (output !== undefined) { diff --git a/src/browser/execution/CdpRuntimeRetention.test.ts b/src/browser/execution/CdpRuntimeRetention.test.ts index 3c22d65b95..1be7cec033 100644 --- a/src/browser/execution/CdpRuntimeRetention.test.ts +++ b/src/browser/execution/CdpRuntimeRetention.test.ts @@ -15,6 +15,10 @@ describe("RuntimeRetention", () => { retained_bytes: WEB_RUNTIME_LIMITS.retainedEventBytes + 5, limit_bytes: WEB_RUNTIME_LIMITS.retainedEventBytes, }), + fixedAllowance: expect.objectContaining({ + limit: WEB_RUNTIME_LIMITS.retainedEventBytes, + unit: "bytes", + }), }), ); }); diff --git a/src/browser/execution/CdpRuntimeRetention.ts b/src/browser/execution/CdpRuntimeRetention.ts index 583505807f..04e18739a2 100644 --- a/src/browser/execution/CdpRuntimeRetention.ts +++ b/src/browser/execution/CdpRuntimeRetention.ts @@ -16,18 +16,18 @@ const retentionExceeded = ( retainedBytes: number, ): AnalysisResourceConstraintError => { const limit = retentionLimit(kind); - const allowance = `Complete browser runtime ${kind} retention (${String(limit)} bytes)`; + const allowance = `Complete browser runtime ${kind} retention`; return new AnalysisResourceConstraintError( operation, "capacity", - `${allowance} exceeded; no partial runtime result is returned.`, + `${allowance} (${String(limit)} bytes) exceeded; no partial runtime result is returned.`, { boundary: "browser-runtime-retention", kind, retained_bytes: retainedBytes, limit_bytes: limit, }, - fixedAllowanceOptions(allowance, "live"), + fixedAllowanceOptions(allowance, "live", { limit, unit: "bytes" }), ); }; diff --git a/src/domain/analysisView/WebNetworkProjectionAccumulator.ts b/src/domain/analysisView/WebNetworkProjectionAccumulator.ts index 51f1905437..dc91cee6c6 100644 --- a/src/domain/analysisView/WebNetworkProjectionAccumulator.ts +++ b/src/domain/analysisView/WebNetworkProjectionAccumulator.ts @@ -97,6 +97,7 @@ export abstract class WebNetworkProjectionAccumulator { fixedAllowanceOptions( "The analysis-view projection allowance", "parser", + { limit: this.maximumBytes, unit: "bytes" }, ), ), ); diff --git a/src/electron/ElectronFuseFailures.ts b/src/electron/ElectronFuseFailures.ts index e630fea06b..7587e2c83b 100644 --- a/src/electron/ElectronFuseFailures.ts +++ b/src/electron/ElectronFuseFailures.ts @@ -28,7 +28,10 @@ import { NonRegularFileReadError, } from "../filesystem/RegularFile.js"; import { ElectronFusePathFailure } from "./ElectronFusePath.js"; -import { ElectronFuseResourceFailure } from "./ElectronFuseReader.js"; +import { + ELECTRON_FUSE_LIMITS, + ElectronFuseResourceFailure, +} from "./ElectronFuseReader.js"; import { errorMessage } from "../kernel/errorMessage.js"; const OPERATION = "inspect_electron_fuses"; @@ -84,16 +87,30 @@ export const electronFuseFailure = ( cause.boundary === "file-size" ? "file-size" : "capacity", cause.message, cause.boundary === "file-size" - ? { maximum_input_bytes: 1024 * 1024 * 1024 } - : { maximum_sentinels_per_slice: 32 }, + ? { maximum_input_bytes: ELECTRON_FUSE_LIMITS.maximumFileBytes } + : { + maximum_sentinels_per_slice: + ELECTRON_FUSE_LIMITS.maximumSentinelsPerSlice, + }, { cause, - ...fixedAllowanceOptions( - cause.boundary === "file-size" - ? "the 1 GiB Electron fuse input allowance" - : "The Electron fuse sentinel inventory", - cause.boundary === "file-size" ? "input" : "count", - ), + ...(cause.boundary === "file-size" + ? fixedAllowanceOptions( + "the Electron fuse input allowance", + "input", + { + limit: ELECTRON_FUSE_LIMITS.maximumFileBytes, + unit: "bytes", + }, + ) + : fixedAllowanceOptions( + "The Electron fuse sentinel inventory", + "count", + { + limit: ELECTRON_FUSE_LIMITS.maximumSentinelsPerSlice, + unit: "sentinels per slice", + }, + )), }, ); const formatFailure = parseFailureAnalysisError(operation, path, cause); diff --git a/src/electron/ElectronFuseProvider.test.ts b/src/electron/ElectronFuseProvider.test.ts index acc2e625b3..ddeb4fee80 100644 --- a/src/electron/ElectronFuseProvider.test.ts +++ b/src/electron/ElectronFuseProvider.test.ts @@ -841,7 +841,15 @@ it("enforces the 32 sentinel boundary with typed and public limit details", asyn expect(projectAnalysisError(result.error)).toMatchObject({ code: "resource_constraint", retryable: false, - details: { reported_limits: { maximum_sentinels_per_slice: 32 } }, + details: { + reported_limits: { maximum_sentinels_per_slice: 32 }, + refusal: { + kind: "fixed_ceiling", + allowance_kind: "count", + limit: 32, + unit: "sentinels per slice", + }, + }, remediation: { action: expect.stringContaining("sentinel inventory"), }, @@ -866,7 +874,15 @@ it("rejects a sparse artifact over 1 GiB before scanning", async () => { expect(projectAnalysisError(result.error)).toMatchObject({ code: "resource_constraint", retryable: false, - details: { reported_limits: { maximum_input_bytes: 1024 * 1024 * 1024 } }, + details: { + reported_limits: { maximum_input_bytes: 1024 * 1024 * 1024 }, + refusal: { + kind: "fixed_ceiling", + allowance_kind: "input", + limit: 1024 * 1024 * 1024, + unit: "bytes", + }, + }, remediation: { action: expect.stringContaining("does not admit this input"), }, diff --git a/src/go/GoBinaryProvider.ts b/src/go/GoBinaryProvider.ts index 1ae9b33d18..eea7515ed4 100644 --- a/src/go/GoBinaryProvider.ts +++ b/src/go/GoBinaryProvider.ts @@ -107,6 +107,7 @@ const failureForPrimary = ( ? fixedAllowanceOptions( "The Go structural decoding allowance", "parser", + { limit: cause.maximum_bytes, unit: "bytes" }, ) : { retryable: false, diff --git a/src/il2cpp/Il2cppGhidraSeeds.ts b/src/il2cpp/Il2cppGhidraSeeds.ts index 9f2a24b1b0..49924e21e1 100644 --- a/src/il2cpp/Il2cppGhidraSeeds.ts +++ b/src/il2cpp/Il2cppGhidraSeeds.ts @@ -2,14 +2,36 @@ import { AnalysisInputError, AnalysisResourceConstraintError, } from "../domain/analysisErrorCore.js"; -import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js"; +import { + fixedAllowanceOptions, + type FixedAllowance, +} from "../domain/fixedAllowanceRemediation.js"; const OPERATION = "inspect_il2cpp_metadata"; -const capacity = ( - message: string, - allowance: string, - kind: "bytes" | "count", -) => - new AnalysisResourceConstraintError( +/** Each Ghidra seed admission ceiling, with the value that refuses a seed. */ +const SEED_ALLOWANCES = { + name: { + name: "The IL2CPP Ghidra seed-name allowance", + kind: "count", + limit: MAX_GHIDRA_SEED_NAME_LENGTH, + unit: "characters", + }, + file: { + name: "The IL2CPP Ghidra seed-file allowance", + kind: "bytes", + limit: MAX_GHIDRA_SEED_BYTES, + unit: "bytes", + }, + entry: { + name: "The IL2CPP Ghidra seed-entry allowance", + kind: "count", + limit: MAX_GHIDRA_SEED_ENTRIES, + unit: "entries", + }, +} as const satisfies Record; + +const capacity = (message: string, allowance: keyof typeof SEED_ALLOWANCES) => { + const { name, kind, limit, unit } = SEED_ALLOWANCES[allowance]; + return new AnalysisResourceConstraintError( OPERATION, "capacity", message, @@ -18,8 +40,9 @@ const capacity = ( maximum_seed_entries: MAX_GHIDRA_SEED_ENTRIES, maximum_seed_name_characters: MAX_GHIDRA_SEED_NAME_LENGTH, }, - fixedAllowanceOptions(allowance, kind), + fixedAllowanceOptions(name, kind, { limit, unit }), ); +}; import type { Il2cppMetadata } from "../domain/il2cpp/il2cppMetadata.js"; import { MAX_GHIDRA_SEED_BYTES, @@ -90,16 +113,14 @@ const typeName = (report: Il2cppMetadata, index: number): string => { if (length > MAX_GHIDRA_SEED_NAME_LENGTH) throw capacity( "Qualified seed type name exceeds the Ghidra name limit.", - "The IL2CPP Ghidra seed-name allowance", - "count", + "name", ); parts.unshift(type.name); namespace = type.namespace; if (length + namespace.length > MAX_GHIDRA_SEED_NAME_LENGTH) throw capacity( "Qualified seed type name exceeds the Ghidra name limit.", - "The IL2CPP Ghidra seed-name allowance", - "count", + "name", ); at = type.declaring_type; } @@ -136,11 +157,7 @@ export const il2cppGhidraSeeds = ( const typeNames = new Map(); const reserve = (length: number) => { if (length > MAX_GHIDRA_SEED_BYTES - bytes) - throw capacity( - "Seed file exceeds Ghidra byte admission.", - "The IL2CPP Ghidra seed-file allowance", - "bytes", - ); + throw capacity("Seed file exceeds Ghidra byte admission.", "file"); bytes += length; }; const emit = (text: string) => { @@ -161,8 +178,7 @@ export const il2cppGhidraSeeds = ( if (raw.length > MAX_GHIDRA_SEED_NAME_LENGTH) throw capacity( "Qualified method seed name exceeds Ghidra character admission.", - "The IL2CPP Ghidra seed-name allowance", - "count", + "name", ); const name = raw.replace(/\s/gu, "_"); if (name.includes("\0")) @@ -190,8 +206,7 @@ export const il2cppGhidraSeeds = ( if (seeded.size > MAX_GHIDRA_SEED_ENTRIES) throw capacity( "Seed function count exceeds Ghidra entry admission.", - "The IL2CPP Ghidra seed-entry allowance", - "count", + "entry", ); emit(`0x${address.toString(16)}\tfunction\t${name}\n`); }; @@ -211,8 +226,7 @@ export const il2cppGhidraSeeds = ( if (ownerName.length + 2 + method.name.length > MAX_GHIDRA_SEED_NAME_LENGTH) throw capacity( "Qualified method seed name exceeds Ghidra character admission.", - "The IL2CPP Ghidra seed-name allowance", - "count", + "name", ); seed(rva, `${ownerName}$$${method.name}`, ["methods", index, "name"]); }); diff --git a/src/il2cpp/Il2cppMetadataProvider.ts b/src/il2cpp/Il2cppMetadataProvider.ts index a95186f28b..484148a724 100644 --- a/src/il2cpp/Il2cppMetadataProvider.ts +++ b/src/il2cpp/Il2cppMetadataProvider.ts @@ -100,6 +100,10 @@ const failureForPrimary = ( ...fixedAllowanceOptions( "The IL2CPP native-link allowance", cause.reason === "native-type-text-capacity" ? "parser" : "count", + { + limit: cause.failure.limit.maximum, + ...(cause.unit === undefined ? {} : { unit: cause.unit }), + }, ), }, ); @@ -143,7 +147,14 @@ const failureForPrimary = ( { maximum_input_bytes: maximum }, { cause, - ...fixedAllowanceOptions("the fixed IL2CPP input allowance", "input"), + ...fixedAllowanceOptions( + "the fixed IL2CPP input allowance", + "input", + { + limit: maximum, + unit: "bytes", + }, + ), }, ); if (cause.reason === "path") diff --git a/src/rust/RustBinaryProvider.ts b/src/rust/RustBinaryProvider.ts index 79f8affb5e..900dbd55bb 100644 --- a/src/rust/RustBinaryProvider.ts +++ b/src/rust/RustBinaryProvider.ts @@ -375,6 +375,10 @@ const failureForPrimary = ( : fixedAllowanceOptions( "This Rust dependency parser allowance", "parser", + { + limit: cause.constraint.reported_limits.maximum_bytes, + unit: "bytes", + }, )), }, ); diff --git a/src/signals/SigrokRecordingProvider.ts b/src/signals/SigrokRecordingProvider.ts index 0d5d946da2..0f1794656c 100644 --- a/src/signals/SigrokRecordingProvider.ts +++ b/src/signals/SigrokRecordingProvider.ts @@ -524,6 +524,7 @@ export class SigrokRecordingProvider implements SignalRecordingPort { ...fixedAllowanceOptions( "The sigrok decoder-discovery line allowance", "capture", + { limit: cause.failure.limit.maximum, unit: "lines" }, ), }) : undefined, diff --git a/tests/boundary/il2cpp/il2cppGhidraSeeds.test.ts b/tests/boundary/il2cpp/il2cppGhidraSeeds.test.ts index b86fe5c753..4c19b91bf8 100644 --- a/tests/boundary/il2cpp/il2cppGhidraSeeds.test.ts +++ b/tests/boundary/il2cpp/il2cppGhidraSeeds.test.ts @@ -235,6 +235,10 @@ it("bounds folded-name retention against the actual Ghidra file admission", () = if (!(caught instanceof AnalysisResourceConstraintError)) throw new Error("Expected seed-file allowance refusal"); expect(caught.message).toMatch(/byte admission/); + expect(caught.fixedAllowance).toMatchObject({ + limit: 32 * 1024 * 1024, + unit: "bytes", + }); expect(analysisErrorRemediationAction(caught)).toContain( "The IL2CPP Ghidra seed-file allowance", ); @@ -280,6 +284,10 @@ it("refuses names the real Ghidra seed parser cannot admit", () => { if (!(caught instanceof AnalysisResourceConstraintError)) throw new Error("Expected seed-name allowance refusal"); expect(caught.message).toMatch(/character admission/); + expect(caught.fixedAllowance).toMatchObject({ + limit: 2000, + unit: "characters", + }); expect(analysisErrorRemediationAction(caught)).toContain( "The IL2CPP Ghidra seed-name allowance", ); diff --git a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts index a5b1d14092..6ea96aa101 100644 --- a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts +++ b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts @@ -1069,6 +1069,7 @@ it("reports the exceeded native-link maximum in the public refusal", async () => boundary: "native-index-capacity", maximum_entries: 64, }, + fixedAllowance: { limit: 64, unit: "entries" }, }); } finally { await provider.close();