fix(tools): prevent searching root directory in grep and glob tools#15534
fix(tools): prevent searching root directory in grep and glob tools#15534coderzc wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Found a related PR: PR #8754: fix(sandbox): glob and grep to project directory This PR appears to address a very similar concern - sandboxing glob and grep tools to the project directory to prevent unintended filesystem access. This may be related to or a predecessor of the current PR (#15534), which specifically targets preventing root directory searches. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Description
Adds validation to prevent the
grepandglobtools from searching the root directory (/), which can cause performance issues and scan unintended system files.Related Issue(s)
Fixes #12051
Related to #14445
Related to #8754 (complementary - this PR specifically targets root directory while #8754 handles general sandboxing)
Type of Change
Changes
grep.tsto throw an error when attempting to search the root directoryglob.tsto throw an error when attempting to search the root directoryTesting
grep pattern=\"test\" path=\"/\"throws:\"Searching root directory is not allowed: /\"glob pattern=\"**/*.ts\" path=\"/\"throws:\"Searching root directory is not allowed: /\"Checklist
Additional Context
Searching the root directory (
/) can:/System,/Volumes, etc. on macOSThis PR complements #8754 which adds general sandboxing - while #8754 restricts searches to the project directory using
Filesystem.contains(), this PR specifically hard-blocks root directory searches which is a common edge case that should never be allowed.