Skip to content

Commit

Permalink
Mark test_clone_command_injection xfail on Windows
Browse files Browse the repository at this point in the history
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. Although this suggest 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 a file unexpected_path points
to when run on its own. I am unsure if that is the case, given
that the "touch" command is used.

This doesn't appear to be reported as a bug, but some general
context about the current implementation of this test can be
examined in gitpython-developers#1531 where the last major change to it was done.

When the test is fixed, that will become more clear. At that time,
this commit can be reverted to remove the xfail mark.
  • Loading branch information
EliahKagan committed Nov 16, 2023
1 parent 6e477e3 commit 16c2a43
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,11 @@ def test_do_not_strip_newline_in_stdout(self, rw_dir):
r.git.commit(message="init")
self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n")

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

0 comments on commit 16c2a43

Please sign in to comment.