| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,4 +50,5 @@ Contributors are: | |||
| 50 | 50 | -Patrick Gerard | |
| 51 | 51 | -Luke Twist <itsluketwist@gmail.com> | |
| 52 | 52 | -Joseph Hale <me _at_ jhale.dev> | |
| 53 | + -Santos Gallegos <stsewd _at_ proton.me> | ||
| 53 | 54 | Portions derived from other open source works and are clearly marked. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -694,91 +694,115 @@ def test_push_error(self, repo): | |||
| 694 | 694 | ||
| 695 | 695 | @with_rw_repo("HEAD") | |
| 696 | 696 | def test_set_unsafe_url(self, rw_repo): | |
| 697 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 698 | + tmp_file = tmp_dir / "pwn" | ||
| 697 | 699 | remote = rw_repo.remote("origin") | |
| 698 | 700 | urls = [ | |
| 699 | - "ext::sh -c touch% /tmp/pwn", | ||
| 701 | + f"ext::sh -c touch% {tmp_file}", | ||
| 700 | 702 | "fd::17/foo", | |
| 701 | 703 | ] | |
| 702 | 704 | for url in urls: | |
| 703 | 705 | with self.assertRaises(UnsafeProtocolError): | |
| 704 | 706 | remote.set_url(url) | |
| 707 | + assert not tmp_file.exists() | ||
| 705 | 708 | ||
| 706 | 709 | @with_rw_repo("HEAD") | |
| 707 | 710 | def test_set_unsafe_url_allowed(self, rw_repo): | |
| 711 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 712 | + tmp_file = tmp_dir / "pwn" | ||
| 708 | 713 | remote = rw_repo.remote("origin") | |
| 709 | 714 | urls = [ | |
| 710 | - "ext::sh -c touch% /tmp/pwn", | ||
| 715 | + f"ext::sh -c touch% {tmp_file}", | ||
| 711 | 716 | "fd::17/foo", | |
| 712 | 717 | ] | |
| 713 | 718 | for url in urls: | |
| 714 | 719 | remote.set_url(url, allow_unsafe_protocols=True) | |
| 715 | 720 | assert list(remote.urls)[-1] == url | |
| 721 | + assert not tmp_file.exists() | ||
| 716 | 722 | ||
| 717 | 723 | @with_rw_repo("HEAD") | |
| 718 | 724 | def test_add_unsafe_url(self, rw_repo): | |
| 725 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 726 | + tmp_file = tmp_dir / "pwn" | ||
| 719 | 727 | remote = rw_repo.remote("origin") | |
| 720 | 728 | urls = [ | |
| 721 | - "ext::sh -c touch% /tmp/pwn", | ||
| 729 | + f"ext::sh -c touch% {tmp_file}", | ||
| 722 | 730 | "fd::17/foo", | |
| 723 | 731 | ] | |
| 724 | 732 | for url in urls: | |
| 725 | 733 | with self.assertRaises(UnsafeProtocolError): | |
| 726 | 734 | remote.add_url(url) | |
| 735 | + assert not tmp_file.exists() | ||
| 727 | 736 | ||
| 728 | 737 | @with_rw_repo("HEAD") | |
| 729 | 738 | def test_add_unsafe_url_allowed(self, rw_repo): | |
| 739 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 740 | + tmp_file = tmp_dir / "pwn" | ||
| 730 | 741 | remote = rw_repo.remote("origin") | |
| 731 | 742 | urls = [ | |
| 732 | - "ext::sh -c touch% /tmp/pwn", | ||
| 743 | + f"ext::sh -c touch% {tmp_file}", | ||
| 733 | 744 | "fd::17/foo", | |
| 734 | 745 | ] | |
| 735 | 746 | for url in urls: | |
| 736 | 747 | remote.add_url(url, allow_unsafe_protocols=True) | |
| 737 | 748 | assert list(remote.urls)[-1] == url | |
| 749 | + assert not tmp_file.exists() | ||
| 738 | 750 | ||
| 739 | 751 | @with_rw_repo("HEAD") | |
| 740 | 752 | def test_create_remote_unsafe_url(self, rw_repo): | |
| 753 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 754 | + tmp_file = tmp_dir / "pwn" | ||
| 741 | 755 | urls = [ | |
| 742 | - "ext::sh -c touch% /tmp/pwn", | ||
| 756 | + f"ext::sh -c touch% {tmp_file}", | ||
| 743 | 757 | "fd::17/foo", | |
| 744 | 758 | ] | |
| 745 | 759 | for url in urls: | |
| 746 | 760 | with self.assertRaises(UnsafeProtocolError): | |
| 747 | 761 | Remote.create(rw_repo, "origin", url) | |
| 762 | + assert not tmp_file.exists() | ||
| 748 | 763 | ||
| 749 | 764 | @with_rw_repo("HEAD") | |
| 750 | 765 | def test_create_remote_unsafe_url_allowed(self, rw_repo): | |
| 766 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 767 | + tmp_file = tmp_dir / "pwn" | ||
| 751 | 768 | urls = [ | |
| 752 | - "ext::sh -c touch% /tmp/pwn", | ||
| 769 | + f"ext::sh -c touch% {tmp_file}", | ||
| 753 | 770 | "fd::17/foo", | |
| 754 | 771 | ] | |
| 755 | 772 | for i, url in enumerate(urls): | |
| 756 | 773 | remote = Remote.create(rw_repo, f"origin{i}", url, allow_unsafe_protocols=True) | |
| 757 | 774 | assert remote.url == url | |
| 775 | + assert not tmp_file.exists() | ||
| 758 | 776 | ||
| 759 | 777 | @with_rw_repo("HEAD") | |
| 760 | 778 | def test_fetch_unsafe_url(self, rw_repo): | |
| 779 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 780 | + tmp_file = tmp_dir / "pwn" | ||
| 761 | 781 | remote = rw_repo.remote("origin") | |
| 762 | 782 | urls = [ | |
| 763 | - "ext::sh -c touch% /tmp/pwn", | ||
| 783 | + f"ext::sh -c touch% {tmp_file}", | ||
| 764 | 784 | "fd::17/foo", | |
| 765 | 785 | ] | |
| 766 | 786 | for url in urls: | |
| 767 | 787 | with self.assertRaises(UnsafeProtocolError): | |
| 768 | 788 | remote.fetch(url) | |
| 789 | + assert not tmp_file.exists() | ||
| 769 | 790 | ||
| 770 | 791 | @with_rw_repo("HEAD") | |
| 771 | 792 | def test_fetch_unsafe_url_allowed(self, rw_repo): | |
| 793 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 794 | + tmp_file = tmp_dir / "pwn" | ||
| 772 | 795 | remote = rw_repo.remote("origin") | |
| 773 | 796 | urls = [ | |
| 774 | - "ext::sh -c touch% /tmp/pwn", | ||
| 797 | + f"ext::sh -c touch% {tmp_file}", | ||
| 775 | 798 | "fd::17/foo", | |
| 776 | 799 | ] | |
| 777 | 800 | for url in urls: | |
| 778 | 801 | # The URL will be allowed into the command, but the command will | |
| 779 | 802 | # fail since we don't have that protocol enabled in the Git config file. | |
| 780 | 803 | with self.assertRaises(GitCommandError): | |
| 781 | 804 | remote.fetch(url, allow_unsafe_protocols=True) | |
| 805 | + assert not tmp_file.exists() | ||
| 782 | 806 | ||
| 783 | 807 | @with_rw_repo("HEAD") | |
| 784 | 808 | def test_fetch_unsafe_options(self, rw_repo): | |
@@ -789,6 +813,7 @@ def test_fetch_unsafe_options(self, rw_repo): | |||
| 789 | 813 | for unsafe_option in unsafe_options: | |
| 790 | 814 | with self.assertRaises(UnsafeOptionError): | |
| 791 | 815 | remote.fetch(**unsafe_option) | |
| 816 | + assert not tmp_file.exists() | ||
| 792 | 817 | ||
| 793 | 818 | @with_rw_repo("HEAD") | |
| 794 | 819 | def test_fetch_unsafe_options_allowed(self, rw_repo): | |
@@ -798,32 +823,40 @@ def test_fetch_unsafe_options_allowed(self, rw_repo): | |||
| 798 | 823 | unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | |
| 799 | 824 | for unsafe_option in unsafe_options: | |
| 800 | 825 | # The options will be allowed, but the command will fail. | |
| 826 | + assert not tmp_file.exists() | ||
| 801 | 827 | with self.assertRaises(GitCommandError): | |
| 802 | 828 | remote.fetch(**unsafe_option, allow_unsafe_options=True) | |
| 829 | + assert tmp_file.exists() | ||
| 803 | 830 | ||
| 804 | 831 | @with_rw_repo("HEAD") | |
| 805 | 832 | def test_pull_unsafe_url(self, rw_repo): | |
| 833 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 834 | + tmp_file = tmp_dir / "pwn" | ||
| 806 | 835 | remote = rw_repo.remote("origin") | |
| 807 | 836 | urls = [ | |
| 808 | - "ext::sh -c touch% /tmp/pwn", | ||
| 837 | + f"ext::sh -c touch% {tmp_file}", | ||
| 809 | 838 | "fd::17/foo", | |
| 810 | 839 | ] | |
| 811 | 840 | for url in urls: | |
| 812 | 841 | with self.assertRaises(UnsafeProtocolError): | |
| 813 | 842 | remote.pull(url) | |
| 843 | + assert not tmp_file.exists() | ||
| 814 | 844 | ||
| 815 | 845 | @with_rw_repo("HEAD") | |
| 816 | 846 | def test_pull_unsafe_url_allowed(self, rw_repo): | |
| 847 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 848 | + tmp_file = tmp_dir / "pwn" | ||
| 817 | 849 | remote = rw_repo.remote("origin") | |
| 818 | 850 | urls = [ | |
| 819 | - "ext::sh -c touch% /tmp/pwn", | ||
| 851 | + f"ext::sh -c touch% {tmp_file}", | ||
| 820 | 852 | "fd::17/foo", | |
| 821 | 853 | ] | |
| 822 | 854 | for url in urls: | |
| 823 | 855 | # The URL will be allowed into the command, but the command will | |
| 824 | 856 | # fail since we don't have that protocol enabled in the Git config file. | |
| 825 | 857 | with self.assertRaises(GitCommandError): | |
| 826 | 858 | remote.pull(url, allow_unsafe_protocols=True) | |
| 859 | + assert not tmp_file.exists() | ||
| 827 | 860 | ||
| 828 | 861 | @with_rw_repo("HEAD") | |
| 829 | 862 | def test_pull_unsafe_options(self, rw_repo): | |
@@ -834,6 +867,7 @@ def test_pull_unsafe_options(self, rw_repo): | |||
| 834 | 867 | for unsafe_option in unsafe_options: | |
| 835 | 868 | with self.assertRaises(UnsafeOptionError): | |
| 836 | 869 | remote.pull(**unsafe_option) | |
| 870 | + assert not tmp_file.exists() | ||
| 837 | 871 | ||
| 838 | 872 | @with_rw_repo("HEAD") | |
| 839 | 873 | def test_pull_unsafe_options_allowed(self, rw_repo): | |
@@ -843,32 +877,40 @@ def test_pull_unsafe_options_allowed(self, rw_repo): | |||
| 843 | 877 | unsafe_options = [{"upload-pack": f"touch {tmp_file}"}] | |
| 844 | 878 | for unsafe_option in unsafe_options: | |
| 845 | 879 | # The options will be allowed, but the command will fail. | |
| 880 | + assert not tmp_file.exists() | ||
| 846 | 881 | with self.assertRaises(GitCommandError): | |
| 847 | 882 | remote.pull(**unsafe_option, allow_unsafe_options=True) | |
| 883 | + assert tmp_file.exists() | ||
| 848 | 884 | ||
| 849 | 885 | @with_rw_repo("HEAD") | |
| 850 | 886 | def test_push_unsafe_url(self, rw_repo): | |
| 887 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 888 | + tmp_file = tmp_dir / "pwn" | ||
| 851 | 889 | remote = rw_repo.remote("origin") | |
| 852 | 890 | urls = [ | |
| 853 | - "ext::sh -c touch% /tmp/pwn", | ||
| 891 | + f"ext::sh -c touch% {tmp_file}", | ||
| 854 | 892 | "fd::17/foo", | |
| 855 | 893 | ] | |
| 856 | 894 | for url in urls: | |
| 857 | 895 | with self.assertRaises(UnsafeProtocolError): | |
| 858 | 896 | remote.push(url) | |
| 897 | + assert not tmp_file.exists() | ||
| 859 | 898 | ||
| 860 | 899 | @with_rw_repo("HEAD") | |
| 861 | 900 | def test_push_unsafe_url_allowed(self, rw_repo): | |
| 901 | + tmp_dir = Path(tempfile.mkdtemp()) | ||
| 902 | + tmp_file = tmp_dir / "pwn" | ||
| 862 | 903 | remote = rw_repo.remote("origin") | |
| 863 | 904 | urls = [ | |
| 864 | - "ext::sh -c touch% /tmp/pwn", | ||
| 905 | + f"ext::sh -c touch% {tmp_file}", | ||
| 865 | 906 | "fd::17/foo", | |
| 866 | 907 | ] | |
| 867 | 908 | for url in urls: | |
| 868 | 909 | # The URL will be allowed into the command, but the command will | |
| 869 | 910 | # fail since we don't have that protocol enabled in the Git config file. | |
| 870 | 911 | with self.assertRaises(GitCommandError): | |
| 871 | 912 | remote.push(url, allow_unsafe_protocols=True) | |
| 913 | + assert not tmp_file.exists() | ||
| 872 | 914 | ||
| 873 | 915 | @with_rw_repo("HEAD") | |
| 874 | 916 | def test_push_unsafe_options(self, rw_repo): | |
@@ -882,8 +924,10 @@ def test_push_unsafe_options(self, rw_repo): | |||
| 882 | 924 | } | |
| 883 | 925 | ] | |
| 884 | 926 | for unsafe_option in unsafe_options: | |
| 927 | + assert not tmp_file.exists() | ||
| 885 | 928 | with self.assertRaises(UnsafeOptionError): | |
| 886 | 929 | remote.push(**unsafe_option) | |
| 930 | + assert not tmp_file.exists() | ||
| 887 | 931 | ||
| 888 | 932 | @with_rw_repo("HEAD") | |
| 889 | 933 | def test_push_unsafe_options_allowed(self, rw_repo): | |
@@ -898,8 +942,11 @@ def test_push_unsafe_options_allowed(self, rw_repo): | |||
| 898 | 942 | ] | |
| 899 | 943 | for unsafe_option in unsafe_options: | |
| 900 | 944 | # The options will be allowed, but the command will fail. | |
| 945 | + assert not tmp_file.exists() | ||
| 901 | 946 | with self.assertRaises(GitCommandError): | |
| 902 | 947 | remote.push(**unsafe_option, allow_unsafe_options=True) | |
| 948 | + assert tmp_file.exists() | ||
| 949 | + tmp_file.unlink() | ||
| 903 | 950 | ||
| 904 | 951 | ||
| 905 | 952 | class TestTimeouts(TestBase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -279,6 +279,7 @@ def test_clone_unsafe_options(self, rw_repo): | |||
| 279 | 279 | for unsafe_option in unsafe_options: | |
| 280 | 280 | with self.assertRaises(UnsafeOptionError): | |
| 281 | 281 | rw_repo.clone(tmp_dir, multi_options=[unsafe_option]) | |
| 282 | + assert not tmp_file.exists() | ||
| 282 | 283 | ||
| 283 | 284 | @with_rw_repo("HEAD") | |
| 284 | 285 | def test_clone_unsafe_options_allowed(self, rw_repo): | |
@@ -290,9 +291,12 @@ def test_clone_unsafe_options_allowed(self, rw_repo): | |||
| 290 | 291 | ] | |
| 291 | 292 | for i, unsafe_option in enumerate(unsafe_options): | |
| 292 | 293 | destination = tmp_dir / str(i) | |
| 294 | + assert not tmp_file.exists() | ||
| 293 | 295 | # The options will be allowed, but the command will fail. | |
| 294 | 296 | with self.assertRaises(GitCommandError): | |
| 295 | 297 | rw_repo.clone(destination, multi_options=[unsafe_option], allow_unsafe_options=True) | |
| 298 | + assert tmp_file.exists() | ||
| 299 | + tmp_file.unlink() | ||
| 296 | 300 | ||
| 297 | 301 | unsafe_options = [ | |
| 298 | 302 | "--config=protocol.ext.allow=always", | |
@@ -331,6 +335,7 @@ def test_clone_from_unsafe_options(self, rw_repo): | |||
| 331 | 335 | for unsafe_option in unsafe_options: | |
| 332 | 336 | with self.assertRaises(UnsafeOptionError): | |
| 333 | 337 | Repo.clone_from(rw_repo.working_dir, tmp_dir, multi_options=[unsafe_option]) | |
| 338 | + assert not tmp_file.exists() | ||
| 334 | 339 | ||
| 335 | 340 | @with_rw_repo("HEAD") | |
| 336 | 341 | def test_clone_from_unsafe_options_allowed(self, rw_repo): | |
@@ -342,11 +347,14 @@ def test_clone_from_unsafe_options_allowed(self, rw_repo): | |||
| 342 | 347 | ] | |
| 343 | 348 | for i, unsafe_option in enumerate(unsafe_options): | |
| 344 | 349 | destination = tmp_dir / str(i) | |
| 350 | + assert not tmp_file.exists() | ||
| 345 | 351 | # The options will be allowed, but the command will fail. | |
| 346 | 352 | with self.assertRaises(GitCommandError): | |
| 347 | 353 | Repo.clone_from( | |
| 348 | 354 | rw_repo.working_dir, destination, multi_options=[unsafe_option], allow_unsafe_options=True | |
| 349 | 355 | ) | |
| 356 | + assert tmp_file.exists() | ||
| 357 | + tmp_file.unlink() | ||
| 350 | 358 | ||
| 351 | 359 | unsafe_options = [ | |
| 352 | 360 | "--config=protocol.ext.allow=always", | |
@@ -374,16 +382,19 @@ def test_clone_from_safe_options(self, rw_repo): | |||
| 374 | 382 | ||
| 375 | 383 | def test_clone_from_unsafe_procol(self): | |
| 376 | 384 | tmp_dir = pathlib.Path(tempfile.mkdtemp()) | |
| 385 | + tmp_file = tmp_dir / "pwn" | ||
| 377 | 386 | urls = [ | |
| 378 | - "ext::sh -c touch% /tmp/pwn", | ||
| 387 | + f"ext::sh -c touch% {tmp_file}", | ||
| 379 | 388 | "fd::17/foo", | |
| 380 | 389 | ] | |
| 381 | 390 | for url in urls: | |
| 382 | 391 | with self.assertRaises(UnsafeProtocolError): | |
| 383 | 392 | Repo.clone_from(url, tmp_dir) | |
| 393 | + assert not tmp_file.exists() | ||
| 384 | 394 | ||
| 385 | 395 | def test_clone_from_unsafe_procol_allowed(self): | |
| 386 | 396 | tmp_dir = pathlib.Path(tempfile.mkdtemp()) | |
| 397 | + tmp_file = tmp_dir / "pwn" | ||
| 387 | 398 | urls = [ | |
| 388 | 399 | "ext::sh -c touch% /tmp/pwn", | |
| 389 | 400 | "fd::/foo", | |
@@ -393,6 +404,7 @@ def test_clone_from_unsafe_procol_allowed(self): | |||
| 393 | 404 | # fail since we don't have that protocol enabled in the Git config file. | |
| 394 | 405 | with self.assertRaises(GitCommandError): | |
| 395 | 406 | Repo.clone_from(url, tmp_dir, allow_unsafe_protocols=True) | |
| 407 | + assert not tmp_file.exists() | ||
| 396 | 408 | ||
| 397 | 409 | @with_rw_repo("HEAD") | |
| 398 | 410 | def test_max_chunk_size(self, repo): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments