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

Commitf4f2658

Browse files
committed
Updates from review
1 parent9dc4392 commitf4f2658

File tree

4 files changed

+110
-17
lines changed

4 files changed

+110
-17
lines changed

‎AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ Contributors are:
5050
-Patrick Gerard
5151
-Luke Twist <itsluketwist@gmail.com>
5252
-Joseph Hale <me _at_ jhale.dev>
53+
-Santos Gallegos <stsewd _at_ proton.me>
5354
Portions derived from other open source works and are clearly marked.

‎test/test_remote.py

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -694,91 +694,115 @@ def test_push_error(self, repo):
694694

695695
@with_rw_repo("HEAD")
696696
deftest_set_unsafe_url(self,rw_repo):
697+
tmp_dir=Path(tempfile.mkdtemp())
698+
tmp_file=tmp_dir/"pwn"
697699
remote=rw_repo.remote("origin")
698700
urls= [
699-
"ext::sh -c touch%/tmp/pwn",
701+
f"ext::sh -c touch%{tmp_file}",
700702
"fd::17/foo",
701703
]
702704
forurlinurls:
703705
withself.assertRaises(UnsafeProtocolError):
704706
remote.set_url(url)
707+
assertnottmp_file.exists()
705708

706709
@with_rw_repo("HEAD")
707710
deftest_set_unsafe_url_allowed(self,rw_repo):
711+
tmp_dir=Path(tempfile.mkdtemp())
712+
tmp_file=tmp_dir/"pwn"
708713
remote=rw_repo.remote("origin")
709714
urls= [
710-
"ext::sh -c touch%/tmp/pwn",
715+
f"ext::sh -c touch%{tmp_file}",
711716
"fd::17/foo",
712717
]
713718
forurlinurls:
714719
remote.set_url(url,allow_unsafe_protocols=True)
715720
assertlist(remote.urls)[-1]==url
721+
assertnottmp_file.exists()
716722

717723
@with_rw_repo("HEAD")
718724
deftest_add_unsafe_url(self,rw_repo):
725+
tmp_dir=Path(tempfile.mkdtemp())
726+
tmp_file=tmp_dir/"pwn"
719727
remote=rw_repo.remote("origin")
720728
urls= [
721-
"ext::sh -c touch%/tmp/pwn",
729+
f"ext::sh -c touch%{tmp_file}",
722730
"fd::17/foo",
723731
]
724732
forurlinurls:
725733
withself.assertRaises(UnsafeProtocolError):
726734
remote.add_url(url)
735+
assertnottmp_file.exists()
727736

728737
@with_rw_repo("HEAD")
729738
deftest_add_unsafe_url_allowed(self,rw_repo):
739+
tmp_dir=Path(tempfile.mkdtemp())
740+
tmp_file=tmp_dir/"pwn"
730741
remote=rw_repo.remote("origin")
731742
urls= [
732-
"ext::sh -c touch%/tmp/pwn",
743+
f"ext::sh -c touch%{tmp_file}",
733744
"fd::17/foo",
734745
]
735746
forurlinurls:
736747
remote.add_url(url,allow_unsafe_protocols=True)
737748
assertlist(remote.urls)[-1]==url
749+
assertnottmp_file.exists()
738750

739751
@with_rw_repo("HEAD")
740752
deftest_create_remote_unsafe_url(self,rw_repo):
753+
tmp_dir=Path(tempfile.mkdtemp())
754+
tmp_file=tmp_dir/"pwn"
741755
urls= [
742-
"ext::sh -c touch%/tmp/pwn",
756+
f"ext::sh -c touch%{tmp_file}",
743757
"fd::17/foo",
744758
]
745759
forurlinurls:
746760
withself.assertRaises(UnsafeProtocolError):
747761
Remote.create(rw_repo,"origin",url)
762+
assertnottmp_file.exists()
748763

