Commit 2e0a04b
fix: prevent environment expansion in clone URLs
Repo.clone_from() expanded environment-variable references in caller-supplied URLs before passing them to git clone. This could expose process environment values to an untrusted remote and made protocol validation apply to a different value than Git received.
Polish clone URLs without variable or home expansion, then apply unsafe-protocol validation to that exact normalized value. Preserve the literal URL when normalizing the stored origin after a successful clone, while retaining the existing Git.polish_url() default for callers that intentionally normalize local paths. Add regression coverage for POSIX and Windows variable syntax, stored origins, and post-normalization protocol validation.
Git baseline: git clone passes URL arguments through literally; t/t5601-clone.sh covers the accepted URL forms without shell-style environment expansion.
Security: GHSA-rwj8-pgh3-r573.
Validation:
- pytest test/test_clone.py -q (20 passed, 1 skipped)
- ruff check on changed files
- ruff format --check on changed files
- full pytest suite (681 passed, 73 skipped, 1 xfailed; 7 unrelated environment/baseline failures)1 parent 7a46dfc commit 2e0a04b
3 files changed
Lines changed: 49 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
906 | | - | |
| 906 | + | |
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
910 | | - | |
| 910 | + | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
| 913 | + | |
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
919 | 923 | | |
920 | 924 | | |
921 | 925 | | |
922 | 926 | | |
923 | 927 | | |
924 | 928 | | |
925 | 929 | | |
926 | | - | |
927 | | - | |
928 | | - | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
929 | 934 | | |
930 | 935 | | |
931 | 936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1452 | 1452 | | |
1453 | 1453 | | |
1454 | 1454 | | |
| 1455 | + | |
1455 | 1456 | | |
1456 | | - | |
| 1457 | + | |
1457 | 1458 | | |
1458 | 1459 | | |
1459 | 1460 | | |
| |||
1465 | 1466 | | |
1466 | 1467 | | |
1467 | 1468 | | |
1468 | | - | |
| 1469 | + | |
1469 | 1470 | | |
1470 | 1471 | | |
1471 | 1472 | | |
| |||
1505 | 1506 | | |
1506 | 1507 | | |
1507 | 1508 | | |
1508 | | - | |
| 1509 | + | |
1509 | 1510 | | |
1510 | 1511 | | |
1511 | 1512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
349 | 382 | | |
350 | 383 | | |
351 | 384 | | |
| |||
0 commit comments