Skip to content
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

gas does not work properly if gopkg.in/yaml.v2 is installed in vendor folder - there may be other packages affected. #144

Closed
marcsauter opened this issue Nov 9, 2017 · 3 comments

Comments

@marcsauter
Copy link

Example code from: https://github.com/go-yaml/yaml

gopkg.in/yaml.v2 not installed - works as expected:

$ gas main.go
[gas] 2017/11/09 07:58:14 Processing "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go"...
[gas] 2017/11/09 07:58:14 Error during type checking: "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go:7:2: could not import gopkg.in/yaml.v2 (can't find import: "gopkg.in/yaml.v2")"
Results:

Summary:
   Files: 1
   Lines: 53
   Nosec: 0
  Issues: 0

gopkg.in/yaml.v2 installed in vendor folder:

$ dep init
  Using v2 as constraint for direct dep gopkg.in/yaml.v2
  Locking in v2 (eb3733d) for direct dep gopkg.in/yaml.v2
$ dep ensure
$ gas main.go
[gas] 2017/11/09 08:05:33 Processing "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go"...
[gas] 2017/11/09 08:05:33 Error during type checking: "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go:7:2: could not import gopkg.in/yaml.v2 (can't find import: "github.com/marcsauter/gasbug/vendor/gopkg.in/yaml.v2")"
Results:

Summary:
   Files: 1
   Lines: 53
   Nosec: 0
  Issues: 0

gopkg.in/yaml.v2 installed in GOPATH

$ go get -u gopkg.in/yaml.v2
$ gas main.go
[gas] 2017/11/09 08:06:55 Processing "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go"...
[gas] 2017/11/09 08:06:55 Error during type checking: "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go:7:2: could not import gopkg.in/yaml.v2 (can't find import: "github.com/marcsauter/gasbug/vendor/gopkg.in/yaml.v2")"
Results:

Summary:
   Files: 1
   Lines: 53
   Nosec: 0
  Issues: 0

Remove all vendoring stuff:

$ rm -rf Gopkg.* vendor/
$ gas main.go
[gas] 2017/11/09 08:07:29 Processing "/home/sauterm/golang/src/github.com/marcsauter/gasbug/main.go"...
Results:

Summary:
   Files: 1
   Lines: 53
   Nosec: 0
  Issues: 0
@jharlap
Copy link

jharlap commented Dec 2, 2017

Had a similar issue and the loader branch seems to fix it for me. Wonder if that's going to get merged... @gcmurphy any plans there?

@jharlap
Copy link

jharlap commented Dec 2, 2017

One side note, if you use the loader branch, be warned that #nosec won't work unless you edit https://github.com/GoASTScanner/gas/compare/loader#diff-7ddfb3e035b42cd70649cc33393fe32cR162 to include parsing comments

	packageConfig := loader.Config{
		Build:      &build.Default,
		ParserMode: parser.ParseComments,
	}

@gcmurphy
Copy link
Member

gcmurphy commented Jan 5, 2018

I believe this has been addressed in #146.

➜  gas git:(experimental) ✗ ./gas $GOPATH/src/github.com/go-yaml/yaml
2018/01/05 23:08:59 including rules: default
2018/01/05 23:08:59 excluding rules: default
[gas] 2018/01/05 23:08:59 Searching directory: /Users/grantmurphy/go/src/github.com/go-yaml/yaml
[gas] 2018/01/05 23:09:00 Checking package: yaml
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/apic.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/decode.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/emitterc.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/encode.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/parserc.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/readerc.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/resolve.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/scannerc.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/sorter.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/writerc.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/yaml.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/yamlh.go
[gas] 2018/01/05 23:09:00 Checking file: /Users/grantmurphy/go/src/github.com/go-yaml/yaml/yamlprivateh.go
Results:

Summary:
   Files: 13
   Lines: 9264
   Nosec: 0
  Issues: 0

@gcmurphy gcmurphy closed this as completed Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants