feat: add safe git_rm tool with single-file constraint#158
Conversation
Safety-first design for LLM context:
- Single file only (string, not list) - no mass deletion
- Rejects wildcards (*, ?, [], {}), '.', '..', trailing '/'
- Rejects shell injection chars (;|&`$())
- Always uses '--' separator before file arg
- Supports --cached (index-only) and --dry-run (preview)
- 27 unit tests covering success, validation, and error handling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @MementoRC's task —— View job Code Review Complete ✅I've thoroughly reviewed the Review Checklist:
🔒 Security (Excellent)The implementation prioritizes security with multiple layers of validation: Strengths:
Minor suggestion: Consider adding validation for absolute paths (paths starting with 📋 Code Quality (Very Good)Model Design (
Implementation (
Registration (
🧪 Test Coverage (Excellent)The test suite in Coverage highlights:
Test quality:
⚡ Performance (Good)
🔍 Potential IssuesMinor concerns:
📝 Suggestions for Enhancement
🎯 Overall AssessmentThis is a high-quality, security-focused implementation that successfully addresses the challenge of providing safe Recommendation: ✅ Approve The implementation demonstrates excellent defensive programming practices and thorough testing. The minor suggestions above are enhancements rather than blocking issues. |
- Add os.path.normpath() to collapse ./, ../, redundant separators - Check trailing slash before normpath to catch dir-style paths - Add unicode filename tests (résumé.txt, 日本語.csv, etc.) - Add path normalization tests (./src/../src/file.py, src//file.py) - 37 tests passing (was 27) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @MementoRC's task —— View job PR Code ReviewI'll review this Review Checklist:
🔒 Security Analysis: ExcellentThe implementation demonstrates exceptional security-first design: Comprehensive Input Validation:
Security Strengths:
📋 Code Quality: Very GoodModel Design (
Implementation Structure (
Registry Integration (
🧪 Test Coverage: OutstandingThe test suite ( Test Categories:
Test Quality Highlights:
⚡ Performance: Efficient
🎯 Minor Enhancement Opportunities
🔍 Potential Issues Found: None CriticalArchitecture Decision Questions:
📝 Code Style & Best PracticesExcellent adherence to:
🏆 Overall AssessmentThis is an exceptionally well-implemented security-focused tool that successfully addresses the challenge of providing safe
Recommendation: ✅ Strong Approve The implementation sets a high standard for security-conscious tool design. The single-file constraint combined with comprehensive input validation makes mass deletion virtually impossible while maintaining necessary functionality. |
Adds os.path.isabs() check after normpath to block paths like /etc/passwd or /tmp/test.txt. Only repo-relative paths allowed. 40 tests passing (was 37). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @MementoRC's task —— View job PR Code ReviewI've thoroughly reviewed this Review Checklist:
🔒 Security Analysis: ExcellentThe implementation demonstrates exceptional security-first design with multiple validation layers: Input Validation Strengths:
Security Architecture:
📋 Code Quality: Very GoodModel Design (
Implementation Structure (
Registry Integration (
🧪 Test Coverage: OutstandingThe test suite ( Test Organization:
Test Quality Highlights:
⚡ Performance: Efficient
🔍 Potential Issues: MinorArchitecture Considerations:
Code Style:
📝 Suggestions for Enhancement
🏆 Overall AssessmentThis is an exceptionally well-implemented security-focused tool that successfully addresses the challenge of providing safe
Strengths Summary:
Recommendation: ✅ Strong Approve The implementation sets a high standard for security-conscious tool design. The single-file constraint combined with comprehensive input validation makes accidental or malicious mass deletion virtually impossible while maintaining necessary functionality. |
Summary
git_rmtool with safety-first design for LLM context.,.., trailing/, and shell injection characters--separator before file arg to prevent flag injection--cached(remove from index only) and--dry-run(preview)Files Changed
src/mcp_server_git/git/models.py—GitRmmodelsrc/mcp_server_git/git/operations_extended.py—git_rm()implementationsrc/mcp_server_git/lean/registry_git.py— tool registrationtests/unit/git/test_git_rm.py— 27 unit tests (7 success, 13 validation, 3 error handling + parametrized)Test plan
🤖 Generated with Claude Code