Skip to content

Commit

Permalink
cmd/go: convert TestAccidentalGitCheckout to a script test
Browse files Browse the repository at this point in the history
As far as I can determine, this is the only existing non-script test
that relies on vcs-test.golang.org. I am attempting to eliminate the
vcs-test server, and to keep configuration straightforward I would
like to only set up its replacement for script tests.

For #27494.

Change-Id: Ib978228b9c3f403af5f1c445e08942cbe7915b62
Reviewed-on: https://go-review.googlesource.com/c/go/+/418103
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Aug 16, 2022
1 parent bd3c35e commit a135f8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,29 +1042,6 @@ func TestGetGitDefaultBranch(t *testing.T) {
tg.grepStdout(`\* another-branch`, "not on correct default branch")
}

// Security issue. Don't disable. See golang.org/issue/22125.
func TestAccidentalGitCheckout(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
testenv.MustHaveExecPath(t, "git")
testenv.MustHaveExecPath(t, "svn")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.tempDir("src")

tg.setenv("GOPATH", tg.path("."))

tg.runFail("get", "-u", "vcs-test.golang.org/go/test1-svn-git")
tg.grepStderr("src[\\\\/]vcs-test.* uses git, but parent .*src[\\\\/]vcs-test.* uses svn", "get did not fail for right reason")

if _, err := os.Stat(tg.path("SrC")); err == nil {
// This case only triggers on a case-insensitive file system.
tg.runFail("get", "-u", "vcs-test.golang.org/go/test2-svn-git/test2main")
tg.grepStderr("src[\\\\/]vcs-test.* uses git, but parent .*src[\\\\/]vcs-test.* uses svn", "get did not fail for right reason")
}
}

func TestPackageMainTestCompilerFlags(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
Expand Down
14 changes: 14 additions & 0 deletions src/cmd/go/testdata/script/get_issue22125.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This test verifies a fix for a security issue; see https://go.dev/issue/22125.

[!net] skip
[!exec:git] skip
[!exec:svn] skip

env GO111MODULE=off

cd $GOPATH
! go get -u vcs-test.golang.org/go/test1-svn-git
stderr 'src'${/}'vcs-test.* uses git, but parent .*src'${/}'vcs-test.* uses svn'

[!case-sensitive] ! go get -u vcs-test.golang.org/go/test2-svn-git/test2main
[!case-sensitive] stderr 'src'${/}'vcs-test.* uses git, but parent .*src'${/}'vcs-test.* uses svn'

0 comments on commit a135f8e

Please sign in to comment.