Skip to content

Commit

Permalink
Fix libraly cache directotry (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
masahiro331 authored and knqyf263 committed Aug 23, 2019
1 parent a77984a commit ab8b73e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/scanner/library/bundler/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

var (
repoPath = filepath.Join(utils.CacheDir(), "ruby-advisory-db")
repoPath string
)

type AdvisoryDB map[string][]Advisory
Expand All @@ -49,6 +49,7 @@ type Related struct {
}

func (s *Scanner) UpdateDB() (err error) {
repoPath = filepath.Join(utils.CacheDir(), "ruby-advisory-db")
if _, err := git.CloneOrPull(dbURL, repoPath); err != nil {
return xerrors.Errorf("error in %s security DB update: %w", s.Type(), err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/scanner/library/cargo/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

var (
repoPath = filepath.Join(utils.CacheDir(), "rust-advisory-db")
repoPath string
)

type AdvisoryDB map[string][]Lockfile
Expand All @@ -45,6 +45,7 @@ type Advisory struct {
}

func (s *Scanner) UpdateDB() (err error) {
repoPath = filepath.Join(utils.CacheDir(), "rust-advisory-db")
if _, err := git.CloneOrPull(dbURL, repoPath); err != nil {
return xerrors.Errorf("error in %s security DB update: %w", s.Type(), err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/scanner/library/composer/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"
"strings"

"github.com/etcd-io/bbolt"
"github.com/aquasecurity/trivy/pkg/db"
"github.com/etcd-io/bbolt"
"golang.org/x/xerrors"

"github.com/aquasecurity/trivy/pkg/utils"
Expand All @@ -22,7 +22,7 @@ const (
)

var (
repoPath = filepath.Join(utils.CacheDir(), "php-security-advisories")
repoPath string
)

type AdvisoryDB map[string][]Advisory
Expand All @@ -40,6 +40,7 @@ type Branch struct {
}

func (s *Scanner) UpdateDB() (err error) {
repoPath = filepath.Join(utils.CacheDir(), "php-security-advisories")
if _, err := git.CloneOrPull(dbURL, repoPath); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/scanner/library/node/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
)

var (
repoPath = filepath.Join(utils.CacheDir(), "nodejs-security-wg")
repoPath string
)

type AdvisoryDB map[string][]Advisory
Expand All @@ -44,6 +44,7 @@ type Advisory struct {
}

func (s *Scanner) UpdateDB() (err error) {
repoPath = filepath.Join(utils.CacheDir(), "nodejs-security-wg")
if _, err := git.CloneOrPull(dbURL, repoPath); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/scanner/library/python/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

var (
repoPath = filepath.Join(utils.CacheDir(), "python-safety-db")
repoPath string
)

type AdvisoryDB map[string][]Advisory
Expand All @@ -36,6 +36,7 @@ type Advisory struct {
}

func (s *Scanner) UpdateDB() (err error) {
repoPath = filepath.Join(utils.CacheDir(), "python-safety-db")
if _, err := git.CloneOrPull(dbURL, repoPath); err != nil {
return err
}
Expand Down

0 comments on commit ab8b73e

Please sign in to comment.