-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jk/transfer-limit-protocol' into maint-2.3
- Loading branch information
Showing
13 changed files
with
306 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Test routines for checking protocol disabling. | ||
|
||
# test cloning a particular protocol | ||
# $1 - description of the protocol | ||
# $2 - machine-readable name of the protocol | ||
# $3 - the URL to try cloning | ||
test_proto () { | ||
desc=$1 | ||
proto=$2 | ||
url=$3 | ||
|
||
test_expect_success "clone $1 (enabled)" ' | ||
rm -rf tmp.git && | ||
( | ||
GIT_ALLOW_PROTOCOL=$proto && | ||
export GIT_ALLOW_PROTOCOL && | ||
git clone --bare "$url" tmp.git | ||
) | ||
' | ||
|
||
test_expect_success "fetch $1 (enabled)" ' | ||
( | ||
cd tmp.git && | ||
GIT_ALLOW_PROTOCOL=$proto && | ||
export GIT_ALLOW_PROTOCOL && | ||
git fetch | ||
) | ||
' | ||
|
||
test_expect_success "push $1 (enabled)" ' | ||
( | ||
cd tmp.git && | ||
GIT_ALLOW_PROTOCOL=$proto && | ||
export GIT_ALLOW_PROTOCOL && | ||
git push origin HEAD:pushed | ||
) | ||
' | ||
|
||
test_expect_success "push $1 (disabled)" ' | ||
( | ||
cd tmp.git && | ||
GIT_ALLOW_PROTOCOL=none && | ||
export GIT_ALLOW_PROTOCOL && | ||
test_must_fail git push origin HEAD:pushed | ||
) | ||
' | ||
|
||
test_expect_success "fetch $1 (disabled)" ' | ||
( | ||
cd tmp.git && | ||
GIT_ALLOW_PROTOCOL=none && | ||
export GIT_ALLOW_PROTOCOL && | ||
test_must_fail git fetch | ||
) | ||
' | ||
|
||
test_expect_success "clone $1 (disabled)" ' | ||
rm -rf tmp.git && | ||
( | ||
GIT_ALLOW_PROTOCOL=none && | ||
export GIT_ALLOW_PROTOCOL && | ||
test_must_fail git clone --bare "$url" tmp.git | ||
) | ||
' | ||
} | ||
|
||
# set up an ssh wrapper that will access $host/$repo in the | ||
# trash directory, and enable it for subsequent tests. | ||
setup_ssh_wrapper () { | ||
test_expect_success 'setup ssh wrapper' ' | ||
write_script ssh-wrapper <<-\EOF && | ||
echo >&2 "ssh: $*" | ||
host=$1; shift | ||
cd "$TRASH_DIRECTORY/$host" && | ||
eval "$*" | ||
EOF | ||
GIT_SSH="$PWD/ssh-wrapper" && | ||
export GIT_SSH && | ||
export TRASH_DIRECTORY | ||
' | ||
} | ||
|
||
# set up a wrapper that can be used with remote-ext to | ||
# access repositories in the "remote" directory of trash-dir, | ||
# like "ext::fake-remote %S repo.git" | ||
setup_ext_wrapper () { | ||
test_expect_success 'setup ext wrapper' ' | ||
write_script fake-remote <<-\EOF && | ||
echo >&2 "fake-remote: $*" | ||
cd "$TRASH_DIRECTORY/remote" && | ||
eval "$*" | ||
EOF | ||
PATH=$TRASH_DIRECTORY:$PATH && | ||
export TRASH_DIRECTORY | ||
' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
test_description='test disabling of local paths in clone/fetch' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY/lib-proto-disable.sh" | ||
|
||
test_expect_success 'setup repository to clone' ' | ||
test_commit one | ||
' | ||
|
||
test_proto "file://" file "file://$PWD" | ||
test_proto "path" file . | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
test_description='test disabling of git-over-tcp in clone/fetch' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY/lib-proto-disable.sh" | ||
. "$TEST_DIRECTORY/lib-git-daemon.sh" | ||
start_git_daemon | ||
|
||
test_expect_success 'create git-accessible repo' ' | ||
bare="$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git" && | ||
test_commit one && | ||
git --bare init "$bare" && | ||
git push "$bare" HEAD && | ||
>"$bare/git-daemon-export-ok" && | ||
git -C "$bare" config daemon.receivepack true | ||
' | ||
|
||
test_proto "git://" git "$GIT_DAEMON_URL/repo.git" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
test_description='test disabling of git-over-http in clone/fetch' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY/lib-proto-disable.sh" | ||
. "$TEST_DIRECTORY/lib-httpd.sh" | ||
start_httpd | ||
|
||
test_expect_success 'create git-accessible repo' ' | ||
bare="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | ||
test_commit one && | ||
git --bare init "$bare" && | ||
git push "$bare" HEAD && | ||
git -C "$bare" config http.receivepack true | ||
' | ||
|
||
test_proto "smart http" http "$HTTPD_URL/smart/repo.git" | ||
|
||
stop_httpd | ||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
test_description='test disabling of git-over-ssh in clone/fetch' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY/lib-proto-disable.sh" | ||
|
||
setup_ssh_wrapper | ||
|
||
test_expect_success 'setup repository to clone' ' | ||
test_commit one && | ||
mkdir remote && | ||
git init --bare remote/repo.git && | ||
git push remote/repo.git HEAD | ||
' | ||
|
||
test_proto "host:path" ssh "remote:repo.git" | ||
test_proto "ssh://" ssh "ssh://remote/$PWD/remote/repo.git" | ||
test_proto "git+ssh://" ssh "git+ssh://remote/$PWD/remote/repo.git" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
test_description='test disabling of remote-helper paths in clone/fetch' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY/lib-proto-disable.sh" | ||
|
||
setup_ext_wrapper | ||
|
||
test_expect_success 'setup repository to clone' ' | ||
test_commit one && | ||
mkdir remote && | ||
git init --bare remote/repo.git && | ||
git push remote/repo.git HEAD | ||
' | ||
|
||
test_proto "remote-helper" ext "ext::fake-remote %S repo.git" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
test_description='test protocol whitelisting with submodules' | ||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-proto-disable.sh | ||
|
||
setup_ext_wrapper | ||
setup_ssh_wrapper | ||
|
||
test_expect_success 'setup repository with submodules' ' | ||
mkdir remote && | ||
git init remote/repo.git && | ||
(cd remote/repo.git && test_commit one) && | ||
# submodule-add should probably trust what we feed it on the cmdline, | ||
# but its implementation is overly conservative. | ||
GIT_ALLOW_PROTOCOL=ssh git submodule add remote:repo.git ssh-module && | ||
GIT_ALLOW_PROTOCOL=ext git submodule add "ext::fake-remote %S repo.git" ext-module && | ||
git commit -m "add submodules" | ||
' | ||
|
||
test_expect_success 'clone with recurse-submodules fails' ' | ||
test_must_fail git clone --recurse-submodules . dst | ||
' | ||
|
||
test_expect_success 'setup individual updates' ' | ||
rm -rf dst && | ||
git clone . dst && | ||
git -C dst submodule init | ||
' | ||
|
||
test_expect_success 'update of ssh allowed' ' | ||
git -C dst submodule update ssh-module | ||
' | ||
|
||
test_expect_success 'update of ext not allowed' ' | ||
test_must_fail git -C dst submodule update ext-module | ||
' | ||
|
||
test_expect_success 'user can override whitelist' ' | ||
GIT_ALLOW_PROTOCOL=ext git -C dst submodule update ext-module | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters