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.
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 09:40:58 +08:00
1 parent 836ac2fea6
commit 680c83f88c
14 files changed
+123 -42

No files matched your search

@@ -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" } }
: {}),
});
},
);
@@ -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) {
@@ -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",
}),
}),
);
});
+3 -3
View File
@@ -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" }),
);
};
@@ -97,6 +97,7 @@ export abstract class WebNetworkProjectionAccumulator {
fixedAllowanceOptions(
"The analysis-view projection allowance",
"parser",
{ limit: this.maximumBytes, unit: "bytes" },
),
),
);
+26 -9
View File
@@ -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);
+18 -2
View File
@@ -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"),
},
+1
View File
@@ -107,6 +107,7 @@ const failureForPrimary = (
? fixedAllowanceOptions(
"The Go structural decoding allowance",
"parser",
{ limit: cause.maximum_bytes, unit: "bytes" },
)
: {
retryable: false,
+37 -23
View File
@@ -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<string, FixedAllowance>;
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<number, string>();
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"]);
});
+12 -1
View File
@@ -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")
+4
View File
@@ -375,6 +375,10 @@ const failureForPrimary = (
: fixedAllowanceOptions(
"This Rust dependency parser allowance",
"parser",
{
limit: cause.constraint.reported_limits.maximum_bytes,
unit: "bytes",
},
)),
},
);
+1
View File
@@ -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,
@@ -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",
);
@@ -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();