749764
@with_rw_repo("HEAD")
750765
deftest_create_remote_unsafe_url_allowed(self,rw_repo):
766+
tmp_dir=Path(tempfile.mkdtemp())
767+
tmp_file=tmp_dir/"pwn"
751768
urls= [
752-
"ext::sh -c touch%/tmp/pwn",
769+
f"ext::sh -c touch%{tmp_file}",
753770
"fd::17/foo",
754771
]
755772
fori,urlinenumerate(urls):
756773
remote=Remote.create(rw_repo,f"origin{i}",url,allow_unsafe_protocols=True)
757774
assertremote.url==url
775+
assertnottmp_file.exists()
758776

759777
@with_rw_repo("HEAD")
760778
deftest_fetch_unsafe_url(self,rw_repo):
779+
tmp_dir=Path(tempfile.mkdtemp())
780+
tmp_file=tmp_dir/"pwn"
761781
remote=rw_repo.remote("origin")
762782
urls= [
763-
"ext::sh -c touch%/tmp/pwn",
783+
f"ext::sh -c touch%{tmp_file}",
764784
"fd::17/foo",
765785
]
766786
forurlinurls:
767787
withself.assertRaises(UnsafeProtocolError):
768788
remote.fetch(url)
789+
assertnottmp_file.exists()
769790

770791
@with_rw_repo("HEAD")
771792
deftest_fetch_unsafe_url_allowed(self,rw_repo):
793+
tmp_dir=Path(tempfile.mkdtemp())
794+
tmp_file=tmp_dir/"pwn"
772795
remote=rw_repo.remote("origin")
773796
urls= [
774-
"ext::sh -c touch%/tmp/pwn",
797+
f"ext::sh -c touch%{tmp_file}",
775798
"fd::17/foo",
776799
]
777800
forurlinurls:
778801
# The URL will be allowed into the command, but the command will
779802
# fail since we don't have that protocol enabled in the Git config file.
780803
withself.assertRaises(GitCommandError):
781804
remote.fetch(url,allow_unsafe_protocols=True)
805+
assertnottmp_file.exists()
782806

783807
@with_rw_repo("HEAD")
784808
deftest_fetch_unsafe_options(self,rw_repo):
@@ -789,6 +813,7 @@ def test_fetch_unsafe_options(self, rw_repo):
789813
forunsafe_optioninunsafe_options:
790814
withself.assertRaises(UnsafeOptionError):
791815
remote.fetch(**unsafe_option)
816+
assertnottmp_file.exists()
792817

793818
@with_rw_repo("HEAD")
794819
deftest_fetch_unsafe_options_allowed(self,rw_repo):
@@ -798,32 +823,40 @@ def test_fetch_unsafe_options_allowed(self, rw_repo):
798823
unsafe_options= [{"upload-pack":f"touch{tmp_file}"}]
799824
forunsafe_optioninunsafe_options:
800825
# The options will be allowed, but the command will fail.
826+
assertnottmp_file.exists()
801827
withself.assertRaises(GitCommandError):
802828
remote.fetch(**unsafe_option,allow_unsafe_options=True)
829+
asserttmp_file.exists()
803830

804831
@with_rw_repo("HEAD")
805832
deftest_pull_unsafe_url(self,rw_repo):
833+
tmp_dir=Path(tempfile.mkdtemp())
834+
tmp_file=tmp_dir/"pwn"
806835
remote=rw_repo.remote("origin")
807836
urls= [
808-
"ext::sh -c touch%/tmp/pwn",
837+
f"ext::sh -c touch%{tmp_file}",
809838
"fd::17/foo",
810839
]
811840
forurlinurls:
812841
withself.assertRaises(UnsafeProtocolError):
813842
remote.pull(url)
843+
assertnottmp_file.exists()
814844

