Repository navigation
fix(native): raise default PE resource entry budget to 16384 - #1703
Conversation
inspect-pe-resources rejected stock Windows resource images because their tables exceed the 4096-entry default. Windows 11 25H2 SystemResources measures imageres.dll.mun at 6476 examined entries, shell32.dll.mun at 5903 and wmploc.DLL.mun at 5440, so the default budget now admits each of them with headroom while the maximum stays 65536. The independent 8 MiB metadata budget still bounds allocation, and exceeding any budget still fails without partial results. The stable filesystem boundary test now emits a 6476-entry table through a larger fixture section and asserts that the default budgets report complete coverage, covering stock-image scale without a real Windows file.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
TL;DR: The fix works. Tables with 4,097 to 16,384 entries now load by default, and 16,385 is still refused with the same message. I found no regression, but two other size caps now matter more, and they are listed below. I tested head bfac8ac against its base 13e03e9 (#1694) on Linux. I also applied the patch to current main 092de8f (#1716). It applied cleanly with ResultsThe PR's three test files pass on Node 22, 24 and 26. The new test fails on base, as it should. The table is in the first fold. I built PE files with a known number of directory entries (type, name and language entries added up). I ran
Each refusal gives the same message and exit code 1, with no partial results. On each accepted file, the counts match the real counts. The MCP tool Issue 1702: its counting rule is right. Three tables with its exact counts are refused on base and complete on head. A real file, shell32.dll from Wine 11.17 Staging (LGPL-2.1-or-later), does the same. Details are in the Issue 1702 fold. Two other caps now decide what fits. On base, the entry limit stopped these files first. So at defaults only the message changes. This is not a regression.
Not run
Thanks, JasonBuildAI, for the clear issue and the exact counts. Test filesThe PR's three test files (the changed one, the parser test and the service test):
Issue 1702 check
Numbers for the two other caps
Time and memoryThe box was shared (load average about 10 of 24 threads). CLI time includes about 1 s of startup. Each row is 3 to 5 runs, Node 24.
Changing the default costs nothing by itself. It only moves the gate. Exact messagesCommands# build each tree under /tmp (Node 24)
npm ci && npm run build && npm run test:prepare
# patch on main
patch -p1 < pr.patch
# the PR's tests, per Node
node node_modules/vitest/vitest.mjs run tests/boundary/filesystem/peResources.test.ts \
src/native/pe/PeResourceParser.test.ts src/application/binaryDiagnostics/PeResourcesService.test.ts
# CLI, per file and tree
node scripts/rea.mjs inspect-pe-resources FILE --format json [--max-entries 65536]
# MCP: node scripts/rea.mjs --mcp, then tools/list and tools/call inspect_pe_resourcesPE files were written by a stdlib Python script that lays out one Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks, @CassieFox23 — this is a thorough and very helpful independent verification. Confirming the two notes: Both caps are pre-existing, unchanged by this PR, and already documented:
The shapes this PR targets sit well inside both: the largest measured real file ( The evidence also complements well: I measured the real Windows 11 25H2 SystemResources files on Windows, and you reproduced the same counts with same-size synthetic tables plus a real Wine 11.17 Leaving the PR as-is for maintainer review. Thanks again for the Linux and Node 22/24/26 coverage. |
|
Welcome to REA, @JasonBuildAI! Thank you for checking the limit against actual Windows system files and cross-checking with |
Summary
Windows reverse engineers can now inspect stock Windows resource images such as
imageres.dll.munthrough the default CLI and MCP calls. Fixes #1702.Before this change,
rea inspect-pe-resources "C:\Windows\SystemResources\imageres.dll.mun"exited 1 withresource_constraintand returned no inventory, because the defaultmax_entriesbudget (4096) is smaller than the largest stock tables (imageres 6476, shell32 5903, wmploc 5440 examined entries on Windows 11 25H2). After the change, the default budgets returncoverage.status: "complete"with the full inventory.Problem and expected behavior
Smallest trigger: run
rea inspect-pe-resourceswith default budgets on any stock Windows resource image whose table exceeds 4096 examined entries.Observed (base 13e03e9, real files):
Expected: a complete inventory, confirmed independently by
pefile2024.8.26, which matches the parser exactly (0 mismatches across type/name/language, RVA, file offset, size, and code page) when the budget is raised.Change and scope
src/domain/native/peResources.ts: defaultmax_entries4096 -> 16384, with the measured stock-image sizes cited at the default. The 65536 maximum and the independent 8 MiB metadata budget are unchanged, and exceeding any budget still fails closed without partial results.src/native/pe/PeResources.fixture.ts: optionalsectionBytesparameter so tests can emit larger tables through the same fixture.tests/boundary/filesystem/peResources.test.ts: new test emits a 6476-entry table (two types, 1620 + 1617 single-language names) via a 256 KiB section and asserts the default budgets report complete coverage with 6476 examined entries and 3237 resources.docs/binary-diagnostics.md: documents the new default with its basis.Intentionally not included: changes to the parser, budgets, or error taxonomy; no new flags or tools.
Contract and boundary impact
src/domain/native/peResources.ts; the earliest changed stage is native-analysis budget admission. The CLI derives its default from the schema shape, so no CLI-local edit was needed.--max-entries/inspect_pe_resources.max_entriesmoves 4096 -> 16384; minimum 1 and maximum 65536 are unchanged. Callers that pass an explicit budget see identical behavior. Raising a default only admits calls that previously failed with a typed error, so this is not a breaking change.docs/public/product-catalog.json), package, or installation impact: none committed;.cache/mcp-tool-catalog.jsonwas regenerated locally so the MCP schema-validity suite exercises the new default.docs/binary-diagnostics.mdis the only authored doc change.Evidence and regression coverage
tests/boundary/filesystem/peResources.test.ts(new stock-scale default-budget test) and the fixture's optional section size; parser and service suites still pass.max_entries: 4096, and at headbfac8ac6return complete coverage (raw output below).pefilecounts agree exactly..muitables were not above the old default in local scans (0 of 4286 System32 files, 0 of 1918.muifiles, 3 of 140 SystemResources files), so they are not exercised here. The repository's symlink boundary test fails on this machine withEPERMbecause Windows symlink creation needs developer mode; the same failure occurs on the unmodified base and is unrelated.For evidence-bearing changes:
Validation performed
node node_modules/vitest/vitest.mjs run tests/boundary/filesystem/peResources.test.ts src/native/pe/PeResourceParser.test.ts src/application/binaryDiagnostics/PeResourcesService.test.ts— 31 passed, 1 failed; the failure is the pre-existingEPERMsymlink case, reproduced identically on base 13e03e9; the new stock-scale test passes.npm run artifacts:mcp-catalog && node node_modules/vitest/vitest.mjs run tests/boundary/mcp/toolSchemaValidity.test.ts— 7 passed; the regenerated advertised schema carries"default": 16384.npm run check:fast— 2 tasks successful (typecheck, lint).npm run docs:check— 6 tasks successful.pefile2024.8.26 cross-check on the three stock images at--max-entries 65536— 0 mismatches, identical resource counts (3234 / 2944 / 2714).npx oxfmt --checkon the changed files — reports only CRLF-vs-LF checkout differences caused by this Windows worktree; LF copies pass, and the committed blobs are LF.rea inspect-pe-resources <file> --format jsonon base 13e03e9 and headbfac8ac6— raw before/after output quoted above.AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.
Compatibility, safety, and release
resource_constraintfailure; explicit budgets behave identically, and the failure mode for genuinely oversized inputs is unchanged.Review checklist
type(scope): outcome.