Skip to content

Commit 009103e

Browse files
feat: change ssvc_v1 property to optionalProperty in inputSchema
1 parent 6e509a5 commit 009103e

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_47.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const inputSchema = /** @type {const} */ ({
4141
optionalProperties: {
4242
content: {
4343
additionalProperties: true,
44-
properties: {
44+
optionalProperties: {
4545
ssvc_v1: {
4646
additionalProperties: true,
4747
properties: {
@@ -79,25 +79,27 @@ export function mandatoryTest_6_1_47(doc) {
7979

8080
doc.vulnerabilities.forEach((vulnerability, vulnerabilityIndex) => {
8181
vulnerability.metrics?.forEach((metric, metricIndex) => {
82-
const ssvcId = metric.content?.ssvc_v1.id
83-
if (ssvcId === doc.document.tracking.id) {
84-
if (doc.vulnerabilities.length > 1) {
85-
ctx.isValid = false
86-
ctx.errors.push({
87-
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v1/id`,
88-
message: `the ssvc id equals the 'document/tracking/id'
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: `the ssvc id equals the 'document/tracking/id'
8990
even the csaf document has multiple vulnerabilities `,
90-
})
91-
}
92-
} else {
93-
const idTexts = vulnerability.ids?.map((id) => id.text)
94-
if (ssvcId !== vulnerability.cve && !idTexts?.includes(ssvcId)) {
95-
ctx.isValid = false
96-
ctx.errors.push({
97-
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v1/id`,
98-
message: `the ssvc id does neither match the 'cve'
91+
})
92+
}
93+
} else {
94+
const idTexts = vulnerability.ids?.map((id) => id.text)
95+
if (ssvcId !== vulnerability.cve && !idTexts?.includes(ssvcId)) {
96+
ctx.isValid = false
97+
ctx.errors.push({
98+
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/ssvc_v1/id`,
99+
message: `the ssvc id does neither match the 'cve'
99100
nor it matches the 'text' of any item in the 'ids' array`,
100-
})
101+
})
102+
}
101103
}
102104
}
103105
})

0 commit comments

Comments
 (0)