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

Block insecure non-multi options in clone/clone_from#1609

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 1 commit intogitpython-developers:mainfromBeuc:block-insecure-options-clone-non-multi
Jul 10, 2023
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: 2 additions & 0 deletionsgit/repo/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1203,6 +1203,8 @@ def _clone(

if not allow_unsafe_protocols:
Git.check_unsafe_protocols(str(url))
if not allow_unsafe_options:
Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options)
if not allow_unsafe_options and multi_options:
Git.check_unsafe_options(options=multi_options, unsafe_options=cls.unsafe_git_clone_options)

Expand Down
24 changes: 23 additions & 1 deletiontest/test_repo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -282,6 +282,17 @@ def test_clone_unsafe_options(self, rw_repo):
rw_repo.clone(tmp_dir, multi_options=[unsafe_option])
assert not tmp_file.exists()

unsafe_options = [
{"upload-pack": f"touch {tmp_file}"},
{"u": f"touch {tmp_file}"},
{"config": "protocol.ext.allow=always"},
{"c": "protocol.ext.allow=always"},
]
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
rw_repo.clone(tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@with_rw_repo("HEAD")
def test_clone_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand DownExpand Up@@ -341,6 +352,17 @@ def test_clone_from_unsafe_options(self, rw_repo):
Repo.clone_from(rw_repo.working_dir, tmp_dir, multi_options=[unsafe_option])
assert not tmp_file.exists()

unsafe_options = [
{"upload-pack": f"touch {tmp_file}"},
{"u": f"touch {tmp_file}"},
{"config": "protocol.ext.allow=always"},
{"c": "protocol.ext.allow=always"},
]
for unsafe_option in unsafe_options:
with self.assertRaises(UnsafeOptionError):
Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option)
assert not tmp_file.exists()

@with_rw_repo("HEAD")
def test_clone_from_unsafe_options_allowed(self, rw_repo):
with tempfile.TemporaryDirectory() as tdir:
Expand DownExpand Up@@ -1410,4 +1432,4 @@ def test_ignored_raises_error_w_symlink(self):
os.symlink(tmp_dir / "target", tmp_dir / "symlink")

with pytest.raises(GitCommandError):
temp_repo.ignored(tmp_dir / "symlink/file.txt")
temp_repo.ignored(tmp_dir / "symlink/file.txt")

[8]ページ先頭

©2009-2025 Movatter.jp