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

Fix command injection#1518

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 3 commits intogitpython-developers:mainfromstsewd:fix-cmd-injection
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
2 changes: 1 addition & 1 deletion.github/workflows/pythonpackage.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.7.5, 3.7.12, 3.8, 3.8.0, 3.8.11, 3.8, 3.9,3.9.0, 3.9.7,"3.10"]
python-version: [3.7, 3.8, 3.9,"3.10","3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 3 additions & 2 deletionsgit/remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -964,7 +964,7 @@ def fetch(
args = [refspec]

proc = self.repo.git.fetch(
self, *args, as_process=True, with_stdout=False, universal_newlines=True, v=verbose, **kwargs
"--",self, *args, as_process=True, with_stdout=False, universal_newlines=True, v=verbose, **kwargs
)
res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
if hasattr(self.repo.odb, "update_cache"):
Expand All@@ -991,7 +991,7 @@ def pull(
self._assert_refspec()
kwargs = add_progress(kwargs, self.repo.git, progress)
proc = self.repo.git.pull(
self, refspec, with_stdout=False, as_process=True, universal_newlines=True, v=True, **kwargs
"--",self, refspec, with_stdout=False, as_process=True, universal_newlines=True, v=True, **kwargs
)
res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
if hasattr(self.repo.odb, "update_cache"):
Expand DownExpand Up@@ -1034,6 +1034,7 @@ def push(
be 0."""
kwargs = add_progress(kwargs, self.repo.git, progress)
proc = self.repo.git.push(
"--",
self,
refspec,
porcelain=True,
Expand Down
3 changes: 2 additions & 1 deletiongit/repo/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1169,6 +1169,7 @@ def _clone(
multi = shlex.split(" ".join(multi_options))
proc = git.clone(
multi,
"--",
Git.polish_url(str(url)),
clone_path,
with_extended_output=True,
Expand DownExpand Up@@ -1305,7 +1306,7 @@ def archive(
if not isinstance(path, (tuple, list)):
path = [path]
# end assure paths is list
self.git.archive(treeish, *path, **kwargs)
self.git.archive("--",treeish, *path, **kwargs)
return self

def has_separate_working_tree(self) -> bool:
Expand Down
26 changes: 26 additions & 0 deletionstest/test_repo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1180,3 +1180,29 @@ def test_do_not_strip_newline_in_stdout(self, rw_dir):
r.git.add(Git.polish_url(fp))
r.git.commit(message="init")
self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n")

@with_rw_repo("HEAD")
def test_clone_command_injection(self, rw_repo):
tmp_dir = pathlib.Path(tempfile.mkdtemp())
unexpected_file = tmp_dir / "pwn"
assert not unexpected_file.exists()

payload = f"--upload-pack=touch {unexpected_file}"
rw_repo.clone(payload)

assert not unexpected_file.exists()
# A repo was cloned with the payload as name
assert pathlib.Path(payload).exists()

@with_rw_repo("HEAD")
def test_clone_from_command_injection(self, rw_repo):
tmp_dir = pathlib.Path(tempfile.mkdtemp())
temp_repo = Repo.init(tmp_dir / "repo")
unexpected_file = tmp_dir / "pwn"

assert not unexpected_file.exists()
payload = f"--upload-pack=touch {unexpected_file}"
with self.assertRaises(GitCommandError):
rw_repo.clone_from(payload, temp_repo.common_dir)

assert not unexpected_file.exists()

[8]ページ先頭

©2009-2025 Movatter.jp