1
0
mirror of https://github.com/securego/gosec.git synced 2025-07-03 00:27:05 +02:00

Support package resolution and filepaths (#187)

* Support package resolution and filepaths

This change introduces the logic to resolve packages using gotool
and build packages from filepaths. It assumes that the packages
being scanned are located within the GOPATH.

If the GOPATH environment variable is not set the GOPATH is derived
as $HOME/go.

Relates to #184

* Fix build error

* Address unhandled error

* Fix formatting error

* Handle multiple paths on GOPATH
This commit is contained in:
Grant Murphy
2018-04-16 15:46:39 +10:00
committed by GitHub
parent b643ac26a4
commit 830cb81b29
2 changed files with 86 additions and 2 deletions

View File

@ -108,6 +108,10 @@ func (gas *Analyzer) Process(packagePaths ...string) error {
if err != nil {
return err
}
if _, err := os.Stat(abspath); os.IsNotExist(err) {
gas.logger.Printf("Skipping: %s. Path doesn't exist.", abspath)
continue
}
gas.logger.Println("Searching directory:", abspath)
basePackage, err := build.Default.ImportDir(packagePath, build.ImportComment)