Skip to content

Fix directory module IDs for collision-prone paths#25

Merged
tob-scott-a merged 1 commit intotrailofbits:mainfrom
flowtrader2016:fix-directory-module-ids
Apr 24, 2026
Merged

Fix directory module IDs for collision-prone paths#25
tob-scott-a merged 1 commit intotrailofbits:mainfrom
flowtrader2016:fix-directory-module-ids

Conversation

@flowtrader2016
Copy link
Copy Markdown
Contributor

Summary

Fix directory parsing so same-named files in different directories do not collide during graph merge.

Directory parsing now uses root-relative module IDs while preserving existing stem-based IDs for single-file parsing. Path components are escaped before joining so dotted filenames remain unambiguous, and symlinked files are keyed by their scanned lexical path.

This also tightens pyproject and override entrypoint resolution so ambiguous suffix matches are skipped instead of selecting an order-dependent node.

Testing

  • ruff format src/ tests/
  • ruff check src/ tests/
  • pytest -q
  • ty check
  • Requests smoke test: cross_file_contains 0

Directory parsing previously derived module IDs from filename stems, causing same-named files in different directories to collide during graph merge.

Use root-relative module IDs during directory parsing while preserving existing single-file stem behavior. Escape dotted path components so the encoding remains unambiguous, and derive relative paths lexically so symlinked files are keyed by their scanned location rather than their resolved target.

Resolve pyproject and override entrypoint targets by exact node ID first, and only fall back to suffix matching when the suffix is unambiguous.

Add shared parser regression tests for duplicate stems, dotted path components, package __init__.py files, and symlinked files, plus entrypoint ambiguity tests.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 23, 2026

CLA assistant check
All committers have signed the CLA.

@tob-scott-a tob-scott-a merged commit 7520ce8 into trailofbits:main Apr 24, 2026
8 checks passed
@tob-scott-a
Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants