-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go/internal/modfetch: add GOINSECURE
Enables insecure fetching of dependencies whos path matches those specified in the enironment variable GOINSECURE. Fixes #32966 Change-Id: I378920fbd5a4436df0b5af3fb5533e663e2cc758 GitHub-Last-Rev: 2c87b30 GitHub-Pull-Request: #35357 Reviewed-on: https://go-review.googlesource.com/c/go/+/205238 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Showing
10 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package modfetch | ||
|
||
import ( | ||
"cmd/go/internal/cfg" | ||
"cmd/go/internal/get" | ||
"cmd/go/internal/str" | ||
) | ||
|
||
// allowInsecure reports whether we are allowed to fetch this path in an insecure manner. | ||
func allowInsecure(path string) bool { | ||
return get.Insecure || str.GlobsMatchPath(cfg.GOINSECURE, path) | ||
} |
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,24 @@ | ||
env GO111MODULE=on | ||
|
||
# secure fetch should report insecure warning | ||
cd $WORK/test | ||
go mod init | ||
stderr 'redirected .* to insecure URL' | ||
|
||
# insecure fetch should not | ||
env GOINSECURE=*.golang.org | ||
rm go.mod | ||
go mod init | ||
! stderr 'redirected .* to insecure URL' | ||
|
||
# insecure fetch invalid path should report insecure warning | ||
env GOINSECURE=foo.golang.org | ||
rm go.mod | ||
go mod init | ||
stderr 'redirected .* to insecure URL' | ||
|
||
-- $WORK/test/dependencies.tsv -- | ||
vcs-test.golang.org/insecure/go/insecure git 6fecd21f7c0c 2019-09-04T18:39:48Z | ||
|
||
-- $WORK/test/x.go -- | ||
package x // import "m" |
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 |
---|---|---|
|
@@ -37,7 +37,14 @@ env GOPROXY=$proxy/sumdb-504 | |
! go get -d rsc.io/[email protected] | ||
stderr 504 | ||
|
||
# GOINSECURE does not bypass checksum lookup | ||
env GOINSECURE=rsc.io | ||
env GOPROXY=$proxy/sumdb-504 | ||
! go get -d rsc.io/[email protected] | ||
stderr 504 | ||
|
||
# but -insecure bypasses the checksum lookup entirely | ||
env GOINSECURE= | ||
go get -d -insecure rsc.io/[email protected] | ||
|
||
# and then it is in go.sum again | ||
|
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ const KnownEnv = ` | |
GOGCCFLAGS | ||
GOHOSTARCH | ||
GOHOSTOS | ||
GOINSECURE | ||
GOMIPS | ||
GOMIPS64 | ||
GONOPROXY | ||
|