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

Commitca965ec

Browse files
authored
Merge pull request#1609 from Beuc/block-insecure-options-clone-non-multi
Block insecure non-multi options in clone/clone_from
2 parentsc09a71e +5c59e0d commitca965ec

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

‎git/repo/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,8 @@ def _clone(
12031203

12041204
ifnotallow_unsafe_protocols:
12051205
Git.check_unsafe_protocols(str(url))
1206+
ifnotallow_unsafe_options:
1207+
Git.check_unsafe_options(options=list(kwargs.keys()),unsafe_options=cls.unsafe_git_clone_options)
12061208
ifnotallow_unsafe_optionsandmulti_options:
12071209
Git.check_unsafe_options(options=multi_options,unsafe_options=cls.unsafe_git_clone_options)
12081210

‎test/test_repo.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ def test_clone_unsafe_options(self, rw_repo):
282282
rw_repo.clone(tmp_dir,multi_options=[unsafe_option])
283283
assertnottmp_file.exists()
284284

285+
unsafe_options= [
286+
{"upload-pack":f"touch{tmp_file}"},
287+
{"u":f"touch{tmp_file}"},
288+
{"config":"protocol.ext.allow=always"},
289+
{"c":"protocol.ext.allow=always"},
290+
]
291+
forunsafe_optioninunsafe_options:
292+
withself.assertRaises(UnsafeOptionError):
293+
rw_repo.clone(tmp_dir,**unsafe_option)
294+
assertnottmp_file.exists()
295+
285296
@with_rw_repo("HEAD")
286297
deftest_clone_unsafe_options_allowed(self,rw_repo):
287298
withtempfile.TemporaryDirectory()astdir:
@@ -341,6 +352,17 @@ def test_clone_from_unsafe_options(self, rw_repo):
341352
Repo.clone_from(rw_repo.working_dir,tmp_dir,multi_options=[unsafe_option])
342353
assertnottmp_file.exists()
343354

355+
unsafe_options= [
356+
{"upload-pack":f"touch{tmp_file}"},
357+
{"u":f"touch{tmp_file}"},
358+
{"config":"protocol.ext.allow=always"},
359+
{"c":"protocol.ext.allow=always"},
360+
]
361+
forunsafe_optioninunsafe_options:
362+
withself.assertRaises(UnsafeOptionError):
363+
Repo.clone_from(rw_repo.working_dir,tmp_dir,**unsafe_option)
364+
assertnottmp_file.exists()
365+
344366
@with_rw_repo("HEAD")
345367
deftest_clone_from_unsafe_options_allowed(self,rw_repo):
346368
withtempfile.TemporaryDirectory()astdir:
@@ -1410,4 +1432,4 @@ def test_ignored_raises_error_w_symlink(self):
14101432
os.symlink(tmp_dir/"target",tmp_dir/"symlink")
14111433

14121434
withpytest.raises(GitCommandError):
1413-
temp_repo.ignored(tmp_dir/"symlink/file.txt")
1435+
temp_repo.ignored(tmp_dir/"symlink/file.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp