fix(analysis-view): read older UEFI extraction Evidence and drop filter-count ceilings

extract_uefi_firmware rows gained a required ffs_file, so extraction Evidence saved before that field failed to parse in retained views. The field is now optional when reading: the extractor still always records it, and an unrecorded owner matches no owner filter. UEFI view filters also capped each list at 64 values without a format, protocol or resource reason; overlapping filters cannot be split into separate requests without miscounting, so the cap is removed. MCP input-element admission still bounds every request.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and Ysopwnable committed 2026-11-23 17:41:53 +08:00
1 parent d3773c910e
commit ca26f2ac84
6 files changed
+99 -6

No files matched your search

@@ -1,6 +1,6 @@
{
"schemas": {
"input compact": "5d5b440228963575",
"input compact": "bd4ced5a290a86f6",
"output compact": "4bda7c3651bfc579"
},
"patterns": {
@@ -1,6 +1,6 @@
{
"schemas": {
"input compact": "129e7906d66c823a",
"input compact": "a704b08506e82abe",
"output compact": "4bda7c3651bfc579"
},
"patterns": {
@@ -0,0 +1,93 @@
import { expect, it } from "vitest";
import { projectAnalysisView } from "./analysisView.js";
import type { AnalysisViewParent } from "./analysisViewParent.js";
import { analysisViewRequestSchema } from "./analysisViewRequest.js";
const digest = (fill: string) => fill.repeat(64);
const file = (index: number, ffs_file?: unknown) => ({
relative_path: `flash/FV@0x0/FFS-x@0x${index.toString(16)}/section-0.payload.bin`,
path: `/out/flash/FV@0x0/FFS-x@0x${index.toString(16)}/section-0.payload.bin`,
size: 16 + index,
sha256: digest(index.toString(16)),
original_file_range: { offset: 0x100 + index * 0x40, length: 16 + index },
source_stream: null,
source_range: { offset: 0x100 + index * 0x40, length: 16 + index },
runtime_address: null,
media_type: "application/vnd.microsoft.portable-executable",
source: "raw-section",
parent_logical_path: `flash/FV@0x0/FFS:x@0x${index.toString(16)}`,
...(ffs_file === undefined ? {} : { ffs_file }),
});
const extraction = (files: readonly unknown[]) => ({
parser: { name: "rea-uefi", version: "1.0.0" },
selection: {
offset: 0,
length: 4096,
source_stream: null,
target_kind: "whole-image",
},
output_directory: "/out",
coverage: "complete",
files,
derivations: [],
extraction_gaps: [],
diagnostics: "1 volumes mapped",
published_bytes: 0,
});
const project = (report: unknown, view: unknown) => {
const parent: AnalysisViewParent = {
predicateType: "rea.analysis",
evidenceId: `ev_${digest("b")}`,
operation: "extract_uefi_firmware",
normalizedResult: report,
limitations: [],
};
const result = projectAnalysisView(
parent,
analysisViewRequestSchema.parse(view),
);
if (!result.ok) throw result.error;
return result.value;
};
it("reads extraction Evidence saved before files recorded their FFS owner", () => {
const report = extraction([file(0), file(1)]);
expect(project(report, { kind: "summary" })).toMatchObject({
summary: { file_count: 2, files_preview: { omitted: 0 } },
});
expect(
project(report, {
kind: "uefi-extraction",
collection: "files",
order: "size-desc",
}),
).toMatchObject({
items: [{ source_index: 1 }, { source_index: 0 }],
coverage: { total: 2 },
});
// An unrecorded owner is unknown, so it matches no owner filter.
expect(
project(report, {
kind: "uefi-extraction",
collection: "files",
ffs_type_names: ["driver"],
}),
).toMatchObject({ items: [], coverage: { total: 0 } });
});
it("accepts owner filters longer than 64 values", () => {
const owner = {
guid: "9e21fd93-9c72-4c15-8c4b-e77f9db8d4d2",
ui_string: "DemoDxe",
type_name: "driver",
logical_path: "flash/FV@0x0/FFS:9e21fd93-9c72-4c15-8c4b-e77f9db8d4d2@0x48",
};
const names = Array.from({ length: 100 }, (_, i) => `Other${String(i)}`);
expect(
project(extraction([file(0, owner), file(1, null)]), {
kind: "uefi-extraction",
collection: "files",
ffs_ui_names: [...names, "DemoDxe"],
}),
).toMatchObject({ items: [{ source_index: 0 }], coverage: { total: 1 } });
});
@@ -40,7 +40,6 @@ const exactNames = <Schema extends z.ZodType>(schema: Schema, what: string) =>
z
.array(schema)
.min(1)
.max(64)
.optional()
.describe(`Exact ${what}; any listed value matches`);
@@ -204,7 +203,8 @@ const fileFilter = (view: FilesView) =>
view.ffs_type_names === undefined
? undefined
: (file: ExtractedFile): boolean => {
const owner = file.ffs_file;
// Older Evidence omits the owner; an unrecorded owner matches no owner filter.
const owner = file.ffs_file ?? null;
return (
(view.media_types === undefined ||
(file.media_type !== null &&
@@ -48,7 +48,6 @@ const exactNames = <Schema extends z.ZodType>(schema: Schema, what: string) =>
z
.array(schema)
.min(1)
.max(64)
.optional()
.describe(`Exact ${what}; any listed value matches`);
+2 -1
View File
@@ -480,8 +480,9 @@ export const uefiResultSchemas = {
parent_logical_path: z.string().nullable(),
ffs_file: uefiExtractedFileOwnerSchema
.nullable()
.optional()
.describe(
"FFS file whose body or section produced these bytes; null for a stream outside any mapped file",
"FFS file whose body or section produced these bytes; null for a stream outside any mapped file. The extractor always records it; Evidence saved before this field existed omits it.",
),
}),
),