aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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