Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit61d1fba

Browse files
committed
Mark unsafe-options "allowed" tests xfail on Windows
The tests of unsafe options are among those introduced originallyin#1521. They are regression tests for#1515 (CVE-2022-24439).The unsafe options tests are paired: a test for the usual, defaultbehavior of forbidding the option, and a test for the behavior whenthe option is explicitly allowed. In each such pair, both tests usea payload that is intended to produce the side effect of a file ofa specific name being created in a temporary directory.All the tests work on Unix-like systems. On Windows, the tests ofthe *allowed* cases are broken, and this commit marks them xfail.However, this has implications for the tests of the default, securebehavior, because until the "allowed" versions work on Windows, itwill be unclear if either are using a payload that is effective andthat corresponds to the way its effect is examined.What *seems* to happen is this: The "\" characters in the path aretreated as shell escape characters rather than literally, with theeffect of disappearing in most paths since most letters lackspecial meaning when escaped. Also, "touch" is not a native Windowscommand, and the "touch" command provided by Git for Windows islinked against MSYS2 libraries, causing it to map (some?)occurrences of ":" in filenames to a separate code point in thePrivate Use Area of the Basic Multilingual Plane. The result is apath with no directory separators or drive letter. It denotes afile of an unintended name in the current directory, which is neverthe intended location. The current directory depends on GitPythonimplementation details, but at present it's the top-level directoryof the rw_repo working tree. A new unstaged file, named like"C\357\200\272UsersekAppDataLocalTemptmpc7x4xik5pwn", can beobserved 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 dependenton OS. So the fix is *probably* fully working on Windows as well.
1 parentb284ad7 commit61d1fba

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

‎test/test_remote.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,15 @@ def test_fetch_unsafe_options(self, rw_repo):
831831
remote.fetch(**unsafe_option)
832832
assertnottmp_file.exists()
833833

834+
@pytest.mark.xfail(
835+
os.name=="nt",
836+
reason=(
837+
"File not created. A separate Windows command may be needed. This and the "
838+
"currently passing test test_fetch_unsafe_options must be adjusted in the "
839+
"same way. Until then, test_fetch_unsafe_options is unreliable on Windows."
840+
),
841+
raises=AssertionError,
842+
)
834843
@with_rw_repo("HEAD")
835844
deftest_fetch_unsafe_options_allowed(self,rw_repo):
836845
withtempfile.TemporaryDirectory()astdir:
@@ -890,6 +899,15 @@ def test_pull_unsafe_options(self, rw_repo):
890899
remote.pull(**unsafe_option)
891900
assertnottmp_file.exists()
892901

902+
@pytest.mark.xfail(
903+
os.name=="nt",
904+
reason=(
905+
"File not created. A separate Windows command may be needed. This and the "
906+
"currently passing test test_pull_unsafe_options must be adjusted in the "
907+
"same way. Until then, test_pull_unsafe_options is unreliable on Windows."
908+
),
909+
raises=AssertionError,
910+
)
893911
@with_rw_repo("HEAD")
894912
deftest_pull_unsafe_options_allowed(self,rw_repo):
895913
withtempfile.TemporaryDirectory()astdir:
@@ -955,6 +973,15 @@ def test_push_unsafe_options(self, rw_repo):
955973
remote.push(**unsafe_option)
956974
assertnottmp_file.exists()
957975

976+
@pytest.mark.xfail(
977+
os.name=="nt",
978+
reason=(
979+
"File not created. A separate Windows command may be needed. This and the "
980+
"currently passing test test_push_unsafe_options must be adjusted in the "
981+
"same way. Until then, test_push_unsafe_options is unreliable on Windows."
982+
),
983+
raises=AssertionError,
984+
)
958985
@with_rw_repo("HEAD")
959986
deftest_push_unsafe_options_allowed(self,rw_repo):
960987
withtempfile.TemporaryDirectory()astdir:

‎test/test_repo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ def test_clone_unsafe_options(self, rw_repo):
294294
rw_repo.clone(tmp_dir,**unsafe_option)
295295
assertnottmp_file.exists()
296296

297+
@pytest.mark.xfail(
298+
os.name=="nt",
299+
reason=(
300+
"File not created. A separate Windows command may be needed. This and the "
301+
"currently passing test test_clone_unsafe_options must be adjusted in the "
302+
"same way. Until then, test_clone_unsafe_options is unreliable on Windows."
303+
),
304+
raises=AssertionError,
305+
)
297306
@with_rw_repo("HEAD")
298307
deftest_clone_unsafe_options_allowed(self,rw_repo):
299308
withtempfile.TemporaryDirectory()astdir:
@@ -364,6 +373,15 @@ def test_clone_from_unsafe_options(self, rw_repo):
364373
Repo.clone_from(rw_repo.working_dir,tmp_dir,**unsafe_option)
365374
assertnottmp_file.exists()
366375

376+
@pytest.mark.xfail(
377+
os.name=="nt",
378+
reason=(
379+
"File not created. A separate Windows command may be needed. This and the "
380+
"currently passing test test_clone_from_unsafe_options must be adjusted in the "
381+
"same way. Until then, test_clone_from_unsafe_options is unreliable on Windows."
382+
),
383+
raises=AssertionError,
384+
)
367385
@with_rw_repo("HEAD")
368386
deftest_clone_from_unsafe_options_allowed(self,rw_repo):
369387
withtempfile.TemporaryDirectory()astdir:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp