fix(tools): allow git_operations to run in workspace subdirectories#4483
Merged
Conversation
Fixes #4409. The git_operations tool now accepts an optional 'path' parameter to specify a subdirectory within the workspace. Path traversal outside the workspace is rejected for security.
webhive
pushed a commit
to webhive/zeroclaw
that referenced
this pull request
Mar 24, 2026
…eroclaw-labs#4483) Fixes zeroclaw-labs#4409. The git_operations tool now accepts an optional 'path' parameter to specify a subdirectory within the workspace. Path traversal outside the workspace is rejected for security.
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
pathparameter to thegit_operationstool schemaresolve_working_dir()helper with directory traversal protectionrun_git_command()and all 8 operation methods to accept a configurable working directoryFixes #4409
Context
The
git_operationstool hardcodedself.workspace_diras the working directory for all git commands. Users with git repos in workspace subdirectories (e.g., monorepos, cloned projects) could not use the tool on those repos. The agent would report "no .git folder exists" even when the subdirectory contained a valid git repository.Test plan
resolve_working_dirreturns workspace root when no path given (new test)resolve_working_dirresolves valid subdirectory paths (new test)resolve_working_dirrejects..traversal attacks (new test)