From 684770ff2ef94983be4caebada03119d6551d34c Mon Sep 17 00:00:00 2001 From: "Kunz, Immanuel" Date: Wed, 24 Apr 2024 17:53:47 +0200 Subject: [PATCH] fix typo, fix linting errors --- cmd/csaf_downloader/config.go | 2 +- cmd/csaf_downloader/main.go | 6 +++--- csaf/providermetaloader.go | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/csaf_downloader/config.go b/cmd/csaf_downloader/config.go index 00780ee..e534c61 100644 --- a/cmd/csaf_downloader/config.go +++ b/cmd/csaf_downloader/config.go @@ -58,7 +58,7 @@ type config struct { IgnorePattern []string `long:"ignore_pattern" short:"i" description:"Do not download files if their URLs match any of the given PATTERNs" value-name:"PATTERN" toml:"ignore_pattern"` ExtraHeader http.Header `long:"header" short:"H" description:"One or more extra HTTP header fields" toml:"header"` - EnumeratePMDOnly bool `long:"enumerate_pmd_only" description:"If this flag is set to true, the donwloader will only enumerate valid provider metadata files, but not download documents" toml:"enumerate_pmd_only"` + EnumeratePMDOnly bool `long:"enumerate_pmd_only" description:"If this flag is set to true, the downloader will only enumerate valid provider metadata files, but not download documents" toml:"enumerate_pmd_only"` RemoteValidator string `long:"validator" description:"URL to validate documents remotely" value-name:"URL" toml:"validator"` RemoteValidatorCache string `long:"validator_cache" description:"FILE to cache remote validations" value-name:"FILE" toml:"validator_cache"` diff --git a/cmd/csaf_downloader/main.go b/cmd/csaf_downloader/main.go index 3a0d79f..6852217 100644 --- a/cmd/csaf_downloader/main.go +++ b/cmd/csaf_downloader/main.go @@ -41,12 +41,12 @@ func run(cfg *config, domains []string) error { d.forwarder = f } + // If the enumerate-only flag is set, enumerate found PMDs, + // else use the normal load method if cfg.EnumeratePMDOnly { - // Enumerate only return d.runEnumerate(domains) - } else { - return d.run(ctx, domains) } + return d.run(ctx, domains) } func main() { diff --git a/csaf/providermetaloader.go b/csaf/providermetaloader.go index 1c1200d..45436b1 100644 --- a/csaf/providermetaloader.go +++ b/csaf/providermetaloader.go @@ -109,6 +109,9 @@ func NewProviderMetadataLoader(client util.Client) *ProviderMetadataLoader { } } +// Enumerate lists all PMD files that can be found under the given domain. +// As specified in CSAF 2.0, it looks for PMDs using the well-known URL and +// the security.txt, and if no PMDs have been found, it also checks the DNS-URL. func (pmdl *ProviderMetadataLoader) Enumerate(domain string) []*LoadedProviderMetadata { // Our array of PMDs to be found @@ -143,10 +146,9 @@ func (pmdl *ProviderMetadataLoader) Enumerate(domain string) []*LoadedProviderMe // According to the spec, only if no PMDs have been found, the should DNS URL be used if len(resPMDs) > 0 { return resPMDs - } else { - dnsURL := "https://csaf.data.security." + domain - return []*LoadedProviderMetadata{pmdl.loadFromURL(dnsURL)} } + dnsURL := "https://csaf.data.security." + domain + return []*LoadedProviderMetadata{pmdl.loadFromURL(dnsURL)} }