Skip to content

Commit 151ad11

Browse files
committed
ROX-28353: use NVD 2.0 JSON feeds
1 parent 3b50556 commit 151ad11

File tree

8 files changed

+372
-393
lines changed

8 files changed

+372
-393
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
contains(github.event.pull_request.labels.*.name, 'generate-dumps-on-pr')
163163
env:
164164
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
165-
ROX_LEGACY_NVD_LOADER: true
165+
ROX_NVD_FEED_LOADER: true
166166
runs-on: ubuntu-latest
167167
needs:
168168
- pre-build-updater

e2etests/vuln_test.go

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,16 @@ func TestStackroxVulnImages(t *testing.T) {
142142
image: "quay.io/rhacs-eng/qa:rails-cve-2016-2098",
143143
expectedFeatures: []feature{
144144
{"rails", "4.2.5.1", []expectedVuln{
145+
{name: "CVE-2016-2098"},
146+
{name: "CVE-2016-6316"},
147+
{name: "CVE-2016-6317"},
145148
{name: "CVE-2018-16476", fixedBy: "4.2.11"},
146149
{name: "CVE-2019-5418", fixedBy: "4.2.11.1"},
147150
{name: "CVE-2019-5419", fixedBy: "4.2.11.1"},
148151
{name: "CVE-2019-5420", fixedBy: "5.2.2.1"},
149152
},
150153
},
151154
},
152-
unexpectedVulns: []feature{
153-
{"rails", "4.2.5.1", []expectedVuln{
154-
// These three vulns should exist, but NVD set these to deferred.
155-
// Placing them here until they are no longer deferred.
156-
{name: "CVE-2016-2098"},
157-
{name: "CVE-2016-6316"},
158-
{name: "CVE-2016-6317"},
159-
},
160-
},
161-
},
162155
},
163156
{
164157
// docker.io/1and1internet/ubuntu-16-customerssh:latest
@@ -184,6 +177,10 @@ func TestStackroxVulnImages(t *testing.T) {
184177
{name: "CVE-2019-10086", fixedBy: ""},
185178
},
186179
},
180+
{"commons_fileupload", "1.3.2", []expectedVuln{
181+
{name: "CVE-2016-1000031", fixedBy: ""},
182+
},
183+
},
187184
{"guava", "18.0", []expectedVuln{
188185
{name: "CVE-2018-10237", fixedBy: "24.1.1"},
189186
},
@@ -197,12 +194,6 @@ func TestStackroxVulnImages(t *testing.T) {
197194
{name: "CVE-2015-2512"},
198195
},
199196
},
200-
{"commons_fileupload", "1.3.2", []expectedVuln{
201-
// This vuln should exist, but NVD set it to deferred.
202-
// Placing it here until they are no longer deferred.
203-
{name: "CVE-2016-1000031", fixedBy: ""},
204-
},
205-
},
206197
},
207198
},
208199
{
@@ -218,17 +209,17 @@ func TestStackroxVulnImages(t *testing.T) {
218209
{
219210
// docker.io/library/cassandra:latest
220211
image: "quay.io/rhacs-eng/qa:cassandra",
212+
expectedFeatures: []feature{
213+
{"logback", "1.1.3", []expectedVuln{
214+
{name: "CVE-2017-5929", fixedBy: ""},
215+
},
216+
},
217+
},
221218
unexpectedVulns: []feature{
222219
{"slingshot", "0.10.3", []expectedVuln{
223220
{name: "CVE-2015-5711"},
224221
},
225222
},
226-
{"logback", "1.1.3", []expectedVuln{
227-
// This vuln should exist, but NVD set it to deferred.
228-
// Placing it here until they are no longer deferred.
229-
{name: "CVE-2017-5929", fixedBy: ""},
230-
},
231-
},
232223
},
233224
},
234225
{

pkg/env/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ var (
4141
// MaxGrpcConcurrentStreams configures the maximum number of HTTP/2 streams to use with gRPC
4242
MaxGrpcConcurrentStreams = RegisterIntegerSetting("ROX_GRPC_MAX_CONCURRENT_STREAMS", DefaultMaxGrpcConcurrentStreams)
4343

44-
// LegacyNVDLoader when true will cause the loader to pull NVD data using
45-
// the NVD Legacy Data Feeds, if false will pull from the NVD 2.0 API.
46-
LegacyNVDLoader = RegisterBooleanSetting("ROX_LEGACY_NVD_LOADER", false)
44+
// NVDFeedLoader when true will cause the loader to pull NVD data using
45+
// the NVD 2.0 Data Feeds. If false, the loader will pull from the NVD 2.0 API.
46+
NVDFeedLoader = RegisterBooleanSetting("ROX_NVD_FEED_LOADER", false)
4747

4848
// RHLineage when true will cause all parent layers (a.k.a lineage) to be considered when
4949
// storing scan results for RHEL image layers.

pkg/vulnloader/nvdloader/convert.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const (
1414
jsonTimeFormat = "2006-01-02T15:04Z"
1515
)
1616

17-
func toJSON(vulns []*apischema.CVEAPIJSON20DefCVEItem) ([]*jsonschema.NVDCVEFeedJSON10DefCVEItem, error) {
17+
func toJSON10(vulns []*apischema.CVEAPIJSON20DefCVEItem) ([]*jsonschema.NVDCVEFeedJSON10DefCVEItem, error) {
1818
if vulns == nil {
1919
return nil, nil
2020
}
@@ -152,14 +152,18 @@ func toBaseMetricV2(metrics []*apischema.CVEAPIJSON20CVSSV2) *jsonschema.NVDCVEF
152152
}
153153

154154
func toBaseMetricV3(metrics30 []*apischema.CVEAPIJSON20CVSSV30, metrics31 []*apischema.CVEAPIJSON20CVSSV31) *jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3 {
155-
switch {
156-
case len(metrics31) != 0:
157-
return toBaseMetricV31(metrics31)
158-
case len(metrics30) != 0:
159-
return toBaseMetricV30(metrics30)
160-
default:
161-
return nil
155+
// Prefer CVSS 3.1.
156+
baseMetric := toBaseMetricV31(metrics31)
157+
if baseMetric != nil {
158+
return baseMetric
159+
}
160+
161+
baseMetric = toBaseMetricV30(metrics30)
162+
if baseMetric != nil {
163+
return baseMetric
162164
}
165+
166+
return nil
163167
}
164168

165169
func toBaseMetricV31(metrics []*apischema.CVEAPIJSON20CVSSV31) *jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3 {

0 commit comments

Comments
 (0)