aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2018-08-17 21:25:52 -0400
committerRuss Cox <rsc@golang.org>2018-08-18 18:22:46 +0000
commit239b8f2edc70046484d5bcc5bf0cac06f8e1ace4 (patch)
tree211f84c7c7fd1538a0ce5cc653a09c42947a0d46
parent714c141c4f2db626ea470a27cfd35f86b0c77c07 (diff)
downloadgo-239b8f2edc70046484d5bcc5bf0cac06f8e1ace4.tar.gz
go-239b8f2edc70046484d5bcc5bf0cac06f8e1ace4.zip
cmd/go: fix and reenable TestAccidentalGitCheckout
This is an important security problem so we shouldn't disable the test. The second half was failing on case-sensitive file systems but the first half is still good. Fixes #22983. Change-Id: I437bb4c9f78eb3177aa8b619e2357b2539566ca9 Reviewed-on: https://go-review.googlesource.com/129797 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/cmd/go/go_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index da2dfd3bfb..ec6a72c66a 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -1291,9 +1291,9 @@ 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.SkipFlaky(t, 22983) // this test might not have ever worked; see issue.
if _, err := exec.LookPath("git"); err != nil {
t.Skip("skipping because git binary not found")
}
@@ -1302,13 +1302,17 @@ func TestAccidentalGitCheckout(t *testing.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")
- 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")
+ 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 TestErrorMessageForSyntaxErrorInTestGoFileSaysFAIL(t *testing.T) {