From 6d113c1ac4001ecb97ff430a264b7232324b0e26 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 19 Mar 2022 00:17:22 -0400 Subject: nvdmirror: use Update internally and return Update from Sync() --- nvdmirror/syncconfig.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'nvdmirror/syncconfig.go') diff --git a/nvdmirror/syncconfig.go b/nvdmirror/syncconfig.go index e80e12e..fb8136b 100644 --- a/nvdmirror/syncconfig.go +++ b/nvdmirror/syncconfig.go @@ -104,32 +104,38 @@ func (me SyncConfig) GetCweListUrl() string { } } -// get meta URL map. -func (me SyncConfig) getMetaUrls() map[string]string { +// get map of meta URLs to possible meta updates. +func (me SyncConfig) getMetas() map[string]Update { // calculate total number of years numYears := time.Now().Year() - baseYear + 1 - r := make(map[string]string) + r := make(map[string]Update) // fetch cve feed metas for i := 0; i < numYears; i++ { - metaUrl := me.GetCveYearUrl(baseYear + i, "meta") - feedUrl := me.GetCveYearUrl(baseYear + i, "json.gz") - r[metaUrl] = feedUrl + year := baseYear + i + metaUrl := me.GetCveYearUrl(year, "meta") + feedUrl := me.GetCveYearUrl(year, "json.gz") + + r[metaUrl] = Update { + Type: UpdateCveYear, + Year: baseYear + i, + Url: feedUrl, + } } // fetch cve extra file metas for _, s := range(cveExtraFiles) { metaUrl := me.GetCveUrl(s, "meta") feedUrl := me.GetCveUrl(s, "json.gz") - r[metaUrl] = feedUrl + r[metaUrl] = Update { Type: UpdateCveYear, Meta: s, Url: feedUrl } } { // add cpe match metaUrl := me.GetCpeMatchUrl("meta") feedUrl := me.GetCpeMatchUrl("json.gz") - r[metaUrl] = feedUrl + r[metaUrl] = Update { Type: UpdateCpeMatch, Url: feedUrl } } // return map -- cgit v1.2.3