Skip to content

Commit 70753f3

Browse files
committed
Mark test_clone_command_injection xfail on Windows
This other GitCommandError on Windows is not related to IndexFile.from_tree whose 8 related failing tests were marked xfail in the preceding commit. Also, test_clone_command_injection should not be confused with test_clone_from_command_injection, which passes on all platforms. The problem here appears to be that, on Windows, the path of the directory GitPython is intended to clone to -- when the possible security vulnerability this test checks for is absent -- is not valid. This suggests the bug may only be in the test and that the code under test may be working on Windows. But the test does not establish that, for which it would need to test with a payload clearly capable of creating the file unexpected_path refers to when run on its own. (The "\" characters in the path seem to be treated as escape characters rather than literally. Also, "touch" is not a native Windows command, and the "touch" command in Git for Windows maps disallowed occurrences of ":" in filenames to a separate code point in the Private Use Area of the Basic Multilingual Plane.) This doesn't currently seem to be reported as a bug, but some general context about the implementation can be examined in gitpython-developers#1518 where it was introduced, and gitpython-developers#1531 where it was modified.
1 parent 6e477e3 commit 70753f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/test_repo.py

+5
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,11 @@ def test_do_not_strip_newline_in_stdout(self, rw_dir):
13651365
r.git.commit(message="init")
13661366
self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n")
13671367

1368+
@pytest.mark.xfail(
1369+
os.name == "nt",
1370+
reason=R"fatal: could not create leading directories of '--upload-pack=touch C:\Users\ek\AppData\Local\Temp\tmpnantqizc\pwn': Invalid argument", # noqa: E501
1371+
raises=GitCommandError,
1372+
)
13681373
@with_rw_repo("HEAD")
13691374
def test_clone_command_injection(self, rw_repo):
13701375
with tempfile.TemporaryDirectory() as tdir:

0 commit comments

Comments
 (0)