mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 16:18:26 +00:00
* fix(native)!: report details.limit for native reader per-call budgets Devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals of caller-selected budgets named their control only in remediation prose. Each now sets details.limit from a domain-owned budget object that also builds the schema (src/domain/parameterBudget.ts), so the reported range is the one the next call accepts. inspect_devicetree's fixed 32 MiB decoded representation allowance becomes the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its refusal reports boundary max_decoded_bytes instead of decoded_bytes. The pwntools allocation failure declares measuredExhaustion, the firmware inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB combined-result ceiling is a registered representation bound. Part of #14234 and #14235. BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports reported_limits.boundary "max_decoded_bytes" with details.limit, instead of "decoded_bytes". * fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits. * fix(cli): describe inspect-devicetree --max-decoded-bytes * refactor(native): let the generated adjustable-budget recovery name the native reader controls With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value.
133 lines
5.0 KiB
TypeScript
133 lines
5.0 KiB
TypeScript
import { fileIdentity } from "../../fixtures/evidenceSubject.js";
|
|
import { symlink, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
|
|
import { createKernelBuildConfigService } from "../../../src/composition/binaryDiagnostics/kernelBuildConfig.js";
|
|
import {
|
|
bzImageGzipFixture,
|
|
kernelBuildConfigFixture,
|
|
plainIkcfgStringFixture,
|
|
} from "../../../src/native/elf/KernelBuildConfig.fixture.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { expectFileSelectionErrors } from "../../support/expectFileSelectionErrors.js";
|
|
|
|
describe("kernel build config stable filesystem boundary", () => {
|
|
it("reports non-file selections as caller input errors", async () => {
|
|
const root = await createTestTempDirectory("rea-kernel-config-files-");
|
|
const path = join(root, "vmlinux");
|
|
const alias = join(root, "alias");
|
|
await writeFile(path, kernelBuildConfigFixture());
|
|
await symlink(path, alias);
|
|
const service = createKernelBuildConfigService();
|
|
try {
|
|
await expectFileSelectionErrors(service, "inspect_kernel_build_config", {
|
|
root,
|
|
alias,
|
|
path,
|
|
});
|
|
} finally {
|
|
await service.close();
|
|
}
|
|
});
|
|
|
|
it("returns typed resource and cancellation failures", async () => {
|
|
const root = await createTestTempDirectory("rea-kernel-config-budget-");
|
|
const path = join(root, "vmlinux");
|
|
await writeFile(path, kernelBuildConfigFixture());
|
|
const service = createKernelBuildConfigService();
|
|
try {
|
|
const tooSmall = await service.inspect({ path, max_file_bytes: 64 });
|
|
if (tooSmall.ok) throw new Error("Expected resource budget failure");
|
|
expect(tooSmall.error).toMatchObject({
|
|
_tag: "AnalysisResourceConstraintError",
|
|
limit: {
|
|
control_kind: "parameter",
|
|
parameter: "max_file_bytes",
|
|
effective_value: 64,
|
|
default_value: 67108864,
|
|
},
|
|
});
|
|
const bootImage = join(root, "bzImage");
|
|
await writeFile(bootImage, bzImageGzipFixture());
|
|
for (const [target, boundary, maximum] of [
|
|
[path, "max_entries", 1],
|
|
[path, "max_config_bytes", 64],
|
|
[bootImage, "max_payload_bytes", 64],
|
|
] as const) {
|
|
const result = await service.inspect({
|
|
path: target,
|
|
[boundary]: maximum,
|
|
});
|
|
if (result.ok) throw new Error(`Expected ${boundary} failure`);
|
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
|
code: "resource_constraint",
|
|
retryable: false,
|
|
details: {
|
|
resource: "capacity",
|
|
reported_limits: { boundary, maximum, [boundary]: maximum },
|
|
limit: {
|
|
control_kind: "parameter",
|
|
parameter: boundary,
|
|
effective_value: maximum,
|
|
applies_at: "next_call",
|
|
},
|
|
},
|
|
remediation: {
|
|
action: expect.stringContaining(
|
|
`Pass a larger ${boundary} on the next inspect_kernel_build_config call`,
|
|
),
|
|
},
|
|
});
|
|
}
|
|
const cancelled = await service.inspect(
|
|
{ path },
|
|
{ signal: AbortSignal.abort() },
|
|
);
|
|
if (cancelled.ok) throw new Error("Expected cancellation");
|
|
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
|
|
} finally {
|
|
await service.close();
|
|
}
|
|
});
|
|
|
|
it("retains partial framing evidence under the config inflate limit", async () => {
|
|
const root = await createTestTempDirectory("rea-kernel-config-framing-");
|
|
const path = join(root, "vmlinux");
|
|
await writeFile(path, kernelBuildConfigFixture().subarray(0, -1));
|
|
const service = createKernelBuildConfigService();
|
|
try {
|
|
for (const max_config_bytes of [4096, 64]) {
|
|
const result = await service.inspect({ path, max_config_bytes });
|
|
if (!result.ok) throw result.error;
|
|
expect(result.value.normalized_result).toMatchObject({
|
|
banner: { status: "present", version: "6.6.0" },
|
|
config: { status: "incomplete", reason: "config_gzip_truncated" },
|
|
coverage: { status: "partial" },
|
|
});
|
|
}
|
|
} finally {
|
|
await service.close();
|
|
}
|
|
});
|
|
|
|
it("reports an ordinary IKCFG_ST string as no config with file Evidence", async () => {
|
|
const root = await createTestTempDirectory("rea-kernel-config-plain-");
|
|
const path = join(root, "vmlinux");
|
|
await writeFile(path, plainIkcfgStringFixture());
|
|
const service = createKernelBuildConfigService();
|
|
try {
|
|
const result = await service.inspect({ path });
|
|
if (!result.ok) throw result.error;
|
|
expect(fileIdentity(result.value.subject).format).toBe("elf");
|
|
expect(result.value.normalized_result).toMatchObject({
|
|
banner: { status: "present", version: "6.6.0" },
|
|
config: { status: "absent", entries: [] },
|
|
coverage: { status: "complete" },
|
|
});
|
|
} finally {
|
|
await service.close();
|
|
}
|
|
});
|
|
});
|