mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 14:05:49 +00:00
fix(uefi): share inspection and extraction scan limits (#12538)
* fix(uefi): share inspection and extraction scan limits * test(uefi): prove extraction honors the FFS file limit
This commit is contained in:
1 parent
0efd54e1c1
commit
9d0502bc51
5 files changed
+143
-45
No files matched your search
@@ -168,33 +168,37 @@ export const uefiFfsFileRecordSchema = z.strictObject({
|
||||
sections: z.array(uefiSectionRecordSchema),
|
||||
});
|
||||
|
||||
const firmwareScanLimits = {
|
||||
max_depth: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxDepth)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxDepth)
|
||||
.describe(
|
||||
"Nesting depth for sections and volumes inside compressed payloads",
|
||||
),
|
||||
max_volumes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxVolumes)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxVolumes)
|
||||
.describe("Maximum firmware volumes mapped before partial coverage"),
|
||||
max_files: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxFiles)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxFiles)
|
||||
.describe("Maximum FFS files mapped before partial coverage"),
|
||||
} as const;
|
||||
|
||||
/** Explicit UEFI firmware inspection and extraction intent, engine-independent. */
|
||||
export const uefiInputSchemas = {
|
||||
inspect_uefi_firmware: z.strictObject({
|
||||
...target,
|
||||
max_depth: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxDepth)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxDepth)
|
||||
.describe(
|
||||
"Nesting depth for sections and volumes inside compressed payloads",
|
||||
),
|
||||
max_volumes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxVolumes)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxVolumes)
|
||||
.describe("Maximum firmware volumes mapped before partial coverage"),
|
||||
max_files: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxFiles)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxFiles)
|
||||
.describe("Maximum FFS files mapped before partial coverage"),
|
||||
...firmwareScanLimits,
|
||||
}),
|
||||
extract_uefi_firmware: z.strictObject({
|
||||
...target,
|
||||
@@ -223,15 +227,7 @@ export const uefiInputSchemas = {
|
||||
}),
|
||||
])
|
||||
.default({ kind: "whole-image" }),
|
||||
max_depth: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(UEFI_FIRMWARE_LIMITS.maxDepth)
|
||||
.default(UEFI_FIRMWARE_LIMITS.defaultMaxDepth)
|
||||
.describe(
|
||||
"Nesting depth for sections and volumes inside compressed payloads",
|
||||
),
|
||||
...firmwareScanLimits,
|
||||
max_output_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
|
||||
@@ -341,17 +341,11 @@ export class UefiAnalysisProvider implements UefiAnalysisPort {
|
||||
}
|
||||
const scan = await scanUefiImage(
|
||||
snapshot.bytes,
|
||||
request.operation === "inspect_uefi_firmware"
|
||||
? {
|
||||
maxDepth: request.input.max_depth,
|
||||
maxVolumes: request.input.max_volumes,
|
||||
maxFiles: request.input.max_files,
|
||||
}
|
||||
: {
|
||||
maxDepth: request.input.max_depth,
|
||||
maxVolumes: UEFI_FIRMWARE_LIMITS.defaultMaxVolumes,
|
||||
maxFiles: UEFI_FIRMWARE_LIMITS.defaultMaxFiles,
|
||||
},
|
||||
{
|
||||
maxDepth: request.input.max_depth,
|
||||
maxVolumes: request.input.max_volumes,
|
||||
maxFiles: request.input.max_files,
|
||||
},
|
||||
({ payload, format, maxOutputBytes }) =>
|
||||
this.#decodeStream(
|
||||
request.operation,
|
||||
|
||||
Reference in new issue
Block a user