Skip to content

Commit b0977a7

Browse files
feat: change some properties to optionalProperties and adapt inputSchema test accordingly
1 parent 21e6351 commit b0977a7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_47.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const inputSchema = /** @type {const} */ ({
1313
properties: {
1414
document: {
1515
additionalProperties: true,
16-
properties: {
16+
optionalProperties: {
1717
tracking: {
1818
additionalProperties: true,
19-
properties: {
19+
optionalProperties: {
2020
id: { type: 'string' },
2121
},
2222
},
@@ -44,7 +44,7 @@ const inputSchema = /** @type {const} */ ({
4444
optionalProperties: {
4545
ssvc_v1: {
4646
additionalProperties: true,
47-
properties: {
47+
optionalProperties: {
4848
id: { type: 'string' },
4949
},
5050
},
@@ -81,7 +81,7 @@ export function mandatoryTest_6_1_47(doc) {
8181
vulnerability.metrics?.forEach((metric, metricIndex) => {
8282
if (metric.content?.ssvc_v1) {
8383
const ssvcId = metric.content.ssvc_v1.id
84-
if (ssvcId === doc.document.tracking.id) {
84+
if (ssvcId === doc.document.tracking?.id) {
8585
if (doc.vulnerabilities.length > 1) {
8686
ctx.isValid = false
8787
ctx.errors.push({

tests/csaf_2_1/mandatoryTest_6_1_47.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import assert from 'node:assert/strict'
22
import { mandatoryTest_6_1_47 } from '../../csaf_2_1/mandatoryTests/mandatoryTest_6_1_47.js'
33
import { expect } from 'chai'
44

5-
const validInputSchemaTestWithEmptyVulnerability6_1_47 = {
5+
const failingInputSchemaTestWithEmptyVulnerability6_1_47 = {
6+
document: {},
67
vulnerabilities: [
7-
{}, // even this vulnerability is empty, the test should not fail due to the inputSchema
8+
{}, // even this vulnerability is empty, the test should run
89
{
910
cve: 'CVE-1900-0001',
1011
metrics: [
1112
{
1213
content: {
1314
ssvc_v1: {
14-
id: 'CVE-1900-0001',
15+
id: 'CVE-1900-0002',
1516
schemaVersion: '1-0-1',
1617
selections: [
1718
{
@@ -37,8 +38,8 @@ describe('mandatoryTest_6_1_47', function () {
3738
})
3839
it('test input schema with empty json object in vulnerabilities', async function () {
3940
const result = mandatoryTest_6_1_47(
40-
validInputSchemaTestWithEmptyVulnerability6_1_47
41+
failingInputSchemaTestWithEmptyVulnerability6_1_47
4142
)
42-
expect(result.errors.length).to.eq(0)
43+
expect(result.errors.length).to.eq(1)
4344
})
4445
})

0 commit comments

Comments
 (0)