Skip to content

Test native Windows on CI #1745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2fd79f4
Add native Windows test jobs to CI matrix
EliahKagan Oct 15, 2023
6e477e3
Add xfail marks for IndexFile.from_tree failures
EliahKagan Nov 14, 2023
cd9d7a9
Mark test_clone_command_injection xfail on Windows
EliahKagan Nov 15, 2023
f72e282
Mark test_diff_submodule xfail on Windows
EliahKagan Nov 15, 2023
42a3d74
Mark TestSubmodule.test_rename xfail on Windows
EliahKagan Nov 15, 2023
4abab92
Mark test_conditional_includes_from_git_dir xfail on Windows
EliahKagan Nov 15, 2023
799c853
Improve ordering/grouping of a few imports
EliahKagan Nov 16, 2023
b284ad7
Mark test_create_remote_unsafe_url_allowed xfail on Windows
EliahKagan Nov 16, 2023
61d1fba
Mark unsafe-options "allowed" tests xfail on Windows
EliahKagan Nov 16, 2023
ad07ecb
Show PATH on CI
EliahKagan Nov 22, 2023
2784e40
Show bash and other WSL-relevant info but not PATH
EliahKagan Nov 22, 2023
9717b8d
Install WSL system on CI for hook tests
EliahKagan Nov 17, 2023
5d11394
Fix and expand bash.exe xfail marks on hook tests
EliahKagan Nov 23, 2023
b215357
Simplify/clarify bash.exe check for hook tests; do it only once
EliahKagan Nov 24, 2023
cabb572
Temporarily don't install WSL system to test xfail
EliahKagan Nov 24, 2023
2875ffa
Put back WSL on Windows CI; pare down debug info
EliahKagan Nov 24, 2023
0f8cd4c
Treat XPASS status as a test failure
EliahKagan Nov 24, 2023
82c361e
Correct TestSubmodule.test_rename xfail condition
EliahKagan Nov 24, 2023
0ae5dd1
Revert "Treat XPASS status as a test failure"
EliahKagan Nov 24, 2023
0b7ee17
Refine TestSubmodule.test_rename xfail condition
EliahKagan Nov 25, 2023
8621e89
Reword comment in _WinBashStatus.check for clarity
EliahKagan Nov 25, 2023
7ff3cee
Make _WinBashStatus instances carry all their info
EliahKagan Nov 25, 2023
d5ed266
Use bytes in bash.exe check; retest no-distro case
EliahKagan Nov 25, 2023
496acaa
Handle multiple encodings for WSL error messages
EliahKagan Nov 26, 2023
d779a75
Don't assume WSL-related bash.exe error is English
EliahKagan Nov 27, 2023
9ac2438
Handle encodings better; make the sum type "public"
EliahKagan Nov 27, 2023
b07e5c7
Put back WSL on Windows CI
EliahKagan Nov 28, 2023
3303c74
Improve readability of WinBashStatus class
EliahKagan Nov 28, 2023
e00fffc
Shorten comments on _decode steps
EliahKagan Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mark unsafe-options "allowed" tests xfail on Windows
The tests of unsafe options are among those introduced originally
in #1521. They are regression tests for #1515 (CVE-2022-24439).
The unsafe options tests are paired: a test for the usual, default
behavior of forbidding the option, and a test for the behavior when
the option is explicitly allowed. In each such pair, both tests use
a payload that is intended to produce the side effect of a file of
a specific name being created in a temporary directory.

All the tests work on Unix-like systems. On Windows, the tests of
the *allowed* cases are broken, and this commit marks them xfail.
However, this has implications for the tests of the default, secure
behavior, because until the "allowed" versions work on Windows, it
will be unclear if either are using a payload that is effective and
that corresponds to the way its effect is examined.

What *seems* to happen is this: The "\" characters in the path are
treated as shell escape characters rather than literally, with the
effect of disappearing in most paths since most letters lack
special meaning when escaped. Also, "touch" is not a native Windows
command, and the "touch" command provided by Git for Windows is
linked against MSYS2 libraries, causing it to map (some?)
occurrences of ":" in filenames to a separate code point in the
Private Use Area of the Basic Multilingual Plane. The result is a
path with no directory separators or drive letter. It denotes a
file of an unintended name in the current directory, which is never
the intended location. The current directory depends on GitPython
implementation details, but at present it's the top-level directory
of the rw_repo working tree. A new unstaged file, named like
"C\357\200\272UsersekAppDataLocalTemptmpc7x4xik5pwn", can be
observed there (this is how "git status" will format the name).

Fortunately, this and all related tests are working on other OSes,
and the affected code under test does not appear highly dependent
on OS. So the fix is *probably* fully working on Windows as well.
  • Loading branch information
EliahKagan committed Nov 24, 2023
commit 61d1fba6dd318e7f68b93b0e8b46050db0d03fa8
27 changes: 27 additions & 0 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,15 @@ def test_fetch_unsafe_options(self, rw_repo):
remote.fetch(**unsafe_option)
assert not tmp_file.exists()

@pytest.mark.xfail(
os.name == "nt",
reason=(
"File not created. A separate Windows command may be needed. This and the "
"currently passing test test_fetch_unsafe_options must be adjusted in the "
"same way. Until then, test_fetch_unsafe_options is unreliable on Windows."
),
raises=AssertionError,
)
@with_rw_repo("HEAD")
def test_fetch_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down Expand Up @@ -890,6 +899,15 @@ def test_pull_unsafe_options(self, rw_repo):
remote.pull(**unsafe_option)
assert not tmp_file.exists()

@pytest.mark.xfail(
os.name == "nt",
reason=(
"File not created. A separate Windows command may be needed. This and the "
"currently passing test test_pull_unsafe_options must be adjusted in the "
"same way. Until then, test_pull_unsafe_options is unreliable on Windows."
),
raises=AssertionError,
)
@with_rw_repo("HEAD")
def test_pull_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down Expand Up @@ -955,6 +973,15 @@ def test_push_unsafe_options(self, rw_repo):
remote.push(**unsafe_option)
assert not tmp_file.exists()

@pytest.mark.xfail(
os.name == "nt",
reason=(
"File not created. A separate Windows command may be needed. This and the "
"currently passing test test_push_unsafe_options must be adjusted in the "
"same way. Until then, test_push_unsafe_options is unreliable on Windows."
),
raises=AssertionError,
)
@with_rw_repo("HEAD")
def test_push_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down
18 changes: 18 additions & 0 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ def test_clone_unsafe_options(self, rw_repo):
rw_repo.clone(tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@pytest.mark.xfail(
os.name == "nt",
reason=(
"File not created. A separate Windows command may be needed. This and the "
"currently passing test test_clone_unsafe_options must be adjusted in the "
"same way. Until then, test_clone_unsafe_options is unreliable on Windows."
),
raises=AssertionError,
)
@with_rw_repo("HEAD")
def test_clone_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down Expand Up @@ -364,6 +373,15 @@ def test_clone_from_unsafe_options(self, rw_repo):
Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@pytest.mark.xfail(
os.name == "nt",
reason=(
"File not created. A separate Windows command may be needed. This and the "
"currently passing test test_clone_from_unsafe_options must be adjusted in the "
"same way. Until then, test_clone_from_unsafe_options is unreliable on Windows."
),
raises=AssertionError,
)
@with_rw_repo("HEAD")
def test_clone_from_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand Down