aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-18 00:46:00 -0400
committerPaul Duncan <pabs@pablotron.org>2022-03-18 00:46:00 -0400
commit2342dfa0ac169e49fa227f05529707a09a88bf35 (patch)
treebf4afd732a55e59b5380e08567709319fe013b6f
parente9df9a34d4eb229af52520d7a8aced08cc420a44 (diff)
downloadcvez-2342dfa0ac169e49fa227f05529707a09a88bf35.tar.bz2
cvez-2342dfa0ac169e49fa227f05529707a09a88bf35.zip
nvdmirror: add cisa kevc url
-rw-r--r--nvdmirror/syncconfig.go15
-rw-r--r--nvdmirror/syncconfig_test.go22
2 files changed, 36 insertions, 1 deletions
diff --git a/nvdmirror/syncconfig.go b/nvdmirror/syncconfig.go
index 5da067d..9cb5397 100644
--- a/nvdmirror/syncconfig.go
+++ b/nvdmirror/syncconfig.go
@@ -18,6 +18,9 @@ type SyncConfig struct {
// CPE 2.3 dictionary URL.
Cpe23DictUrl string
+ // CISA known exploited vulnerabilities catalog (KEVC) URL.
+ CisaKevcUrl string
+
// User agent string. Set to "" for default user agent string.
UserAgent string
@@ -28,11 +31,12 @@ type SyncConfig struct {
IdleConnTimeout time.Duration
}
-// NVD URLs
+// Default configuration (NVD and CISA URLs).
var DefaultConfig = SyncConfig {
Cve11BaseUrl: "https://nvd.nist.gov/feeds/json/cve/1.1",
CpeMatch10BaseUrl: "https://nvd.nist.gov/feeds/json/cpematch/1.0",
Cpe23DictUrl: "https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz",
+ CisaKevcUrl: "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json",
UserAgent: "cvez/0.1.0",
}
@@ -78,6 +82,15 @@ func (me SyncConfig) GetCpeDictUrl() string {
}
}
+// Get CISA KEVC URL.
+func (me SyncConfig) GetCisaKevcUrl() string {
+ if len(me.CisaKevcUrl) > 0 {
+ return me.CisaKevcUrl
+ } else {
+ return DefaultConfig.CisaKevcUrl
+ }
+}
+
// get meta URL map.
func (me SyncConfig) getMetaUrls() map[string]string {
// calculate total number of years
diff --git a/nvdmirror/syncconfig_test.go b/nvdmirror/syncconfig_test.go
index cc1cdfe..5f57b2d 100644
--- a/nvdmirror/syncconfig_test.go
+++ b/nvdmirror/syncconfig_test.go
@@ -119,6 +119,28 @@ func TestSyncConfigGetCpeDictUrl(t *testing.T) {
}
}
+func TestSyncConfigGetCisaKevcUrl(t *testing.T) {
+ tests := []struct {
+ name string
+ val string
+ exp string
+ } {
+ { "custom", "https://example.com/", "https://example.com/" },
+ { "default", "", DefaultConfig.CisaKevcUrl },
+ }
+
+ for _, test := range(tests) {
+ t.Run(test.name, func(t *testing.T) {
+ config := SyncConfig { CisaKevcUrl: test.val }
+
+ got := config.GetCisaKevcUrl()
+ if got != test.exp {
+ t.Errorf("got \"%s\", exp \"%s\"", got, test.exp)
+ }
+ })
+ }
+}
+
func TestSyncConfigGetMetaUrls(t *testing.T) {
// declare expected result
exp := make(map[string]string)