Skip to content

repoRootForImportDynamic has security arg equal to web.Secure(=0) when the url is http (not https) #29590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jan 6, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 6, 2019

What version of Go are you using (go version)?

$ go version
go version devel +35f4ec152b Sat Jan 5 00:45:14 2019 +0000 linux/amd64

or
ArchLinux's community/go 2:1.11.4-1

Does this issue reproduce with the latest release?

I guess

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xftroxgpx/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xftroxgpx/build/2nonpkgs/go.stuff/gopath"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build832694890=/tmp/go-build -gno-record-gcc-switches"

What did you do?

tried to build perkeep as per these instructions: https://perkeep.org/download
like:

$ cd $GOPATH/src
$ git clone https://github.com/perkeep/perkeep.git perkeep.org
...
$ cd perkeep.org
$ time go run make.go
...
(error here)
$ time go run make.go
...
(same error here)
$ go clean
...
(same error here)

What did you expect to see?

In short, this: ...(http/https fetch: Get http://...
In full, this:

go: bazil.org/fuse@v0.0.0-20160811212531-371fbbdaa898: unrecognized import path "bazil.org/fuse" (http/https fetch: Get http://bazil.org/fuse/?go-get=1: dial tcp 104.28.6.28:80: connect: connection refused sec:0 webinsec:1 websec:0)
go: error loading module requirements

What did you see instead?

In short, this: ...(https fetch: Get http://...
In full, this:

go: bazil.org/fuse@v0.0.0-20160811212531-371fbbdaa898: unrecognized import path "bazil.org/fuse" (https fetch: Get http://bazil.org/fuse/?go-get=1: dial tcp 104.28.6.28:80: connect: connection refused)
go: error loading module requirements

Relevant code:

func RepoRootForImportPath(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) {
rr, err := repoRootFromVCSPaths(importPath, "", security, vcsPaths)
if err == errUnknownSite {
rr, err = repoRootForImportDynamic(importPath, mod, security)
if err != nil {
err = fmt.Errorf("unrecognized import path %q (%v)", importPath, err)
}

func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) {
slash := strings.Index(importPath, "/")
if slash < 0 {
slash = len(importPath)
}
host := importPath[:slash]
if !strings.Contains(host, ".") {
return nil, errors.New("import path does not begin with hostname")
}
urlStr, body, err := web.GetMaybeInsecure(importPath, security)
if err != nil {
msg := "https fetch: %v"
if security == web.Insecure {
msg = "http/" + msg
}
return nil, fmt.Errorf(msg, err)

Related issue: perkeep/perkeep#1242

@ghost
Copy link
Author

ghost commented Jan 6, 2019

The only setters that I've found (thanks grep) to be setting the security parameter are the following:

security := web.Secure
if Insecure {
security = web.Insecure
}

security := web.Secure
if get.Insecure {
security = web.Insecure
}

security := web.Secure
if get.Insecure {
security = web.Insecure
}

EDIT: which kinda means, to me, that Insecure (which is set by a command line arg?) and/or get.Insecure are having the value 0 (aka web.Secure)
EDIT2: Looks like get.Insecure referes to the same Insecure that's being set by command line args... (my golang knowledge is inexistent)

var (
getD = CmdGet.Flag.Bool("d", false, "")
getF = CmdGet.Flag.Bool("f", false, "")
getT = CmdGet.Flag.Bool("t", false, "")
getU = CmdGet.Flag.Bool("u", false, "")
getFix = CmdGet.Flag.Bool("fix", false, "")
Insecure bool
)
func init() {
work.AddBuildFlags(CmdGet)
CmdGet.Run = runGet // break init loop
CmdGet.Flag.BoolVar(&Insecure, "insecure", Insecure, "")
}

@ghost
Copy link
Author

ghost commented Jan 6, 2019

The -insecure flag permits fetching from repositories and resolving
custom domains using insecure schemes such as HTTP. Use with caution.                                           

So then, I can only expect to see this ...(http/https fetch: Get http://... instead of this ...(https fetch: Get http://... ONLY when -insecure is used on command line ?!!

I guess not an issue then.

@ghost ghost closed this as completed Jan 6, 2019
@ghost
Copy link
Author

ghost commented Jan 6, 2019

Turns out I didn't do $ cd $GOPATH/src but instead I did just $ cd $GOPATH and as soon as I moved perkeep.org dir from $GOPATH into $GOPATH/src I'm not even getting this error anymore! and perkeep compiled ok.
Success. Binaries are in /home/xftroxgpx/build/2nonpkgs/go.stuff/gopath/bin

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant