Repository navigation
feat(pe): inspect import and delay-load tables - #6509
Conversation
Add inspect_pe_imports / inspect-pe-imports to read PE32/PE32+ import and delay-load directories without executing the image. The report keeps DLL names, named and ordinal functions, ILT/IAT RVAs, and a pefile import hash of the standard import table. A missing directory is observed absence, not proof the image never imported APIs.
Allow peImportImage() without an argument so CLI and filesystem tests can use the KERNEL32 sample without repeating an empty options object.
inspect_pe_imports already rejects relative MCP paths in its own boundary test. Leave the shared absolute-path matrix to tools whose handler issue projection matches that suite's expected shape.
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. |
[Medium impact] The PR appears safe to merge; the outstanding ordinal-lookup bug is fixed. SummaryAdds
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[CLI or MCP] --> B[Validate explicit file selection]
B --> C[Read bounded stable file]
C --> D[Parse standard and delay-load imports]
D --> E[Compute or withhold import hash]
E --> F[Return Evidence and limitations]
Reviews (3) · Last reviewed commit: "fix(pe): read only own ordinal tables fo..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 130b5babaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
baron
left a comment
There was a problem hiding this comment.
AI-assisted independent review confirms substantive producer defects despite green CI:
PeImportParser.ts:454computes imphash from retained rows even when a standard-table name is unreadable. The two-import probe retained only GetProcAddress, reported partial coverage, yet emitted a successful MD5 with no unavailable reason. That prefix hash is not an established image import hash.- Missing FirstThunk with a populated ILT becomes complete/empty imports and MD5(empty), rather than malformed/partial evidence.
- Directory Evidence claims one contiguous physical span even when consecutive RVA descriptors map into disjoint file spans. The probe consumed [5100,5120) and [8192,8212), but advertised [5100,5140).
Fix completeness and consumed-span ownership in the parser, and carry exhausted-limit tags instead of parsing diagnostic prose in provider remediation. The review also confirms the existing ordinal compatibility issue. Mapping complexity is multiplicative by source inspection, not an independently measured freeze.
These findings were checked against exact-source isolated parser probes, not a real PE corpus/Windows or full CLI/MCP run. No OOM, latency or peak-memory claim is made. Existing threads cover the findings, so no duplicate inline threads added. Main CI passes; incomplete human readiness and unresolved substantive issues still block approval.
mappedFileOffset scans every mapping twice per span, so a parser that translates one span per table entry costs sections x entries. Add fileMappingLookup, which builds an O(n log n) interval index once and answers each span in O(log n) with the same accept, reject and translation results. A differential test checks it against mappedFileOffset over randomized overlapping mappings and zero fills. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ra7LM2NyQ7DumdssxbUq5g
- Withhold imphash with an explicit reason whenever the standard import table is partial (unreadable names or thunks, missing tables), or when pefile 2024.8.26 would hash a different row sequence: invalid or truncated names, ordinal 0, descriptors without functions, tables its bounds or repeat/spread heuristics discard, and its 8192-thunk import symbol cap. Delay-load issues do not withhold it. - Hash ordinal imports with pefile's complete ordlookup tables and its ord<decimal> fallback instead of declining unmapped ordinals. - Report a nonterminal descriptor whose FirstThunk is zero, and a delay-load descriptor whose IAT or INT RVA is zero, as malformed_entry partial coverage instead of a complete empty inventory. - Directory evidence lists the file spans actually consumed for the descriptor array and terminator; discontiguous mappings produce separate spans and separate Evidence ranges. - Carry exhausted limits as PeImportLimitFailure.limit and derive recovery from it; the fixed 16 MiB retained-text ceiling reports a fixed allowance instead of max_file_bytes advice. - Translate RVAs through the indexed mapping lookup and yield with a cancellation check every 1024 table entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ra7LM2NyQ7DumdssxbUq5g
|
@baron thanks for the review. e13fee6 fixes these in the parser: imphash is withheld with a reason whenever standard imports are partial (test hashes come from pefile 2024.8.26 on the same bytes), a zero FirstThunk with a populated ILT is malformed and partial, and directory evidence reports each consumed file span instead of one contiguous range. Limit failures carry structured tags, and ordinals fall back to pefile's ord names. 4682a8e indexes section lookups; 65,535 sections with 8,192 imports went from 178.6 s to 0.21 s. Not run against a real PE corpus on Windows. |
DLL names such as constructor and __proto__ pass pefile's name rule but resolved inherited object members, throwing before the ord<n> fallback. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ra7LM2NyQ7DumdssxbUq5g
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b65cbcfe2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7406eca81
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adc2a91a37
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Final-head CI attribution for 0f225fb: CI run 40057282775 has 25 successful, 11 skipped, 3 failed and 2 cancelled jobs. The functional failures are 11 plist cases in nativePlistTextSource.test.ts / plistSourceFormat.test.ts; Portable tests repeats those 11 and CI required aggregates test/test-shard failures. The two cancelled shards report cancellation without another functional failure; their remaining coverage was not executed. Reproduced both files on exact main cd10ee1 and the actual CI merge c3d08d0 (parents main + this PR head). Both runs have 30 cases: 19 pass / 11 fail. All 30 statuses and all failure messages match after normalizing checkout roots and temporary directory suffixes only. The failing files, fixture runner and selected XML/plist producing sources are byte-identical. The existing source/optional-conversion expectations disagree on main as well; this PR does not establish a diagnosis of that separate behavior. The PR's 277 selected PE/mapping/image/service/filesystem/CLI/actual SDK/lifecycle checks and full static/docs/discovery gates pass. Final-head CI also passes build, source/static/documentation and the completed provider lanes. Title and existing human-readiness checks pass. Two superseded metadata runs were cancelled while unassigned (runner 0, zero steps); their newer same-head runs pass. The maintainer's authorization permits merging when failures are proven unrelated to this PR. This record supports the baseline-failure bypass for the exact reviewed head; cancelled coverage and provider/platform limits remain as reported in the verification document. |
|
Latest integration verification before merge: the PR head 0f225fb combined with main ae24b78 produces tree 4e65ee22cf14f3d7a0b4a5de94f329aa83e11f59. Installed its exact lock with the pinned toolchain (Husky disabled to preserve shared Git configuration), built the runtime, and passed 143 selected service/filesystem/public CLI/actual SDK/shared-lifecycle checks. These overlap the earlier 277-check selection. Later main commits through f508a1a change release tooling, unreachable native command routing and Windows native-load diagnostics; the PE implementation and its portable static-reader path are unchanged. The predicted clean merge tree there is f7610c5e2a992708fa62ddd5875848635e4686ee. All actionable review threads are resolved and the existing human-readiness declaration passes. The baseline attribution above covers the 11 plist failures and the two fail-fast cancellations. Proceeding with the maintainer-authorized bypass for the exact reviewed PR head. |
Related to #4539.
Adds
inspect_pe_imports/inspect-pe-importsfor one selected local PE: standard/delay DLLs, names or ordinals, hints, IAT RVAs, consumed ranges and a pefile-compatible imphash when the complete standard table supports it. CLI/MCP share bounded stable-file reading, validation and Evidence; the target is never executed.The integration consumes parsed PE facts and canonical indexed mappings. Descriptor/thunk RVA overflow and descriptor mapping gaps preserve preceding rows and explicit partial coverage. An unexamined directory retains its declaration with zero consumed spans. Coverage is reconciled with actual rows, standard-table issues withhold the hash, and delay-only issues preserve an independently complete standard hash. Cancellation, typed resource recovery and failed-cleanup ownership remain intact.
Validation:
7f70797bintegration, covering parser/mapping/image/service/filesystem/CLI/MCP/lifecycle behavior and the upstream plist-fixture correction. Fullnpm run check,npm run docs:checkand test discovery pass. Negative controls reproduce the corrected overflow, mapping-gap, coverage and cancellation failures before correction. Actual SDK output is checked against the advertised JSON schema.Verification report records artifact digests, revisions, provenance and measurement limits. Final CI run 40057282775 fails on 11 separate plist cases. Exact main
cd10ee1fand actual CI mergec3d08d01reproduce the same 19 passing / 11 failing cases with identical normalized failures and unchanged producing sources. Two other shards are cancelled; their remaining coverage is unexecuted. The maintainer-authorized baseline bypass is supported by these controls; the PR's selected checks pass.Author readiness
Human owner: @mvanhorn