aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-19 23:38:14 -0400
committerPaul Duncan <pabs@pablotron.org>2022-03-19 23:38:14 -0400
commitcf219fb6f6feac735725ce9d04b3d3ac8c399007 (patch)
tree37fe8586139737247c199980c43990b7c8dffeb3
parentd05eb19e1493422400f31a6d030eb1c9f8bb890c (diff)
downloadcvez-cf219fb6f6feac735725ce9d04b3d3ac8c399007.tar.bz2
cvez-cf219fb6f6feac735725ce9d04b3d3ac8c399007.zip
cmd/cmd.go: add getFeeds()
-rw-r--r--cmd/cmd.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/cmd.go b/cmd/cmd.go
index fd195aa..f70eaae 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -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