Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/binary-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ payload ranges are supported. The supported tree has three levels: type, name,
and language. Other resource payload formats remain opaque.

`max_file_bytes` defaults to 64 MiB (maximum 512 MiB); `max_entries` defaults to
4096 (maximum 65536). CLI options are `--max-file-bytes` and `--max-entries`.
16384, the largest stock Windows resource image measured with headroom
(maximum 65536). CLI options are `--max-file-bytes` and `--max-entries`.
Metadata is bounded to 8 MiB; exceeding any budget fails without truncation.
Large Evidence envelopes may require a caller-configured MCP transport receive
buffer because envelope copies add overhead. Requests honor cancellation during
Expand Down
7 changes: 6 additions & 1 deletion src/domain/native/peResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ export const inspectPeResourcesInputSchema = z.strictObject({
.max(536870912)
.default(67108864)
.describe("Maximum stable artifact bytes to read (default 64 MiB)"),
// Windows resource images carry thousands of entries: Windows 11 25H2
// SystemResources measures imageres.dll.mun at 6476 examined entries,
// shell32.dll.mun at 5903 and wmploc.DLL.mun at 5440. The default admits
// those stock images with headroom; the independent 8 MiB metadata budget
// still bounds allocation.
max_entries: z
.number()
.int()
.min(1)
.max(65536)
.default(4096)
.default(16384)
.describe(
"Maximum resource directory entries to examine; exceeding the budget fails without partial success",
),
Expand Down
3 changes: 2 additions & 1 deletion src/native/pe/PeResources.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const peResourceFixture = (
{ type: 10, name: 7, language: 1041, payload: Buffer.from("World") },
{ type: 14, name: 42, language: 1033, payload: iconGroup() },
],
sectionBytes = 65536,
) => {
const tree: Tree = { children: new Map() };
for (const resource of resources) {
Expand All @@ -58,7 +59,7 @@ export const peResourceFixture = (
if ("children" in child.value) parent = child.value;
}
}
const section = Buffer.alloc(65536);
const section = Buffer.alloc(sectionBytes);
let cursor = 0;
const allocate = (size: number, alignment = 4): number => {
cursor = Math.ceil(cursor / alignment) * alignment;
Expand Down
36 changes: 36 additions & 0 deletions tests/boundary/filesystem/peResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,40 @@ describe("PE resource stable filesystem boundary", () => {
if (result.ok) throw new Error("Expected cancellation");
expect(result.error._tag).toBe("AnalysisCancelledError");
});

it("admits the largest measured stock Windows resource table by default", async () => {
// Windows 11 25H2 SystemResources measures imageres.dll.mun at 6476
// examined entries; the default budget must admit real system images, not
// only small fixtures. Two types with 1620 and 1617 one-language names
// examine 2 + 2 * 3237 entries.
const resources = [
...Array.from({ length: 1620 }, (_unused, index) => ({
type: 10,
name: index + 1,
language: 1033,
payload: Buffer.from([index % 256]),
})),
...Array.from({ length: 1617 }, (_unused, index) => ({
type: 3,
name: index + 1,
language: 1033,
payload: Buffer.from([index % 256]),
})),
];
const root = await createTestTempDirectory("rea-pe-resource-stock-scale-");
const path = join(root, "image.exe");
await writeFile(path, peResourceFixture(false, resources, 262144).bytes);
const result = await createPeResourcesService().inspect({ path });
if (!result.ok)
throw new Error(
`Expected the default budgets to admit the image: ${result.error.message}`,
);
expect(result.value.normalized_result).toMatchObject({
coverage: {
status: "complete",
examined_entries: 6476,
resources: 3237,
},
});
});
});
Loading