815845
@with_rw_repo("HEAD")
816846
deftest_pull_unsafe_url_allowed(self,rw_repo):
847+
tmp_dir=Path(tempfile.mkdtemp())
848+
tmp_file=tmp_dir/"pwn"
817849
remote=rw_repo.remote("origin")
818850
urls= [
819-
"ext::sh -c touch%/tmp/pwn",
851+
f"ext::sh -c touch%{tmp_file}",
820852
"fd::17/foo",
821853
]
822854
forurlinurls:
823855
# The URL will be allowed into the command, but the command will
824856
# fail since we don't have that protocol enabled in the Git config file.
825857
withself.assertRaises(GitCommandError):
826858
remote.pull(url,allow_unsafe_protocols=True)
859+
assertnottmp_file.exists()
827860

828861
@with_rw_repo("HEAD")
829862
deftest_pull_unsafe_options(self,rw_repo):
@@ -834,6 +867,7 @@ def test_pull_unsafe_options(self, rw_repo):
834867
forunsafe_optioninunsafe_options:
835868
withself.assertRaises(UnsafeOptionError):
836869
remote.pull(**unsafe_option)
870+
assertnottmp_file.exists()
837871

838872
@with_rw_repo("HEAD")
839873
deftest_pull_unsafe_options_allowed(self,rw_repo):
@@ -843,32 +877,40 @@ def test_pull_unsafe_options_allowed(self, rw_repo):
843877
unsafe_options= [{"upload-pack":f"touch{tmp_file}"}]
844878
forunsafe_optioninunsafe_options:
845879
# The options will be allowed, but the command will fail.
880+
assertnottmp_file.exists()
846881
withself.assertRaises(GitCommandError):
847882
remote.pull(**unsafe_option,allow_unsafe_options=True)
883+
asserttmp_file.exists()
848884

849885
@with_rw_repo("HEAD")
850886
deftest_push_unsafe_url(self,rw_repo):
887+
tmp_dir=Path(tempfile.mkdtemp())
888+
tmp_file=tmp_dir/"pwn"
851889
remote=rw_repo.remote("origin")
852890
urls= [
853-
"ext::sh -c touch%/tmp/pwn",
891+
f"ext::sh -c touch%{tmp_file}",
854892
"fd::17/foo",
855893
]
856894
forurlinurls:
857895
withself.assertRaises(UnsafeProtocolError):
858896
remote.push(url)
897+
assertnottmp_file.exists()
859898

860899
@with_rw_repo("HEAD")
861900
deftest_push_unsafe_url_allowed(self,rw_repo):
901+
tmp_dir=Path(tempfile.mkdtemp())
902+
tmp_file=tmp_dir/"pwn"
862903
remote=rw_repo.remote("origin")
863904
urls= [
864-
"ext::sh -c touch%/tmp/pwn",
905+
f"ext::sh -c touch%{tmp_file}",
865906
"fd::17/foo",
866907
]
867908
forurlinurls:
868909
# The URL will be allowed into the command, but the command will
869910
# fail since we don't have that protocol enabled in the Git config file.
870911
withself.assertRaises(GitCommandError):
871912
remote.push(url,allow_unsafe_protocols=True)
913+
assertnottmp_file.exists()
872914

873915
@with_rw_repo("HEAD")
874916
deftest_push_unsafe_options(self,rw_repo):
@@ -882,8 +924,10 @@ def test_push_unsafe_options(self, rw_repo):
882924
}
883925
]
884926
forunsafe_optioninunsafe_options:
927+
assertnottmp_file.exists()
885928
withself.assertRaises(UnsafeOptionError):
886929
remote.push(**unsafe_option)
930+
assertnottmp_file.exists()
887931

888932
@with_rw_repo("HEAD")
889933
deftest_push_unsafe_options_allowed(self,rw_repo):
@@ -898,8 +942,11 @@ def test_push_unsafe_options_allowed(self, rw_repo):
898942
]
899943
forunsafe_optioninunsafe_options:
900944
# The options will be allowed, but the command will fail.
945+
assertnottmp_file.exists()
901946
withself.assertRaises(GitCommandError):
902947
remote.push(**unsafe_option,allow_unsafe_options=True)
948+
asserttmp_file.exists()
949+
tmp_file.unlink()
903950

