feat(worktree): add worktree isolation plugin to marketplace#79
feat(worktree): add worktree isolation plugin to marketplace#79
Conversation
Add manually-maintained (Type 5) plugin that provides git worktree isolation via SessionStart context injection and PreToolUse path blocking. Ported from chatbot-pf/engineering-standards.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates a new Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new worktree plugin to provide isolation for git worktrees. While the implementation is well-structured and includes a comprehensive test suite, a critical security vulnerability was identified in the PreToolUse hook. This vulnerability allows relative paths to bypass access restrictions because the hook only checks absolute paths; resolving all paths against the current working directory before the security check is suggested as a remediation. Additionally, there is a minor opportunity to improve maintainability by reducing code duplication.
There was a problem hiding this comment.
4 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/worktree/hooks/deny-parent-access.ts">
<violation number="1" location="plugins/worktree/hooks/deny-parent-access.ts:147">
P1: Security bypass: relative paths are not resolved before the security check. A tool can pass a relative path like `../../parent/secret.ts` to bypass the parent path protection entirely, since `isParentPath()` returns `false` for non-absolute paths, immediately allowing the request.
The path should be resolved to absolute using `resolve(cwd, filePath)` before the security checks.</violation>
</file>
<file name="plugins/worktree/hooks/worktree-context.ts">
<violation number="1" location="plugins/worktree/hooks/worktree-context.ts:78">
P2: Linked-worktree detection compares paths using inconsistent separator normalization, which can misclassify the main repo as a worktree on Windows.</violation>
<violation number="2" location="plugins/worktree/hooks/worktree-context.ts:87">
P2: Parent project path extraction is POSIX-only and fails for Windows-style paths ending in `\\.git`.</violation>
</file>
<file name="plugins/worktree/hooks/worktree-context.test.ts">
<violation number="1" location="plugins/worktree/hooks/worktree-context.test.ts:86">
P2: This test is environment-dependent due to a hardcoded local path, so it may pass for the wrong reason and fail to validate the intended main-repo-root behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/worktree/hooks/deny-parent-access.ts">
<violation number="1" location="plugins/worktree/hooks/deny-parent-access.ts:140">
P1: Security bypass: relative paths are not resolved to absolute before checking, allowing access to parent project via paths like `../../../secret.ts`. The `cwd` should be used to resolve relative paths before calling `isParentPath`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Security (P1): resolve relative paths against cwd before isParentPath
check to prevent bypass via paths like ../../secret.ts
- Refactor: extract resolveCwd() helper from worktree-context.ts and
reuse in deny-parent-access.ts to eliminate duplication
- Fix (P2): use path.join() for .git dir comparisons to support
Windows path separators (endsWith(join('.git')))
- Test: replace hardcoded local path in worktree-context.test.ts with
import.meta.dir-based path for portability
- Test: add relative-path-bypass coverage to deny-parent-access.test.ts
Summary
worktreeplugin (Type 5 manually-maintained) ported fromchatbot-pf/engineering-standardsworktreeentry to.claude-plugin/marketplace.json(category: tooling)Plugin structure
Test plan
bun testinplugins/worktree/)marketplace.jsonandplugin.jsonare valid JSONSummary by cubic
Adds a new worktree isolation plugin to the marketplace to keep tool operations inside the active git worktree. Also hardens path checks to block relative-path bypasses and improves Windows support.
New Features
Bug Fixes
Written for commit b861a34. Summary will update on new commits.