diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-03-19 23:38:14 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-03-19 23:38:14 -0400 |
commit | cf219fb6f6feac735725ce9d04b3d3ac8c399007 (patch) | |
tree | 37fe8586139737247c199980c43990b7c8dffeb3 | |
parent | d05eb19e1493422400f31a6d030eb1c9f8bb890c (diff) | |
download | cvez-cf219fb6f6feac735725ce9d04b3d3ac8c399007.tar.bz2 cvez-cf219fb6f6feac735725ce9d04b3d3ac8c399007.zip |
cmd/cmd.go: add getFeeds()
-rw-r--r-- | cmd/cmd.go | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -142,6 +142,30 @@ func getFeed(path string) nvd_feed.Feed { return feed } +// Load CVE feeds in parallel. +func getFeeds(cacheDir string, updates []nvdmirror.Update) []nvd_feed.Feed { + numFeeds := 0 + + // load feeds in parallel + ch := make(chan nvd_feed.Feed) + for _, row := range(updates) { + if row.Type == nvdmirror.UpdateCveYear { + numFeeds += 1 + go func(path string) { + ch <- getFeed(path) + }(filepath.Join(cacheDir, row.Path)) + } + } + + // collect feeds + feeds := make([]nvd_feed.Feed, numFeeds) + for i := 0; i < numFeeds; i++ { + feeds[i] = <-ch + } + + return feeds +} + // Read cpe matches from file. func getCpeMatches(path string) cpematch.Matches { var matches cpematch.Matches |