praetorian-inc / gokart

A static analysis tool for securing Go code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: err: go command required

alexandrevicenzi opened this issue · comments

If go is not installed scan panics. Not a usual scenario.

alexandre@localhost:~> gokart scan
Using default analyzers config found at "~/.gokart/analyzers.yml".
No existing analyzers.yml file found - writing default to ~/.gokart/analyzers.yml

Revving engines VRMMM VRMMM
3...2...1...Go!
panic: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 

goroutine 1 [running]:
github.com/praetorian-inc/gokart/analyzers.Scan(0xc000035f80, 0x1, 0x1)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/analyzers/scan.go:97 +0x135f
github.com/praetorian-inc/gokart/cmd.glob..func1(0x55a77c40cc20, 0xc000035f80, 0x1, 0x1)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/cmd/scan.go:53 +0x1ca
github.com/spf13/cobra.(*Command).execute(0x55a77c40cc20, 0x55a77c43fa00, 0x0, 0x0, 0x55a77c40cc20, 0x55a77c43fa00)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:860 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x55a77c40c9a0, 0xc000000180, 0xc00013bf78, 0x55a77bb9efc5)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:902
github.com/praetorian-inc/gokart/cmd.Execute(...)
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/cmd/root.go:61
main.main()
	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/main.go:38 +0x34

Perhaps log.Fatal would make more sense in here as the analysis failed for some reason, I don't think anyone is going to recover from here.

@alexandrevicenzi thanks for the issue submission! I am able to reproduce this issue, and I agree that that log.Fatal would be more appropriate here.

Thanks for the suggestion @alexandrevicenzi! I made this fix as well as a similar one for analyzers/sarif.go:31.

PR for this #22 is currently in review and once it's merged, it would be great if you could verify the fix to close this out.

Drive Securely,
The GoKart Maintenance Team

Hi @alexandrevicenzi - we're merged PR #22 to address this.

Please pull and rebuild the main branch to verify when you get chance. Thanks!

It works, now I get an error message.

Revving engines VRMMM VRMMM
3...2...1...Go!
2021/09/02 16:28:50 err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: