Skip to content

fix(tools): allow git_operations to run in workspace subdirectories#4483

Merged
theonlyhennygod merged 1 commit into
masterfrom
fix/4409-git-operations-subdir
Mar 24, 2026
Merged

fix(tools): allow git_operations to run in workspace subdirectories#4483
theonlyhennygod merged 1 commit into
masterfrom
fix/4409-git-operations-subdir

Conversation

@theonlyhennygod
Copy link
Copy Markdown
Collaborator

Summary

  • Adds optional path parameter to the git_operations tool schema
  • Implements resolve_working_dir() helper with directory traversal protection
  • Refactors run_git_command() and all 8 operation methods to accept a configurable working directory
  • Adds 5 new tests covering path resolution, traversal rejection, and subdirectory operations

Fixes #4409

Context

The git_operations tool hardcoded self.workspace_dir as 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

  • Verify resolve_working_dir returns workspace root when no path given (new test)
  • Verify resolve_working_dir resolves valid subdirectory paths (new test)
  • Verify resolve_working_dir rejects .. traversal attacks (new test)
  • Verify git operations work correctly in subdirectories (new test)
  • Verify existing git operations at workspace root still work (existing tests pass)

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.
@theonlyhennygod theonlyhennygod merged commit ac543cf into master Mar 24, 2026
18 checks passed
@theonlyhennygod theonlyhennygod deleted the fix/4409-git-operations-subdir branch March 24, 2026 04:44
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.
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.

[Bug]: git_operations tool only run git command under workspace, not any subdirectories even I asked to

1 participant