mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
fix(fit): retain declared devicetree parser limits (#12474)
This commit is contained in:
1 parent
410b64ab1f
commit
641834a7cd
2 files changed
+53
-3
No files matched your search
@@ -575,13 +575,15 @@ const parseFit = (fdt: Buffer, path: string) => {
|
||||
if (cause instanceof BinaryFormatFailure)
|
||||
throw formatFailure(cause.message);
|
||||
if (isParseLimit(cause, DEVICETREE_FORMAT)) {
|
||||
const { name } = cause.failure.limit;
|
||||
const { limit: parserLimit } = cause.failure;
|
||||
throw new ArtifactReaderFailure(
|
||||
"limit",
|
||||
`FIT devicetree exceeds the fixed ${name} allowance`,
|
||||
`FIT devicetree exceeds the fixed ${parserLimit.name} allowance`,
|
||||
{
|
||||
boundary: name === "decoded_bytes" ? "memory" : "capacity",
|
||||
boundary:
|
||||
parserLimit.name === "decoded_bytes" ? "memory" : "capacity",
|
||||
cause,
|
||||
parserLimit,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import {
|
||||
} from "../../src/artifacts/fit/FitImage.fixture.js";
|
||||
import {
|
||||
cells,
|
||||
devicetreeFixture,
|
||||
dtString,
|
||||
type FixtureNode,
|
||||
} from "../../src/domain/firmware/devicetree.fixture.js";
|
||||
import { parseEvidence } from "../../src/domain/evidence.js";
|
||||
import { artifactInspectionResultSchema } from "../../src/domain/artifactInspection.js";
|
||||
@@ -84,6 +86,52 @@ cliTest.for(cases)(
|
||||
},
|
||||
);
|
||||
|
||||
cliTest("reports the fixed FIT devicetree depth limit", async ({ cli }) => {
|
||||
const directory = await createTestTempDirectory("rea-fit-depth-cli-");
|
||||
const source = join(directory, "boot.itb");
|
||||
const inspect = async (depth: number) => {
|
||||
let metadata: FixtureNode = { name: "leaf" };
|
||||
for (let level = 2; level < depth; level++)
|
||||
metadata = { name: "nested", children: [metadata] };
|
||||
await writeFile(
|
||||
source,
|
||||
devicetreeFixture({
|
||||
name: "",
|
||||
children: [
|
||||
{
|
||||
name: "images",
|
||||
children: [{ name: "kernel", properties: { data: FIT_KERNEL } }],
|
||||
},
|
||||
metadata,
|
||||
],
|
||||
}),
|
||||
);
|
||||
return await cli.run({
|
||||
arguments: ["inspect-artifact", source, "--json"],
|
||||
});
|
||||
};
|
||||
const admitted = await inspect(64);
|
||||
expect(admitted.exitCode, admitted.stdout + admitted.stderr).toBe(0);
|
||||
const inspection = artifactInspectionResultSchema.parse(
|
||||
parseEvidence(admitted.json).normalized_result,
|
||||
);
|
||||
const graph = artifactInventoryResultSchema.parse(
|
||||
inspection.substeps[0]?.evidence.normalized_result,
|
||||
);
|
||||
expect(graph.manifest.root_format).toBe("fit");
|
||||
|
||||
const refused = await inspect(65);
|
||||
expect(refused.json).toMatchObject({
|
||||
code: "truncated",
|
||||
retryable: false,
|
||||
details: {
|
||||
boundary: "capacity",
|
||||
detail: expect.stringContaining("fixed max_depth"),
|
||||
reported_limits: { boundary: "max_depth", maximum: 64 },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
cliTest("rejects a FIT hash mismatch through the CLI", async ({ cli }) => {
|
||||
const directory = await createTestTempDirectory("rea-fit-invalid-cli-");
|
||||
const source = join(directory, "boot.itb");
|
||||
|
||||
Reference in new issue
Block a user