1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-29 22:37:59 +02:00

Derive the package from given files

Move some utility functions into the helper
This commit is contained in:
Cosmin Cojocar
2018-07-23 15:16:47 +02:00
parent 3f2b81461f
commit 4c6396b7d4
3 changed files with 71 additions and 45 deletions

View File

@@ -28,8 +28,6 @@ import (
"regexp"
"strings"
"path/filepath"
"golang.org/x/tools/go/loader"
)
@@ -106,11 +104,8 @@ func (gosec *Analyzer) Process(buildTags []string, packagePaths ...string) error
AllowErrors: true,
}
for _, packagePath := range packagePaths {
abspath, err := filepath.Abs(packagePath)
abspath, err := GetPkgAbsPath(packagePath)
if err != nil {
return err
}
if _, err := os.Stat(abspath); os.IsNotExist(err) {
gosec.logger.Printf("Skipping: %s. Path doesn't exist.", abspath)
continue
}