Skip to content

Commit c75743c

Browse files
authored
Merge pull request #171 from secvisogram/chore/update-dependencies
update dependencies
2 parents e61a408 + 9e7c3f8 commit c75743c

22 files changed

+932
-85
lines changed

backend/package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

csaf-validator-lib/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,9 @@ The following tests are not yet implemented and therefore missing:
311311
312312
**Mandatory Tests**
313313
314-
- Mandatory Test 6.1.6
315-
- Mandatory Test 6.1.14
316-
- Mandatory Test 6.1.16
317314
- Mandatory Test 6.1.26
318315
- Mandatory Test 6.1.27.13
319-
- Mandatory Test 6.1.27.16
320316
- Mandatory Test 6.1.27.18
321-
- Mandatory Test 6.1.27.19
322317
- Mandatory Test 6.1.42
323318
- Mandatory Test 6.1.44
324319
- Mandatory Test 6.1.45
@@ -328,7 +323,6 @@ The following tests are not yet implemented and therefore missing:
328323
- Mandatory Test 6.1.49
329324
- Mandatory Test 6.1.50
330325
- Mandatory Test 6.1.51
331-
- Mandatory Test 6.1.52
332326
- Mandatory Test 6.1.53
333327
- Mandatory Test 6.1.54
334328
- Mandatory Test 6.1.55
@@ -339,7 +333,6 @@ The following tests are not yet implemented and therefore missing:
339333
- Recommended Test 6.2.19
340334
- Recommended Test 6.2.20
341335
- Recommended Test 6.2.21
342-
- Recommended Test 6.2.23
343336
- Recommended Test 6.2.24
344337
- Recommended Test 6.2.25
345338
- Recommended Test 6.2.26
@@ -366,7 +359,6 @@ The following tests are not yet implemented and therefore missing:
366359
367360
**Informative Tests**
368361
369-
- Informative Test 6.2.12
370362
- Informative Test 6.2.13
371363
- Informative Test 6.2.14
372364
- Informative Test 6.2.15
@@ -390,14 +382,17 @@ export const mandatoryTest_6_1_2: DocumentTest
390382
export const mandatoryTest_6_1_3: DocumentTest
391383
export const mandatoryTest_6_1_4: DocumentTest
392384
export const mandatoryTest_6_1_5: DocumentTest
385+
export const mandatoryTest_6_1_6: DocumentTest
393386
export const mandatoryTest_6_1_7: DocumentTest
394387
export const mandatoryTest_6_1_8: DocumentTest
395388
export const mandatoryTest_6_1_9: DocumentTest
396389
export const mandatoryTest_6_1_10: DocumentTest
397390
export const mandatoryTest_6_1_11: DocumentTest
398391
export const mandatoryTest_6_1_12: DocumentTest
399392
export const mandatoryTest_6_1_13: DocumentTest
393+
export const mandatoryTest_6_1_14: DocumentTest
400394
export const mandatoryTest_6_1_15: DocumentTest
395+
export const mandatoryTest_6_1_16: DocumentTest
401396
export const mandatoryTest_6_1_17: DocumentTest
402397
export const mandatoryTest_6_1_18: DocumentTest
403398
export const mandatoryTest_6_1_19: DocumentTest
@@ -421,7 +416,9 @@ export const mandatoryTest_6_1_27_11: DocumentTest
421416
export const mandatoryTest_6_1_27_12: DocumentTest
422417
export const mandatoryTest_6_1_27_14: DocumentTest
423418
export const mandatoryTest_6_1_27_15: DocumentTest
419+
export const mandatoryTest_6_1_27_16: DocumentTest
424420
export const mandatoryTest_6_1_27_17: DocumentTest
421+
export const mandatoryTest_6_1_27_19: DocumentTest
425422
export const mandatoryTest_6_1_28: DocumentTest
426423
export const mandatoryTest_6_1_29: DocumentTest
427424
export const mandatoryTest_6_1_30: DocumentTest
@@ -437,6 +434,7 @@ export const mandatoryTest_6_1_39: DocumentTest
437434
export const mandatoryTest_6_1_40: DocumentTest
438435
export const mandatoryTest_6_1_41: DocumentTest
439436
export const mandatoryTest_6_1_43: DocumentTest
437+
export const mandatoryTest_6_1_52: DocumentTest
440438
```
441439
442440
[(back to top)](#bsi-csaf-validator-lib)
@@ -462,6 +460,7 @@ export const recommendedTest_6_2_16: DocumentTest
462460
export const recommendedTest_6_2_17: DocumentTest
463461
export const recommendedTest_6_2_18: DocumentTest
464462
export const recommendedTest_6_2_22: DocumentTest
463+
export const recommendedTest_6_2_23: DocumentTest
465464
```
466465
467466
[(back to top)](#bsi-csaf-validator-lib)
@@ -480,6 +479,7 @@ export const informativeTest_6_3_8: DocumentTest
480479
export const informativeTest_6_3_9: DocumentTest
481480
export const informativeTest_6_3_10: DocumentTest
482481
export const informativeTest_6_3_11: DocumentTest
482+
export const informativeTest_6_3_12: DocumentTest
483483
```
484484
485485
[(back to top)](#bsi-csaf-validator-lib)

csaf-validator-lib/csaf_2_1/informativeTests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export {
1111
export { informativeTest_6_3_1 } from './informativeTests/informativeTest_6_3_1.js'
1212
export { informativeTest_6_3_2 } from './informativeTests/informativeTest_6_3_2.js'
1313
export { informativeTest_6_3_4 } from './informativeTests/informativeTest_6_3_4.js'
14+
export { informativeTest_6_3_12 } from './informativeTests/informativeTest_6_3_12.js'
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import Ajv from 'ajv/dist/jtd.js'
2+
3+
const ajv = new Ajv()
4+
5+
/**
6+
* @typedef {object} MetricContent
7+
* @property {object} [cvss_v2]
8+
* @property {string} [cvss_v2.version]
9+
* @property {object} [cvss_v3]
10+
* @property {string} [cvss_v3.version]
11+
* @property {object} [cvss_v4]
12+
* @property {string} [cvss_v4.version]
13+
*/
14+
15+
/**
16+
* @typedef {object} Metric
17+
* @property {MetricContent} [content]
18+
* @property {Array<string>} [products]
19+
*/
20+
21+
const inputSchema = /** @type {const} */ ({
22+
additionalProperties: true,
23+
properties: {
24+
vulnerabilities: {
25+
elements: {
26+
additionalProperties: true,
27+
optionalProperties: {
28+
metrics: {
29+
elements: {
30+
additionalProperties: true,
31+
optionalProperties: {
32+
content: {
33+
additionalProperties: true,
34+
optionalProperties: {
35+
cvss_v2: {
36+
additionalProperties: true,
37+
optionalProperties: {
38+
version: { type: 'string' },
39+
},
40+
},
41+
cvss_v3: {
42+
additionalProperties: true,
43+
optionalProperties: {
44+
version: { type: 'string' },
45+
},
46+
},
47+
cvss_v4: {
48+
additionalProperties: true,
49+
optionalProperties: {
50+
version: { type: 'string' },
51+
},
52+
},
53+
},
54+
},
55+
},
56+
},
57+
},
58+
},
59+
},
60+
},
61+
},
62+
})
63+
64+
const validateInput = ajv.compile(inputSchema)
65+
66+
/**
67+
* For each item in the list of metrics, it MUST be tested that a cvss_v4 object is present.
68+
* @param {unknown} doc
69+
* @returns
70+
*/
71+
export function informativeTest_6_3_12(doc) {
72+
const ctx = {
73+
infos: /** @type {Array<{ message: string; instancePath: string }>} */ ([]),
74+
}
75+
76+
if (!validateInput(doc)) {
77+
return ctx
78+
}
79+
80+
const vulnerabilities = doc.vulnerabilities
81+
82+
vulnerabilities.forEach((vulnerability, vulnerabilityIndex) => {
83+
/** @type {Array<Metric> | undefined} */
84+
const metrics = vulnerability.metrics
85+
metrics?.forEach((metric, metricIndex) => {
86+
if (!metric?.content?.cvss_v4) {
87+
ctx.infos.push({
88+
instancePath: `/vulnerabilities/${vulnerabilityIndex}/metrics/${metricIndex}/content/cvss_v4`,
89+
message: `cvss_v4 object is not present`,
90+
})
91+
}
92+
})
93+
})
94+
95+
return ctx
96+
}

csaf-validator-lib/csaf_2_1/mandatoryTests.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ export {
33
mandatoryTest_6_1_3,
44
mandatoryTest_6_1_4,
55
mandatoryTest_6_1_5,
6-
mandatoryTest_6_1_6,
76
mandatoryTest_6_1_12,
7+
mandatoryTest_6_1_14,
88
mandatoryTest_6_1_15,
9+
mandatoryTest_6_1_16,
910
mandatoryTest_6_1_17,
1011
mandatoryTest_6_1_18,
1112
mandatoryTest_6_1_19,
@@ -35,6 +36,7 @@ export {
3536
mandatoryTest_6_1_33,
3637
} from '../mandatoryTests.js'
3738
export { mandatoryTest_6_1_1 } from './mandatoryTests/mandatoryTest_6_1_1.js'
39+
export { mandatoryTest_6_1_6 } from './mandatoryTests/mandatoryTest_6_1_6.js'
3840
export { mandatoryTest_6_1_7 } from './mandatoryTests/mandatoryTest_6_1_7.js'
3941
export { mandatoryTest_6_1_8 } from './mandatoryTests/mandatoryTest_6_1_8.js'
4042
export { mandatoryTest_6_1_9 } from './mandatoryTests/mandatoryTest_6_1_9.js'
@@ -44,7 +46,9 @@ export { mandatoryTest_6_1_13 } from './mandatoryTests/mandatoryTest_6_1_13.js'
4446
export { mandatoryTest_6_1_27_12 } from './mandatoryTests/mandatoryTest_6_1_27_12.js'
4547
export { mandatoryTest_6_1_27_14 } from './mandatoryTests/mandatoryTest_6_1_27_14.js'
4648
export { mandatoryTest_6_1_27_15 } from './mandatoryTests/mandatoryTest_6_1_27_15.js'
49+
export { mandatoryTest_6_1_27_16 } from './mandatoryTests/mandatoryTest_6_1_27_16.js'
4750
export { mandatoryTest_6_1_27_17 } from './mandatoryTests/mandatoryTest_6_1_27_17.js'
51+
export { mandatoryTest_6_1_27_19 } from './mandatoryTests/mandatoryTest_6_1_27_19.js'
4852
export { mandatoryTest_6_1_34 } from './mandatoryTests/mandatoryTest_6_1_34.js'
4953
export { mandatoryTest_6_1_35 } from './mandatoryTests/mandatoryTest_6_1_35.js'
5054
export { mandatoryTest_6_1_36 } from './mandatoryTests/mandatoryTest_6_1_36.js'
@@ -54,3 +58,4 @@ export { mandatoryTest_6_1_39 } from './mandatoryTests/mandatoryTest_6_1_39.js'
5458
export { mandatoryTest_6_1_40 } from './mandatoryTests/mandatoryTest_6_1_40.js'
5559
export { mandatoryTest_6_1_41 } from './mandatoryTests/mandatoryTest_6_1_41.js'
5660
export { mandatoryTest_6_1_43 } from './mandatoryTests/mandatoryTest_6_1_43.js'
61+
export { mandatoryTest_6_1_52 } from './mandatoryTests/mandatoryTest_6_1_52.js'

csaf-validator-lib/csaf_2_1/mandatoryTests/mandatoryTest_6_1_1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function collectProductIdRefs({ document }) {
7575
if (productRef) {
7676
entries.push({
7777
id: productRef,
78-
instancePath: `/product_tree/relationships/${i}/product_reference`,
78+
instancePath: '/product_tree/relationships/${i}/product_reference',
7979
})
8080
}
8181
const relToProductRef = relationshipGroup.relates_to_product_reference
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import Ajv from 'ajv/dist/jtd.js'
2+
3+
const ajv = new Ajv()
4+
5+
/*
6+
This is the jtd schema that needs to match the input document so that the
7+
test is activated. If this schema doesn't match it normally means that the input
8+
document does not validate against the csaf json schema or optional fields that
9+
the test checks are not present.
10+
*/
11+
const inputSchema = /** @type {const} */ ({
12+
additionalProperties: true,
13+
properties: {
14+
document: {
15+
additionalProperties: true,
16+
properties: {
17+
category: {
18+
type: 'string',
19+
},
20+
tracking: {
21+
additionalProperties: true,
22+
properties: {
23+
revision_history: {
24+
elements: {
25+
additionalProperties: true,
26+
properties: {},
27+
},
28+
},
29+
},
30+
},
31+
},
32+
},
33+
},
34+
})
35+
36+
const validate = ajv.compile(inputSchema)
37+
38+
/**
39+
* This implements the mandatory test 6.1.27.16 of the CSAF 2.1 standard.
40+
*
41+
* @param {unknown} doc
42+
*/
43+
export function mandatoryTest_6_1_27_16(doc) {
44+
/*
45+
The `ctx` variable holds the state that is accumulated during the test ran and is
46+
finally returned by the function.
47+
*/
48+
const ctx = {
49+
errors:
50+
/** @type {Array<{ instancePath: string; message: string }>} */ ([]),
51+
isValid: true,
52+
}
53+
54+
if (
55+
!validate(doc) ||
56+
!['csaf_withdrawn', 'csaf_superseded'].includes(doc.document.category)
57+
)
58+
return ctx
59+
60+
if (doc.document.tracking.revision_history.length < 2) {
61+
ctx.isValid = false
62+
ctx.errors.push({
63+
instancePath: `/document/tracking/revision_history`,
64+
message: 'needs at least two entries for the specified document category',
65+
})
66+
}
67+
68+
return ctx
69+
}

0 commit comments

Comments
 (0)