Properly handle path in CVE URL prefix (#4174)

This commit is contained in:
Tomas Touceda 2022-02-11 14:10:13 -03:00 committed by GitHub
parent d167556514
commit c45115a915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1 @@
* Properly handle paths in CVE URL prefix

View file

@ -36,6 +36,7 @@ func SyncCVEData(vulnPath string, config config.FleetConfig) error {
return fmt.Errorf("parsing cve feed url prefix override: %w", err)
}
source.Host = parsed.Host
source.CVEFeedPath = parsed.Path
source.Scheme = parsed.Scheme
}

View file

@ -148,7 +148,7 @@ func TestSyncsCVEFromURL(t *testing.T) {
tempDir := t.TempDir()
err := SyncCVEData(
tempDir, config.FleetConfig{Vulnerabilities: config.VulnerabilitiesConfig{CVEFeedPrefixURL: ts.URL}})
tempDir, config.FleetConfig{Vulnerabilities: config.VulnerabilitiesConfig{CVEFeedPrefixURL: ts.URL + "/feeds/json/cve/1.1/"}})
require.Error(t, err)
require.Equal(t,
fmt.Sprintf("1 synchronisation error:\n\tunexpected size for \"%s/feeds/json/cve/1.1/nvdcve-1.1-2002.json.gz\" (200 OK): want 1453293, have 0", ts.URL),