Skip to content

Commit 1a2a8b8

Browse files
feat: adapt mandatory test 6.1.47
1 parent ce55d96 commit 1a2a8b8

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_47.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const inputSchema = /** @type {const} */ ({
4242
content: {
4343
additionalProperties: true,
4444
optionalProperties: {
45-
ssvc_v1: {
45+
ssvc_v2: {
4646
additionalProperties: true,
4747
optionalProperties: {
48-
id: { type: 'string' },
48+
target_ids: { elements: { type: 'string' } },
4949
},
5050
},
5151
},
@@ -79,30 +79,30 @@ export function mandatoryTest_6_1_47(doc) {
7979

8080
doc.vulnerabilities.forEach((vulnerability, vulnerabilityIndex) => {
8181
vulnerability.metrics?.forEach((metric, metricIndex) => {
82-
if (metric.content?.ssvc_v1) {
83-
const ssvcId = metric.content.ssvc_v1.id
84-
if (ssvcId === doc.document.tracking?.id) {
85-
if (doc.vulnerabilities.length > 1) {
86-
ctx.isValid = false
87-
ctx.errors.push({
88-
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v1/id`,
89-
message:
90-
`the ssvc id equals the 'document/tracking/id' ` +
91-
`even the csaf document has multiple vulnerabilities `,
92-
})
82+
if (metric.content?.ssvc_v2) {
83+
metric.content.ssvc_v2.target_ids?.forEach((ssvcId, ssvcIdIndex) => {
84+
if (ssvcId === doc.document.tracking?.id) {
85+
if (doc.vulnerabilities.length > 1) {
86+
ctx.isValid = false
87+
ctx.errors.push({
88+
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v2/${ssvcIdIndex}`,
89+
message:
90+
`the ssvc id equals the "document/tracking/id" ` +
91+
`even the csaf document has multiple vulnerabilities `,
92+
})
93+
}
9394
}
94-
} else {
9595
const idTexts = vulnerability.ids?.map((id) => id.text)
9696
if (ssvcId !== vulnerability.cve && !idTexts?.includes(ssvcId)) {
9797
ctx.isValid = false
9898
ctx.errors.push({
99-
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v1/id`,
99+
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v2/${ssvcIdIndex}`,
100100
message:
101-
`the ssvc id does neither match the 'cve' ` +
102-
`nor it matches the 'text' of any item in the 'ids' array`,
101+
`the ssvc id does neither match the "cve" ` +
102+
`nor it matches the "text" of any item in the "ids" array`,
103103
})
104104
}
105-
}
105+
})
106106
}
107107
})
108108
})

tests/csaf_2_1/mandatoryTest_6_1_47.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ const failingInputSchemaTestWithEmptyVulnerability6_1_47 = {
1111
metrics: [
1212
{
1313
content: {
14-
ssvc_v1: {
15-
id: 'CVE-1900-0002',
16-
schemaVersion: '1-0-1',
14+
ssvc_v2: {
15+
schemaVersion: '2.0.0',
1716
selections: [
1817
{
19-
name: 'Exploitation',
18+
key: 'E',
2019
namespace: 'ssvc',
21-
values: ['None'],
20+
values: [
21+
{
22+
key: 'N',
23+
},
24+
],
2225
version: '1.1.0',
2326
},
2427
],
28+
target_ids: ['CVE-1900-0002'],
2529
timestamp: '2024-01-24T10:00:00.000Z',
2630
},
2731
},

0 commit comments

Comments
 (0)