feat: add HTTP Basic Auth for git operations and inject host git config - #174
Conversation
This commit adds two key features to enable git operations in Docker containers: 1. **HTTP Basic Auth for Git Operations** - Added AuthEncoding enum with Simple and BasicAuthWithToken variants - Updated proxy rules to use BasicAuthWithToken for github.com - Encodes credentials as "Basic base64(x-access-token:TOKEN)" - Enables git push/pull/clone through the HTTPS proxy - Added comprehensive unit tests for Basic Auth encoding 2. **Git User Configuration Injection** - Added read_git_user_config() to read host git config - Injects GIT_AUTHOR_NAME, GIT_COMMITTER_NAME environment variables - Injects GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL environment variables - Ensures git commits in containers have proper attribution - Added tests for git config injection and graceful handling Files modified: - src/proxy/rules.rs: HTTP Basic Auth implementation - src/backends/docker.rs: Git config reading and injection - Cargo.toml: Added base64 dependency - tests/*: Updated all tests with new parameters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @shepherdjerred's task in 1m 55s —— View job Code ReviewI've reviewed this PR focusing on architectural fit, logic errors, security, and design. Overall, this is a well-implemented feature with solid test coverage. The changes cleanly integrate into the existing codebase. Here are my findings: ✅ Strengths
🔍 Issues Found1. Security: Potential Command Injection in Git Config (packages/multiplexer/src/backends/docker.rs:386-400)The git user name and email are injected directly into environment variables without sanitization: format!("GIT_AUTHOR_NAME={}", name),If a user has malicious characters in their git config (e.g., Recommendation: Sanitize or validate the git config values before injection: // Reject names/emails containing newlines or other dangerous characters
if name.contains('\n') || name.contains('\r') {
tracing::warn!("Git user name contains invalid characters, skipping");
return None;
}2. Logic Error: Race Condition in Git Config Reading (packages/multiplexer/src/backends/docker.rs:10-44)The let name = Command::new("git").args([...]).await;
let email = Command::new("git").args([...]).await;This is inefficient and could theoretically read inconsistent state if git config changes between calls. Recommendation: Either:
3. Design: Unused
|
Added sanitize_git_config_value() function that removes control characters (except tabs) to prevent environment variable injection. - Filters out newlines that could inject malicious env vars - Removes other control characters that could cause issues - Preserves tabs as they're valid in git names - Added 4 tests to verify sanitization works correctly Addresses security concern from automated code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @shepherdjerred's task in 1m 16s —— View job Code ReviewI've reviewed the changes focusing on architectural fit, logic errors, security, and design. The previous review identified the command injection vulnerability which has been fixed in commit ✅ What's Good
🔍 Issues Found1. Architectural: Unused
|
|
Claude finished @shepherdjerred's task in 1m 43s —— View job Code ReviewI've reviewed the changes focusing on architectural fit, logic errors, security, and design. The security fix for command injection has been properly implemented. Here's my analysis: ✅ What's Good
🔍 Issues Found1. Design: Unused
|
Resolved conflicts: - src/tui/events.rs: Merged AccessMode field navigation with cursor movement logic in Prompt field Includes changes from main: - feat: add access mode selection to TUI session creation (#173) - feat: add comprehensive status tracking to session manager TUI (#172) - fix: make plan mode work via prompt instruction (#171) - feat: add Rust compiler cache sharing with sccache (#175) - feat: add HTTP Basic Auth for git operations (#174) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ig (shepherdjerred#174) * feat: add HTTP Basic Auth for git operations and inject host git config This commit adds two key features to enable git operations in Docker containers: 1. **HTTP Basic Auth for Git Operations** - Added AuthEncoding enum with Simple and BasicAuthWithToken variants - Updated proxy rules to use BasicAuthWithToken for github.com - Encodes credentials as "Basic base64(x-access-token:TOKEN)" - Enables git push/pull/clone through the HTTPS proxy - Added comprehensive unit tests for Basic Auth encoding 2. **Git User Configuration Injection** - Added read_git_user_config() to read host git config - Injects GIT_AUTHOR_NAME, GIT_COMMITTER_NAME environment variables - Injects GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL environment variables - Ensures git commits in containers have proper attribution - Added tests for git config injection and graceful handling Files modified: - src/proxy/rules.rs: HTTP Basic Auth implementation - src/backends/docker.rs: Git config reading and injection - Cargo.toml: Added base64 dependency - tests/*: Updated all tests with new parameters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * security: sanitize git config values to prevent injection attacks Added sanitize_git_config_value() function that removes control characters (except tabs) to prevent environment variable injection. - Filters out newlines that could inject malicious env vars - Removes other control characters that could cause issues - Preserves tabs as they're valid in git names - Added 4 tests to verify sanitization works correctly Addresses security concern from automated code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
This PR adds two key features to enable git operations in Docker containers:
1. HTTP Basic Auth for Git Operations
AuthEncodingenum withSimpleandBasicAuthWithTokenvariantsBasicAuthWithTokenfor github.comBasic base64("x-access-token:TOKEN")2. Git User Configuration Injection
read_git_user_config()to read host git configGIT_AUTHOR_NAME,GIT_COMMITTER_NAMEenvironment variablesGIT_AUTHOR_EMAIL,GIT_COMMITTER_EMAILenvironment variablesHow It Works
Git Push Flow:
```
git push
→ Uses HTTPS_PROXY (host.docker.internal:18080)
→ Proxy matches github.com
→ BasicAuthWithToken encoding
→ Injects: Authorization: Basic base64("x-access-token:GITHUB_TOKEN")
→ GitHub accepts auth
→ Git push succeeds! ✅
```
Git Config Flow:
```
Host: git config user.name / user.email
→ read_git_user_config()
→ Docker container environment:
→ Git commits have proper attribution! ✅
```
Files Modified
src/proxy/rules.rs: HTTP Basic Auth implementationsrc/backends/docker.rs: Git config reading and injectionCargo.toml: Added base64 dependencytests/*: Updated all tests with new parametersTesting
🤖 Generated with Claude Code