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

Commit1c65efb

Browse files
committed
Show "not from cwd" test is broken for shell=True
This adds a test_it_executes_git_not_from_cwd case for shell=True.(This case also gives the command as a string, so the test need notbe further special-cased for non-Windows systems, where argumentlists aren't accepted with shell=True.)The test did not attempt to cover the shell=True case before,because I had erroneously assumed it worked similarity. It isactually very different, because when a shell is used, both theshell and the command the shell runs must be found and executed,and because the process creation GitPython performs is that of theshell process, with the state of the shell process being what isrelevant to how the path search is done for the git (or other)command.The code change here does not itself demonstrate that the test isbroken for shell=True, because that case passes. However, manuallyundoing the fix in cmd.py forCVE-2023-40590, which as expectedcauses the preexisting (implicitly shell=False case) to fail, does*not* cause the new shell=True case to fail. That case passes!That passing result in the absence of a fix forCVE-2023-40590 iserroneous, because the cmd.exe shell does search the CWD first whennothing has been done to prevent it.
1 parent32c02d1 commit1c65efb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎test/test_git.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ def test_it_logs_istream_summary_for_stdin(self, case):
134134
deftest_it_executes_git_and_returns_result(self):
135135
self.assertRegex(self.git.execute(["git","version"]),r"^git version [\d\.]{2}.*$")
136136

137-
deftest_it_executes_git_not_from_cwd(self):
137+
@ddt.data(
138+
(["git","version"],False),
139+
("git version",True),
140+
)
141+
deftest_it_executes_git_not_from_cwd(self,case):
142+
command,shell=case
143+
138144
withTemporaryDirectory()astmpdir:
139145
ifos.name=="nt":
140146
# Copy an actual binary executable that is not git.
@@ -149,7 +155,9 @@ def test_it_executes_git_not_from_cwd(self):
149155
os.chmod(impostor_path,0o755)
150156

151157
withcwd(tmpdir):
152-
self.assertRegex(self.git.execute(["git","version"]),r"^git version\b")
158+
output=self.git.execute(command,shell=shell)
159+
160+
self.assertRegex(output,r"^git version\b")
153161

154162
@skipUnless(
155163
os.name=="nt",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp