Skip to content

✨ feat(mq-lang): add walk_files builtin for generic file enumeration - #2334

Merged
harehare merged 2 commits into
mainfrom
feat/walk-files-builtin
Sep 13, 2026
Merged

✨ feat(mq-lang): add walk_files builtin for generic file enumeration#2334
harehare merged 2 commits into
mainfrom
feat/walk-files-builtin

Conversation

@harehare

@harehare harehare commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Summary

collection() reads and parses Markdown files only; there was no safe way to enumerate arbitrary files (SBOM, logs, images, etc.) under --allow-read without escaping to a shell find. walk_files(root, pattern="**", options) returns a stable-sorted array of root-relative paths, matched against a glob pattern, with respect_gitignore and follow_symlinks options.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

collection() reads and parses Markdown files only; there was no safe way
to enumerate arbitrary files (SBOM, logs, images, etc.) under --allow-read
without escaping to a shell find. walk_files(root, pattern="**", options)
returns a stable-sorted array of root-relative paths, matched against a
glob pattern, with respect_gitignore and follow_symlinks options.

Internally, collection's and walk_files' directory recursion is unified
into a single walk_dir helper (gitignore/hidden-file filtering, symlink-
cycle detection, and symlink-directory-following are now shared), with no
change to collection's observable behavior.

Also fixes dangerous_capability_call's capability_flag map, which was
missing file_info alongside the new walk_files entry.
@codspeed-hq

codspeed-hq Bot commented Sep 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 51 untouched benchmarks


Comparing feat/walk-files-builtin (9e08341) with main (c6e3e1d)

Open in CodSpeed

…ns in walk_dir

SandboxedIo's --allow-read/--allow-write allowlist checked only the lexical
path, so a symlink whose lexical path sat inside an allowed directory (or an
allowed root that was itself a symlink) could redirect reads/writes outside
every grant. Add real_path/permits_real to resolve both the target and each
allowed root to their real filesystem location before comparing.

walk_dir (shared by collection and walk_files) also dropped any entry whose
filename wasn't valid UTF-8, unlike the old collection walker, and only
checked follow_symlinks against subdirectories found during recursion, never
the initial root. Keep filenames as OsStr and move the symlink check to the
top of walk_dir so it covers the root too.
@harehare
harehare merged commit 0e7c26c into main Sep 13, 2026
12 checks passed
@harehare
harehare deleted the feat/walk-files-builtin branch September 13, 2026 06:48
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.

1 participant