Skip to content

Fix path flattening collisions and make runfiles resolution deterministic in make_corpus_dir#290

Open
jmestwa-coder wants to merge 1 commit into
bazel-contrib:mainfrom
jmestwa-coder:make-corpus-dir-path-handling
Open

Fix path flattening collisions and make runfiles resolution deterministic in make_corpus_dir#290
jmestwa-coder wants to merge 1 commit into
bazel-contrib:mainfrom
jmestwa-coder:make-corpus-dir-path-handling

Conversation

@jmestwa-coder
Copy link
Copy Markdown

Summary

Fixes path flattening collisions and makes runfiles resolution deterministic in make_corpus_dir.


Problem

  • Different inputs could map to the same output (e.g., dir/../a.txt vs a.txt, ./a.txt vs dot-a.txt)
  • Runfiles resolution could pick the wrong script depending on manifest order

Solution

  • Preserve input path structure during flattening (no unintended normalization)
  • Ensure unique output names using deterministic suffixing and fallback aliasing
  • Make runfiles resolution deterministic:
    • prefer workspace entries
    • use _main only as fallback
    • ignore unrelated repos

Result

  • Distinct inputs always produce distinct outputs
  • No silent collisions or overwrites
  • Deterministic behavior across runfiles and manifest modes

Tests

  • Added coverage for path edge cases and collision scenarios
  • Verified runfiles resolution across:
    • TEST_SRCDIR
    • RUNFILES_DIR
    • RUNFILES_MANIFEST_FILE
    • multi-repo manifests

@jmestwa-coder jmestwa-coder force-pushed the make-corpus-dir-path-handling branch from e2e4d68 to c328a1a Compare May 2, 2026 15:51
@jmestwa-coder
Copy link
Copy Markdown
Author

Hi @fmeum, @simonresch Can you kindly review this PR. Thank you!

@simonresch
Copy link
Copy Markdown
Collaborator

The only caller of make_corpus_dir is in fuzzing_corpus where https://github.com/bazel-contrib/rules_fuzzing/blob/main/fuzzing/private/common.bzl#L86 calls it with a list of workspace relative, cleaned list of files. Where is the potential for dir/../a.txt vs a.txt, ./a.txt ambiguity?

Could you make sure the added test passes? You can run it with the command bazel test //fuzzing/tools:make_corpus_dir_test.

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.

2 participants