Repository navigation
PE inspection: audit the package dependency graph before first boot - #6242
ODanielAtaide wants to merge 4 commits into
Conversation
Follow normal and delay imports through package images and report the dependency chain for missing files, unreadable images, architecture mismatches and missing exports. AI-assisted.
|
The new dependency graph retains a quadratic number of module references for a linear DLL chain at
Every import resolved in this synthetic test. One predecessor per module preserves the shortest path chosen by breadth-first traversal. Reconstruct full chains for diagnostics when needed. If the JSON must include every full chain, its output size has the same quadratic lower bound. Reproduce from the repository root with import json, runpy, tempfile
from pathlib import Path
t = runpy.run_path("tests/test_pe_inspect.py")
for n in (32, 64, 128, 256):
with tempfile.TemporaryDirectory() as d:
root = Path(d)
names = ["test.exe"] + [f"m{i:03}.dll" for i in range(1,n)]
for i,name in enumerate(names):
refs = [(names[i+1], ["Start"])] if i+1 < n else []
(root/name).write_bytes(t["package_image"](refs,exports=t["with_exports"]([0x1000],{0:"Start"})))
graph = t["pe_inspect"].inspect(str(root/names[0]),str(root),dependencies=True)["dependency_graph"]
assert all(e["status"] == "declared" for e in graph["imports"])
print(n,len(graph["imports"]),sum(len(m["chain"]) for m in graph["modules"]),len(json.dumps(graph).encode()))On Windows, 63 PE inspector tests passed and one skipped. The first-look report integration test passed. The new cycle test fails against AI-assisted. |
|
Ran the Across the DLL roots I counted 325 distinct (source, imported DLL, import kind) edges, all normal imports. Of these, 30 resolved locally with every requested export declared. The other 295 were classified I recomputed reachability and shortest distances from the individual direct-import reports and case-insensitive directory membership. Both matched the new graph for all 17 roots. One DLL root reached depth two, 13 reached depth one and two had no local dependencies. All visited local modules parsed successfully. The long-chain and delay-import cases remain covered by synthetic fixtures. AI-assisted, CPU only. |
Keep a single predecessor per image and reconstruct paths only for Markdown findings. Collect all inspected DLLs before writing a batch of reports. Regression tests cover a deep chain and a file another report would overwrite. AI-assisted.
|
Retested the predecessor change at This covers the batch CLI and the externally visible diagnostics on the same Xbox 1.0.2.1 package as the earlier check. CachyOS x86-64, CPU only, AI-assisted. Retested the ordinal-matching change at |
|
Thanks for the reproducer. Updated in I also reproduced a batch-output collision: the first entry's report could overwrite a DLL imported only by a later entry. The CLI now collects all inspected inputs before writing. The regression test verifies the would-be output survives and the later report can still resolve its export. Windows CPU: 65 PE inspector tests passed, one symlink test skipped. The first-look report and exit-code integrations passed. AI-assisted. |
|
Independent Windows 11 / Python 3.12 review of
Environment note: the first-look exit test initially failed on both revisions in my PowerShell 7-launched session because its inherited PowerShell module path interfered with Windows PowerShell's These checks establish the tested synthetic behavior, not actual package bindings or boot success. No game files or GPU were used. AI-assisted review. — LocalFirst-AI |
|
Head Windows 11, Python 3.13: End-to-end on a real package member ( Verdict: good pre-boot audit tool and docs, works as described, and the failure paths (absent, unreadable, machine mismatch, ambiguous name, missing export) are covered by tests. It is diagnostic only: it cannot change the first frame. Applies cleanly to |
Keep the first-look hash lookup and dependency graph assertions and stage their report path helper in the test fixture.
|
@ItsNotRexed Could you approve the fork workflows for I merged upstream On Windows 11 with CPython 3.14, the PE inspector suite passed 65 tests with one skip. All six first-look integration tests passed. A separate read-only parser check on a local x64 executable produced 68 import records. The sample's build version remains unverified. The No Game Data and whitespace checks passed. AI-assisted (Codex). Additional Windows check with the same executable and a separate local DLL directory. The read-only dependency walk visited 8 PE images and recorded 195 imports. Of those, 18 had a declaration in a local DLL, 167 were host candidates, and 10 remained unresolved across 7 distinct library names. Version alignment and loader binding remain unverified. |
|
Tested 6c2ef3c merged with main 1ce6eb5 on Linux/Python 3.12.16 and Windows/Python 3.13.1: pass Merge was clean on both (tools/pe_inspect.py, scripts/first_look.ps1, tests/test_pe_inspect.py, tests/test_first_look_shim_report.py, docs/boot.md). Linux, 3.12.16:
Windows, 3.13.1 (worktree of main with the PR merged):
Diff read: Overlap: #7084 (open) rewrites |
Keep name and ordinal identities distinct in dependency matching and preserve the report format.
|
hey @ItsNotRexed, could you take a look at #6242 when you get a chance? the windows tests passed on |
What this adds
First-boot PE inspection currently lists only the executable’s direct imports. Add an opt-in
--dependenciespass and enable it inscripts/first_look.ps1. It follows normal and delay imports through local package DLLs, lists each image once even in a cycle, and records the shortest chain to each image. The Markdown report points to absent or unreadable DLLs, machine mismatches, ambiguous file names, and names or ordinals absent from the local export table.This is a read-only inventory of the package, independent of the runtime build. A forwarded export counts as a declaration. Windows and shim binding behavior can be measured with the existing
--dry-run. This complements #5732, which classifies shim coverage for explicitly supplied images.Claim: #6089 (comment)
Validation
test_pe_inspect.py, 63 passed, 1 existing symlink test skipped. The four new tests cover transitive normal and delay imports, a cycle, a forwarded export declaration, named and ordinal lookup, unreadable and mismatched DLLs, and report path protection.first_look.ps1integration test exercises the real inspector and checks the transition from missing to unreadable when a DLL appears. It fails on unmodified main because the graph is absent. The exit-code integration test also passes.py_compile, PowerShell syntax validation, andgit diff --check.No game files or GPU execution. AI-assisted.