Skip to content

Commit 3a1cd4f

Browse files
authored
feat: use VulnsStatus to skip NVD Rejected CVE (#542)
1 parent ca81c49 commit 3a1cd4f

6 files changed

Lines changed: 43 additions & 2 deletions

File tree

pkg/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type VulnerabilityDetail struct {
8383
Description string `json:",omitempty"`
8484
PublishedDate *time.Time `json:",omitempty"` // Take from NVD or GHSA
8585
LastModifiedDate *time.Time `json:",omitempty"` // Take from NVD or GHSA
86+
Status string `json:"-"` // Rejected or not, also not stored in db
8687
}
8788

8889
type AdvisoryDetail struct {

pkg/vulnsrc/nvd/nvd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func (nvd *NVD) Put(tx *bolt.Tx, cve Cve) error {
198198
Description: description,
199199
PublishedDate: &publishedDate,
200200
LastModifiedDate: &lastModifiedDate,
201+
Status: strings.ToUpper(cve.VulnStatus),
201202
}
202203

203204
return nvd.PutVulnerabilityDetail(tx, cve.ID, vulnerability.NVD, vuln)

pkg/vulnsrc/nvd/nvd_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestVulnSrc_Update(t *testing.T) {
2323
{
2424
Key: []string{"vulnerability-detail", "CVE-2020-0001", "nvd"},
2525
Value: types.VulnerabilityDetail{
26+
Status: "ANALYZED",
2627
Description: "In getProcessRecordLocked of ActivityManagerService.java isolated apps are not handled correctly. This could lead to local escalation of privilege with no additional execution privileges needed. User interaction is not needed for exploitation. Product: Android Versions: Android-8.0, Android-8.1, Android-9, and Android-10 Android ID: A-140055304",
2728
CvssScore: 7.2,
2829
CvssVector: "AV:L/AC:L/Au:N/C:C/I:C/A:C",
@@ -38,6 +39,7 @@ func TestVulnSrc_Update(t *testing.T) {
3839
{
3940
Key: []string{"vulnerability-detail", "CVE-2023-0001", "nvd"},
4041
Value: types.VulnerabilityDetail{
42+
Status: "UNDERGOING ANALYSIS",
4143
Description: "An information exposure vulnerability in the Palo Alto Networks Cortex XDR agent on Windows devices allows a local system administrator to disclose the admin password for the agent in cleartext, which bad actors can then use to execute privileged cytool commands that disable or uninstall the agent.",
4244
CvssScoreV3: 6.7,
4345
CvssVectorV3: "CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
@@ -51,6 +53,7 @@ func TestVulnSrc_Update(t *testing.T) {
5153
{
5254
Key: []string{"vulnerability-detail", "CVE-2024-0069", "nvd"},
5355
Value: types.VulnerabilityDetail{
56+
Status: "REJECTED",
5457
Description: "Rejected reason: This CVE ID was unused by the CNA.",
5558
LastModifiedDate: utils.MustTimeParse("2023-11-28T00:15:07.140Z"),
5659
PublishedDate: utils.MustTimeParse("2023-11-28T00:15:07.140Z"),
@@ -59,6 +62,7 @@ func TestVulnSrc_Update(t *testing.T) {
5962
{
6063
Key: []string{"vulnerability-detail", "CVE-2024-5732", "nvd"},
6164
Value: types.VulnerabilityDetail{
65+
Status: "ANALYZED",
6266
Description: "A vulnerability was found in Clash up to 0.20.1 on Windows. It has been declared as critical. This vulnerability affects unknown code of the component Proxy Port. The manipulation leads to improper authentication. The attack can be initiated remotely. The exploit has been disclosed to the public and may be used. It is recommended to change the configuration settings. VDB-267406 is the identifier assigned to this vulnerability.",
6367
CvssScoreV3: 9.8,
6468
CvssVectorV3: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",

pkg/vulnsrc/nvd/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Cve struct {
99
Metrics Metrics `json:"metrics,omitempty"`
1010
Weaknesses []Weakness `json:"weaknesses,omitempty"`
1111
References []Reference `json:"references"`
12+
VulnStatus string `json:"vulnStatus"`
1213
}
1314

1415
type LangString struct {

pkg/vulnsrc/vulnerability/vulnerability.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
)
1212

1313
const (
14-
rejectVulnerability = "** REJECT **"
14+
rejectedStatus = "REJECTED"
15+
rejectKeyword = "** REJECT **"
16+
rejectedReason = "Rejected reason:"
17+
rejectedDoNotUse = "DO NOT USE THIS CANDIDATE NUMBER"
1518
)
1619

1720
type Vulnerability struct {
@@ -216,7 +219,8 @@ func getRejectedStatus(details map[types.SourceID]types.VulnerabilityDetail) boo
216219
if !ok {
217220
continue
218221
}
219-
if strings.Contains(d.Description, rejectVulnerability) {
222+
if strings.EqualFold(d.Status, rejectedStatus) || strings.Contains(d.Description, rejectKeyword) ||
223+
strings.Contains(d.Description, rejectedDoNotUse) || strings.HasPrefix(d.Description, rejectedReason) {
220224
return true
221225
}
222226
}

pkg/vulnsrc/vulnerability/vulnerability_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func TestIsRejected(t *testing.T) {
8585
CvssScore: 9.1,
8686
Title: "test vulnerability",
8787
Description: "a test vulnerability where vendor rates it lower than NVD",
88+
Status: "Modified",
8889
},
8990
vulnerability.RedHat: {
9091
ID: "CVE-2020-1234",
@@ -118,6 +119,35 @@ func TestIsRejected(t *testing.T) {
118119
CvssScore: 9.1,
119120
Title: "test vulnerability",
120121
Description: "** REJECT ** a test vulnerability where vendor rates it lower than NVD",
122+
Status: "Rejected",
123+
},
124+
},
125+
want: true,
126+
},
127+
{
128+
name: "happy path, when vulnerability from redhat and ubuntu is rejected by Nvd (from status only)",
129+
details: map[types.SourceID]types.VulnerabilityDetail{
130+
vulnerability.RedHat: {
131+
ID: "CVE-2020-1234",
132+
CvssScoreV3: 5.6,
133+
Title: "test vulnerability",
134+
Description: "a test vulnerability where vendor rates it lower than NVD",
135+
},
136+
vulnerability.Ubuntu: {
137+
ID: "CVE-2020-1234",
138+
CvssScore: 1.2,
139+
CvssScoreV3: 3.4,
140+
Severity: types.SeverityLow,
141+
SeverityV3: types.SeverityMedium,
142+
Title: "test vulnerability",
143+
Description: "a test vulnerability where vendor rates it lower than NVD",
144+
},
145+
vulnerability.NVD: {
146+
ID: "CVE-2020-1234",
147+
CvssScore: 9.1,
148+
Title: "test vulnerability",
149+
Description: "a test vulnerability where vendor rates it lower than NVD",
150+
Status: "Rejected",
121151
},
122152
},
123153
want: true,

0 commit comments

Comments
 (0)