Check errors passed through by filepath.Walk (#208)

In several files, the error passed from filepath.Walk to WalkFunc is
not checked. As the info argument to WalkFn is nil in case of an error,
accessing info can cause a runtime panic.
This commit adds checks for errors passed through to WalkFunc.
This commit is contained in:
Sebastian Ehmann
2019-10-17 09:34:19 +02:00
committed by Teppei Fukuda
parent cb1870e7bf
commit f198b6eb63
6 changed files with 18 additions and 0 deletions

View File

@@ -59,6 +59,9 @@ func CloneOrPull(url, repoPath string) (map[string]struct{}, error) {
// Need to refresh all vulnerabilities
if db.GetVersion() == "" {
err = filepath.Walk(repoPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}