diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-03-19 23:38:19 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-03-19 23:38:19 -0400 |
commit | 82a96af793f3d2ba190b658d7586e44d3854ba82 (patch) | |
tree | 87558b362794fd7787c175f872e1cd85bfd98971 /cmd | |
parent | cf219fb6f6feac735725ce9d04b3d3ac8c399007 (diff) | |
download | cvez-82a96af793f3d2ba190b658d7586e44d3854ba82.tar.bz2 cvez-82a96af793f3d2ba190b658d7586e44d3854ba82.zip |
cmd/update.go: use getFeeds()
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/update.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd/update.go b/cmd/update.go index 86e6c7a..8615057 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -7,7 +7,6 @@ import ( "github.com/pablotron/cvez/nvdmirror" "github.com/rs/zerolog/log" "github.com/spf13/cobra" - nvd_feed "github.com/pablotron/cvez/feed" "os" "path/filepath" ) @@ -33,22 +32,16 @@ var updateCmd = &cobra.Command{ defer cache.Close() // sync data, get updates + log.Info().Msg("sync mirror") updates := nvdmirror.Sync(config, &cache, cacheDir) if len(updates) > 0 { // connect to db ctx := context.Background() db := getDb() - // build list of feeds to add + // load feeds log.Info().Msg("load feeds") - var feeds []nvd_feed.Feed - for _, row := range(updates) { - if row.Type == nvdmirror.UpdateCveYear { - feeds = append(feeds, getFeed(filepath.Join(cacheDir, row.Path))) - } - } - - if len(feeds) > 0 { + if feeds := getFeeds(cacheDir, updates); len(feeds) > 0 { log.Info().Msg("AddCveFeeds") if _, err := db.AddCveFeeds(ctx, feeds); err != nil { // FIXME: failing like this leaves an invalid cache @@ -88,6 +81,8 @@ var updateCmd = &cobra.Command{ } } } + + log.Info().Msg("done") } }, } |