Skip to content

Commit 67a00ea

Browse files
feat(CSAF2.1): #373 add mandatory test 6.1.44 - refactor input schema
1 parent 581d58f commit 67a00ea

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,33 @@ import Ajv from 'ajv/dist/jtd.js'
22

33
const ajv = new Ajv()
44

5-
const branchSchema = /** @type {const} */ ({
5+
const fullProductNameSchema = /** @type {const} */ ({
66
additionalProperties: true,
77
optionalProperties: {
8-
branches: {
9-
elements: {
10-
additionalProperties: true,
11-
properties: {},
12-
},
13-
},
14-
product: {
8+
product_identification_helper: {
159
additionalProperties: true,
1610
optionalProperties: {
17-
product_identification_helper: {
18-
additionalProperties: true,
19-
optionalProperties: {
20-
serial_numbers: { elements: { type: 'string' } },
21-
},
22-
},
11+
serial_numbers: { elements: { type: 'string' } },
2312
},
2413
},
2514
},
2615
})
2716

28-
const validateBranch = ajv.compile(branchSchema)
29-
30-
const fullProductNameSchema = /** @type {const} */ ({
17+
const branchSchema = /** @type {const} */ ({
3118
additionalProperties: true,
3219
optionalProperties: {
33-
product_identification_helper: {
34-
additionalProperties: true,
35-
optionalProperties: {
36-
serial_numbers: { elements: { type: 'string' } },
20+
branches: {
21+
elements: {
22+
additionalProperties: true,
23+
properties: {},
3724
},
3825
},
26+
product: fullProductNameSchema,
3927
},
4028
})
4129

30+
const validateBranch = ajv.compile(branchSchema)
31+
4232
/*
4333
This is the jtd schema that needs to match the input document so that the
4434
test is activated. If this schema doesn't match, it normally means that the input
@@ -105,8 +95,8 @@ export function checkSerialNumbers(serialNumbers) {
10595
const invalidNumbers = []
10696
if (serialNumbers) {
10797
for (let i = 0; i < serialNumbers.length; i++) {
108-
const modelNumber = serialNumbers[i]
109-
if (containMultipleUnescapedStars(modelNumber)) {
98+
const serialNumber = serialNumbers[i]
99+
if (containMultipleUnescapedStars(serialNumber)) {
110100
invalidNumbers.push('' + i)
111101
}
112102
}

0 commit comments

Comments
 (0)