904951

905952
classTestTimeouts(TestBase):

‎test/test_repo.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def test_clone_unsafe_options(self, rw_repo):
279279
forunsafe_optioninunsafe_options:
280280
withself.assertRaises(UnsafeOptionError):
281281
rw_repo.clone(tmp_dir,multi_options=[unsafe_option])
282+
assertnottmp_file.exists()
282283

283284
@with_rw_repo("HEAD")
284285
deftest_clone_unsafe_options_allowed(self,rw_repo):
@@ -290,9 +291,12 @@ def test_clone_unsafe_options_allowed(self, rw_repo):
290291
]
291292
fori,unsafe_optioninenumerate(unsafe_options):
292293
destination=tmp_dir/str(i)
294+
assertnottmp_file.exists()
293295
# The options will be allowed, but the command will fail.
294296
withself.assertRaises(GitCommandError):
295297
rw_repo.clone(destination,multi_options=[unsafe_option],allow_unsafe_options=True)
298+
asserttmp_file.exists()
299+
tmp_file.unlink()
296300

297301
unsafe_options= [
298302
"--config=protocol.ext.allow=always",
@@ -331,6 +335,7 @@ def test_clone_from_unsafe_options(self, rw_repo):
331335
forunsafe_optioninunsafe_options:
332336
withself.assertRaises(UnsafeOptionError):
333337
Repo.clone_from(rw_repo.working_dir,tmp_dir,multi_options=[unsafe_option])
338+
assertnottmp_file.exists()
334339

335340
@with_rw_repo("HEAD")
336341
deftest_clone_from_unsafe_options_allowed(self,rw_repo):
@@ -342,11 +347,14 @@ def test_clone_from_unsafe_options_allowed(self, rw_repo):
342347
]
343348
fori,unsafe_optioninenumerate(unsafe_options):
344349
destination=tmp_dir/str(i)
350+
assertnottmp_file.exists()
345351
# The options will be allowed, but the command will fail.
346352
withself.assertRaises(GitCommandError):
347353
Repo.clone_from(
348354
rw_repo.working_dir,destination,multi_options=[unsafe_option],allow_unsafe_options=True
349355
)
356+
asserttmp_file.exists()
357+
tmp_file.unlink()
350358

351359
unsafe_options= [
352360
"--config=protocol.ext.allow=always",
@@ -374,16 +382,19 @@ def test_clone_from_safe_options(self, rw_repo):
374382

375383
deftest_clone_from_unsafe_procol(self):
376384
tmp_dir=pathlib.Path(tempfile.mkdtemp())
385+
tmp_file=tmp_dir/"pwn"
377386
urls= [
378-
"ext::sh -c touch%/tmp/pwn",
387+
f"ext::sh -c touch%{tmp_file}",
379388
"fd::17/foo",
380389
]
381390
forurlinurls:
382391
withself.assertRaises(UnsafeProtocolError):
383392
Repo.clone_from(url,tmp_dir)
393+
assertnottmp_file.exists()
384394

385395
deftest_clone_from_unsafe_procol_allowed(self):
386396
tmp_dir=pathlib.Path(tempfile.mkdtemp())
397+
tmp_file=tmp_dir/"pwn"
387398
urls= [
388399
"ext::sh -c touch% /tmp/pwn",
389400
"fd::/foo",
@@ -393,6 +404,7 @@ def test_clone_from_unsafe_procol_allowed(self):
393404
# fail since we don't have that protocol enabled in the Git config file.
394405
withself.assertRaises(GitCommandError):
395406
Repo.clone_from(url,tmp_dir,allow_unsafe_protocols=True)
407+
assertnottmp_file.exists()
396408

397409
@with_rw_repo("HEAD")
398410
deftest_max_chunk_size(self,repo):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp