diff options
Diffstat (limited to 'cmd')
-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 |