Commit 7fa20b2
feat: add HTTP Basic Auth for git operations and inject host git config (#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>1 parent 8da1f8f commit 7fa20b2
6 files changed
Lines changed: 345 additions & 1 deletion
File tree
- packages/multiplexer
- src
- backends
- proxy
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
7 | 57 | | |
8 | 58 | | |
9 | 59 | | |
| |||
172 | 222 | | |
173 | 223 | | |
174 | 224 | | |
| 225 | + | |
| 226 | + | |
175 | 227 | | |
176 | 228 | | |
177 | 229 | | |
| |||
338 | 390 | | |
339 | 391 | | |
340 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
341 | 412 | | |
342 | 413 | | |
343 | 414 | | |
| |||
477 | 548 | | |
478 | 549 | | |
479 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
480 | 554 | | |
481 | 555 | | |
482 | 556 | | |
| |||
485 | 559 | | |
486 | 560 | | |
487 | 561 | | |
| 562 | + | |
| 563 | + | |
488 | 564 | | |
489 | 565 | | |
490 | 566 | | |
| |||
637 | 713 | | |
638 | 714 | | |
639 | 715 | | |
| 716 | + | |
| 717 | + | |
640 | 718 | | |
641 | 719 | | |
642 | 720 | | |
| |||
651 | 729 | | |
652 | 730 | | |
653 | 731 | | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
654 | 769 | | |
655 | 770 | | |
656 | 771 | | |
| |||
0 commit comments