Repository navigation
feat(elf): inspect dynamic dependencies and required symbol versions - #7868
Conversation
Add inspect-elf-dependencies and inspect_elf_dependencies for ELF32/ELF64 ET_EXEC and ET_DYN images, read statically without executing them or invoking the dynamic loader. Report ordered DT_NEEDED names with duplicates preserved, DT_SONAME, DT_RPATH and DT_RUNPATH as written including $ORIGIN/$LIB/$PLATFORM tokens, decoded DT_FLAGS and DT_FLAGS_1, PT_INTERP, GNU version requirements and definitions, derived per-namespace maxima, and undefined .dynsym imports joined to library@version when known. A missing PT_DYNAMIC is an observed empty inventory. Relocatable objects and core dumps are rejected toward the matching workflows. Cyclic version chains and exhausted named budgets return no partial success.
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 latest change appears safe to merge; no new actionable issue was found. SummaryAdds offline ELF dependency inspection through CLI and MCP, with retained summaries and selectable pages.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI or MCP request] --> B[Admit selected file and controls]
B --> C[Read stable file without execution]
C --> D[Decode bounded ELF tables]
D --> E[Complete Evidence with identity and coverage]
E --> F[Inline inventory]
E --> G[Retained summary]
G --> H[Selected pages from retained Evidence]
Reviews (65) · Last reviewed commit: "test(mcp): assert omitted and explicit o..." · Reviewed by Greptile |
# Conflicts: # .agents/skills/reverse-engineer-anything/SKILL.md # src/contracts/analysisViewToolContracts.ts # src/domain/analysisView/analysisView.ts # src/generatedPackageMetadata.ts # src/server/createServer.ts
- Keep DT_VERNEED/DT_VERDEF fallback reads and the GNU hash walk inside the admitting PT_LOAD mapping or section instead of EOF. - Report a version table with no record count as unreadable. - Keep the verneed/verdef prefix read before a failure and join imports only against fully read verneed entries. - Leave imports unresolved when verneed entries reuse a version index. - Record name_unreadable for empty PT_INTERP segments and paths. - Compare version components as exact integers and skip empty namespaces when deriving maxima. - Type the elf-dependencies view kinds for the refactored view registry.
|
This branch now has main merged in, with the conflicts resolved. Main split analysisView.ts into request, result and shape modules, so the elf-dependencies view now registers through analysisViewRequest.ts, analysisViewResult.ts and the retained projector map, the same way native-exports does. createServer.ts takes main's layout with the inspect_elf_dependencies registration added next to the kernel module tool. Skill version moves to 56 since main is at 55. Merge commit is 0873e42. |
- Decode each dynamic string offset once and charge every retained reference, including import version names, against one scan and retained-text budget fixed by the admitted image length. - Treat DT_* entries as the load-time facts. Use a section header only when it names the same address, maps to the same file bytes, and agrees on DT_STRSZ or DT_SYMENT; report a disagreeing section. - Page version definitions and derived version maxima through their own view collections; summaries keep counts and table status. - Keep the read file's path, SHA-256, and byte count as a partial observation when parsing fails after a completed read.
Resolve the skill version conflict at 59, one past main's 58, and regenerate package metadata.
asTag cut every ELF64 tag to 32 bits, so 0x100000001 read as DT_NEEDED and 0x100000000 read as DT_NULL and ended the walk. Keep the class-width value and skip tags wider than any known DT_* tag. A PT_INTERP outside the file kept its invalid range in the report location, so the service rejected the whole inventory. Return a null location with the existing issue, which still names the declared offset.
A nonzero bucket below firstSymbol made the chain walk read before the chain array, so a stripped image could report a short symbol count and lose imports while coverage stayed complete. Treat the table as unusable, matching the reader in DartElf.ts.
The walkers read vn_next, vna_next and vd_next only while the count said another record was due, so a count that stopped short of the links dropped the remaining records and still reported complete coverage. The dynamic loader follows the links, so those records are real requirements. Move the chain step into one helper that also requires the final link to be zero. A conflict keeps the records already read, marks the table unreadable, and leaves coverage partial.
Nothing imports the alias, so knip fails the repository check.
Every count limit failed as the same capacity boundary, so recovery text could not tell a caller budget from a fixed ceiling. An image over the dynamic-symbol ceiling was told to raise max_imports, which the schema caps at that same value. The failure now carries the limit that was hit. Budget failures name only that budget and its maximum. Ceiling failures, including the input-size ceiling, say this release has no runtime override and name what does not raise them. DT_FLAGS and DT_FLAGS_1 were cut to 32 bits before decoding, so ELF64 bits above the low word vanished from raw and unrecognized. The decoder now keeps the whole word and the output schema allows safe integers. Words past that range stay refused rather than cut. The fixture's 64-bit writer cut values the same way, and its concatenation overflowed the stack on a table large enough to reach the ceiling.
tableFromSection copied a section's declared size into the table and its report location without checking it fits the file. A .gnu.version_r or .gnu.version_d section with a valid start and an oversized size still parsed, then ElfDependenciesService.validReport rejected the published range and the whole inventory was lost. Clamp section tables to the file and report malformed_entry. A table starting past the end has no usable part, so the dynamic declaration is used instead. locateSymbolCount no longer takes a count from such a section, which dropped every import or hit the dynamic symbol ceiling when the size was a multiple of the entry size.
Rejecting an oversized .dynsym now reaches the hash fallback, which read the count at hash.offset + 4 without checking the section range. With no DT_HASH tag and a .hash offset past the file, agreedSection keeps the section and the read throws, so the provider loses the whole inventory. A .hash section that does not fit the file now gives a malformed_entry issue and no count, and the walk moves on to DT_HASH and GNU hash. If none of them gives a count, the existing table_unavailable issue reports it and the libraries and versions stay in the report.
Resolve conflicts with the capability binding refactor: register the ELF dependencies service and provider through the capability declarations and services instead of the old createServer wiring.
|
Merged current main into this branch to clear the conflicts. main moved ELF service wiring into the capability declarations and services, so inspect_elf_dependencies is now registered there (the old createServer and catalog-builders edits were dropped). Typecheck, the composition and conformance tests, the ELF and server unit tests, and the architecture and module boundary checks pass locally. |
…ports DT_NEEDED and DT_SONAME offsets that pass the safe-integer check were rejected by the uint schema, which failed the whole report. Allow any safe integer so readable dependencies, versions and imports survive.
…revisions inspect-elf-dependencies dropped the caller's path spelling from Evidence because it never passed callerInputPath. Pass it as the other one-shot commands do. parseVerneed and parseVerdef read every record with revision 1's layout, so a damaged header could resolve imports while coverage stayed complete. Both now check the header revision first and report the table as unreadable.
Produce named decoder limits through the shared parse-failure algebra and project their facts at the provider boundary. Remove the superseded count-limit carrier and reuse the shared error-message projection. Check nested Evidence identity, caller path and digest in normal completion and late cancellation, and align the MCP architecture assertion. Co-authored-by: gensokyo-dev <[email protected]>
Register the public CLI and MCP cases for the provider capability, and regenerate the advertised output-schema summary after the Evidence identity migration. Co-authored-by: gensokyo-dev <[email protected]>
gensokyo-dev
left a comment
There was a problem hiding this comment.
The offline scope fits REA. Validated the refreshed implementation with 90 focused source tests, 274 public CLI/MCP/filesystem/finalization tests, 75 conformance tests, serial static checks, docs checks, and a real ELF/readelf comparison. Named parser limits, canonical Evidence identity, and retained views are covered.
Full typed lint remains unverified under the local memory budget; current required CI must pass before merge.
Keep application-owned input defaults at the application boundary. CLI option schemas retain help defaults without inserting omitted values; MCP summary bindings distinguish SDK-owned defaults from raw application requests, including nested selections. Record only the caller-selected ELF dependency controls. Cover omitted, explicit-default and nondefault budgets through the real CLI/MCP, SDK admission, nested application input, and help rendering. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <[email protected]>
Preserve shared reader checkpoints in the provider driver, keep named CPU limits, and verify cancellation identity and retry. Scope focused contract imports and align CLI omission assertions. Co-authored-by: gensokyo-dev <[email protected]>
Check a separate input using canonical defaults while retaining caller omission and deferred JSON text. Cover capture, signal and SQLite registrations alongside existing cleanup and admission workflows. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <[email protected]>
Keep defaults in schema metadata and let help render one annotation. Preserve existing parity goldens and distinguish omitted from explicit defaults in CLI admission assertions. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <[email protected]>
Render positional and option defaults through one metadata-aware owner. Verify keyed-archive help, preserve parity goldens, and assert the integrity-policy default as schema metadata. Co-authored-by: gensokyo-dev <[email protected]>
Collect actual bounded keyword-search results until the complete advertised catalog is covered. Preserve pending queries across partial readiness and diagnostics, check duplicate schemas, and retain query provenance. Verify 256 schemas with the official Grok1.0.50 client and all native preflight cleanup regressions. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <[email protected]>
Preserve omitted caller input and verify the declared default without inventing a description. Co-authored-by: gensokyo-dev <[email protected]>
Capture selected parameter names at canonical SDK validation and apply them to provider admission without retaining raw input trees. Reuse the application selection owner and verify omitted and explicit defaults through real MCP provider calls. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <[email protected]>
Compare equal CLI and MCP caller selections, including omitted controls and explicitly selected defaults, instead of requiring MCP to invent selections. Co-authored-by: gensokyo-dev <[email protected]>
|
Thanks for merging this, @N0zoM1z0. Having inspect_elf_dependencies report DT_NEEDED order, RUNPATH tokens and GNU symbol versions offline should make ELF load-time questions a lot quicker to answer. |
Summary
Add offline
inspect-elf-dependencies/inspect_elf_dependenciesfor ELF32/ELF64 needed libraries, literal search paths, GNU symbol versions and undefined dynamic imports. Retained summaries/pages preserve source identity, uncertainty and coverage. The selected image is read without execution or host-library resolution.GNU-hash decoding has a finite work allowance and cancellation checkpoints; decoder limits use the shared error algebra. CLI inputs, application-admitted MCP summaries and provider Evidence preserve omitted versus explicitly selected parameters. MCP captures selected names at canonical SDK validation without retaining raw input trees; SDK callbacks and delivery still receive parsed defaults. Execution defaults remain with their owning contracts, and help renders schema defaults once for both arguments and options.
The new tool raises the catalog to 256 entries. Grok verification now collects bounded native keyword-search results and checks their union against the complete catalog, retaining pending queries through partial readiness.
Validation
/usr/bin/lsCLI output matchedreadelfdependencies and required versions; actual stdio MCP summary/paging controls passed and the selected file digest stayed unchanged.Full typed lint exceeded the local 6 GiB early-stop budget; a later whole-static run hit its time limit. Complete current-head local static coverage remains unverified; CI supplies the full gate. No OOM occurred. Live model APIs, native Windows Grok behavior, loader behavior and ABI compatibility were not verified.
Author readiness
Human owner: @mvanhorn