Skip to content

Commit b780bb3

Browse files
authored
feat(detector): add DataSources filter to enrich function (#2513)
Specify the DataSources used by enrich (CISA KEV, ENISA KEV, RedHat CVE, VulnCheck KEV) in the filter passed to GetVulnerabilityDataByVulnerabilityID, so that only relevant sources are fetched. Also add a test case with mitre-v5 fixture data to verify that non-enrich DataSources are correctly filtered out.
1 parent 8383d40 commit b780bb3

7 files changed

Lines changed: 88 additions & 7 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"id": "CVE-2023-44487",
3+
"vulnerabilities": [
4+
{
5+
"content": {
6+
"id": "CVE-2023-44487",
7+
"title": "HTTP/2 Rapid Reset Attack",
8+
"description": "The HTTP/2 protocol allows a denial of service (server resource consumption) because request cancellation can reset many streams quickly, as exploited in the wild in August through October 2023.",
9+
"severity": [
10+
{
11+
"type": "cvss_v31",
12+
"source": "cve@mitre.org",
13+
"cvss_v31": {
14+
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
15+
"base_score": 7.5,
16+
"base_severity": "HIGH"
17+
}
18+
}
19+
],
20+
"references": [
21+
{
22+
"source": "cve@mitre.org",
23+
"url": "https://www.cve.org/CVERecord?id=CVE-2023-44487"
24+
}
25+
],
26+
"published": "2023-10-10T00:00:00Z"
27+
}
28+
}
29+
],
30+
"data_source": {
31+
"id": "mitre-v5",
32+
"raws": [
33+
"fixtures/CVE-2023-44487.json"
34+
]
35+
}
36+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": "CVE-2024-1102",
3+
"vulnerabilities": [
4+
{
5+
"content": {
6+
"id": "CVE-2024-1102",
7+
"title": "jberet: jberet-core logging database credentials (from mitre-v5)",
8+
"description": "This data should be filtered out by the DataSources filter and never reach enrichVulnerabilities."
9+
}
10+
}
11+
],
12+
"data_source": {
13+
"id": "mitre-v5",
14+
"raws": [
15+
"fixtures/CVE-2024-1102.json"
16+
]
17+
}
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"id": "mitre-v5",
3+
"name": "MITRE CVE v5"
4+
}

detector/vuls2/vuls2.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ func toReference(ref string) models.Reference {
12011201
}
12021202
}
12031203

1204-
// enrich adds vulnerability data from all sources (including non-detecting sources)
1204+
// enrich adds vulnerability data from specific enrichment sources (KEV, RedHat CVE)
12051205
// to the already-detected VulnInfos. This replaces gost.FillCVEsWithRedHat and also
12061206
// provides cross-source enrichment (e.g., RedHat CVE data for Debian-detected CVEs).
12071207
func enrich(sesh *session.Session, vim models.VulnInfos) error {
@@ -1211,6 +1211,13 @@ func enrich(sesh *session.Session, vim models.VulnInfos) error {
12111211
dbTypes.FilterContentTypeAdvisories,
12121212
dbTypes.FilterContentTypeVulnerabilities,
12131213
},
1214+
DataSources: []sourceTypes.SourceID{
1215+
sourceTypes.CISAKEV,
1216+
sourceTypes.ENISAKEV,
1217+
sourceTypes.Metasploit,
1218+
sourceTypes.RedHatCVE,
1219+
sourceTypes.VulnCheckKEV,
1220+
},
12141221
})
12151222
if err != nil {
12161223
if errors.Is(err, dbTypes.ErrNotFoundVulnerability) {

detector/vuls2/vuls2_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9295,6 +9295,22 @@ func Test_enrich(t *testing.T) {
92959295
},
92969296
want: models.VulnInfos{},
92979297
},
9298+
{
9299+
name: "datasource not in enrich filter is filtered out",
9300+
args: args{
9301+
vim: models.VulnInfos{
9302+
"CVE-2023-44487": models.VulnInfo{
9303+
CveID: "CVE-2023-44487",
9304+
},
9305+
},
9306+
},
9307+
want: models.VulnInfos{
9308+
"CVE-2023-44487": models.VulnInfo{
9309+
CveID: "CVE-2023-44487",
9310+
CveContents: models.CveContents{},
9311+
},
9312+
},
9313+
},
92989314
}
92999315

93009316
c := session.Config{Type: "boltdb", Path: filepath.Join(t.TempDir(), "enrich-test.db")}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ require (
66
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.4
77
github.com/BurntSushi/toml v1.6.0
88
github.com/CycloneDX/cyclonedx-go v0.10.0
9-
github.com/MaineK00n/vuls-data-update v0.0.0-20260415043012-19efba9dab97
10-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260309062902-6fa3e81762d9
9+
github.com/MaineK00n/vuls-data-update v0.0.0-20260415100620-ce86ca1a408d
10+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260416040322-81ce30605753
1111
github.com/Ullaakut/nmap/v2 v2.2.2
1212
github.com/aquasecurity/trivy v0.69.2
1313
github.com/aquasecurity/trivy-db v0.0.0-20251222105351-a833f47f8f0d

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ github.com/MaineK00n/go-microsoft-version v0.0.0-20260325021654-1d9206bdeffc h1:
7070
github.com/MaineK00n/go-microsoft-version v0.0.0-20260325021654-1d9206bdeffc/go.mod h1:GNf+Vhnxk8/pW56jsxAeFCBP0VCgVQlLIJ812UnAj9c=
7171
github.com/MaineK00n/go-paloalto-version v0.0.0-20250909032857-57479910413b h1:pDmxa1+HCq7nShTgLURMOpjKc38hYq3lrgNHqur/Nps=
7272
github.com/MaineK00n/go-paloalto-version v0.0.0-20250909032857-57479910413b/go.mod h1:ELOxzfAd4oAe4niMmoZlSiJwzf1DF+DjNdjsUcuqAR8=
73-
github.com/MaineK00n/vuls-data-update v0.0.0-20260415043012-19efba9dab97 h1:d47BSg9Gi+ZyTTZn6Fkh2O4juZS7LKBG+iAlvigbVlU=
74-
github.com/MaineK00n/vuls-data-update v0.0.0-20260415043012-19efba9dab97/go.mod h1:3bTaNbc4WrdAWFbo9kCtdbvMz10i72XGpa8U1fGMzOE=
75-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260309062902-6fa3e81762d9 h1:soWhB4NG12vsdy7N+LFxeVu5vS2YrHAuae+O/ZqPKqM=
76-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260309062902-6fa3e81762d9/go.mod h1:Px7Z7+l1+WrZlhfVRRKW2rSZ8CqS4ZW6wb5/BsPCvBs=
73+
github.com/MaineK00n/vuls-data-update v0.0.0-20260415100620-ce86ca1a408d h1:QdfZfoz8rJSZmlM9t9LSjqq7WmQdFe7aRPZTni14eSI=
74+
github.com/MaineK00n/vuls-data-update v0.0.0-20260415100620-ce86ca1a408d/go.mod h1:3bTaNbc4WrdAWFbo9kCtdbvMz10i72XGpa8U1fGMzOE=
75+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260416040322-81ce30605753 h1:SraOXYeQdog7TihZYbgdwyUc76oiMNxARWI+3NG3RPQ=
76+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20260416040322-81ce30605753/go.mod h1:o02d7v5LzUDj32vt1LibE30MoO9X9yWUhmHfgAO/46I=
7777
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
7878
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
7979
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=

0 commit comments

Comments
 (0)