diff options
-rw-r--r-- | nvdmirror/sync.go | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/nvdmirror/sync.go b/nvdmirror/sync.go index 8cdd4c7..dcbf6a9 100644 --- a/nvdmirror/sync.go +++ b/nvdmirror/sync.go @@ -1,7 +1,10 @@ package nvdmirror -// Sync to destination directory based on given sync configuration and -// cache. Returns an array of file names which have been updated in the +// +// Sync NVD data files to destination directory based on given sync +// configuration and cache. +// +// Returns an array of file names which have been updated in the // destination directory. // // This function does the following: @@ -16,24 +19,25 @@ package nvdmirror // 3. Fetch the contents of the changed CVE feeds, CPE match files, and // the CPE dictionary. // -// All HTTP requests are made with the following request headers: +// All HTTP requests are sent with the following headers: +// +// * if-modified-since: The last-modified header from the previous +// successful response, if it was set. // -// * if-modified-since (if the URL was queried previously and the -// previous successful response had a "last-modified" header). -// * if-none-match (if the URL was queried previously and the -// previous successful response had an "etag" header). -// * user-agent +// * if-none-match: The etag header from the last successful response, +// if it was set. +// +// * user-agent: User agent from config, or the default user agent if +// the config value is unspecified. // func Sync(config SyncConfig, cache Cache, dstDir string) []string { // build sync context ctx := newSyncContext(config, cache, dstDir) - // fetch updated meta files - checks := ctx.fetchMetas() - - // get syncable URLs - urls := append(ctx.checkMetas(checks), config.GetCpeDictUrl()) - - // sync urls and return changed files - return ctx.syncUrls(urls) + // fetch meta files, check for updates, append cpe dictionary URL, + // fetch updated files, and then return a list of changed files + return ctx.syncUrls(append( + ctx.checkMetas(ctx.fetchMetas()), + config.GetCpeDictUrl(), + )) } |