test(security): Pin that a remote clone's .git is always removed - #1798
Conversation
intent(remote-clone): the .git removal is what stops a cloned repository from handing git its own config during the pack, but the code framed it as tidiness, so a later change could drop it without anyone noticing what was lost constraint(remote-clone): the guarantee is about what is left on disk rather than which git arguments ran, so unlike its sibling tests this one uses a real temporary directory learned(remote-clone): deleting the fs.rm call turns the new test red, so it pins the behavior instead of passing vacuously Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
⚡ Performance Benchmark
Details
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change documents why ChangesGit clone cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1798 +/- ##
=======================================
Coverage 91.87% 91.87%
=======================================
Files 133 133
Lines 5574 5574
Branches 1365 1365
=======================================
Hits 5121 5121
Misses 453 453 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
execGitShallowClonedeletes the clone's.gitbefore the pack runs. The comment called this "Clean up .git directory", which reads as tidiness, but the removal is load-bearing for safety: packing runsgit -C <dir> logby default (output.git.sortByChanges), and git honors a repository's own.git/config. If the clone kept its.git, a remote repository could reach host command execution through keys such asgpg.programvialog.showSignature.Nothing guarded that. No comment explained it and no test pinned it, so a reasonable-looking change (keeping
.gitso diffs work on remote repos, for instance) would have reopened the path silently.This adds the missing why, and a test that fails if the removal goes away.
Changes
src/core/git/gitCommand.ts: explain what the removal protects and why it must stay unconditionaltests/core/git/gitCommand.test.ts: assert.gitis gone afterexecGitShallowClone. Unlike its sibling tests, this one uses a real temporary directory, because the guarantee is about what is left on disk rather than which git arguments ranThe same reasoning is already spelled out where the sandboxed MCP path disables git sorting (
src/mcp/tools/packCodebaseTool.ts) and where the website drops.gitfrom uploads. This brings the third site in line.Verification
fs.rmcall turns the new test red, so it is not passing vacuously🤖 Generated with Claude Code