✨ feat(mq-lang): add walk_files builtin for generic file enumeration - #2334
Merged
Conversation
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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Checklist
cargo fmtandcargo clippyand addressed any warningsjust test-alland all tests pass/docs, crateREADME.md) if neededAdditional Context