File tree Expand file tree Collapse file tree 5 files changed +62
-2
lines changed Expand file tree Collapse file tree 5 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -351,7 +351,6 @@ The following tests are not yet implemented and therefore missing:
351
351
- Recommended Test 6.2.40
352
352
- Recommended Test 6.2.41
353
353
- Recommended Test 6.2.42
354
- - Recommended Test 6.2.43
355
354
- Recommended Test 6.2.44
356
355
- Recommended Test 6.2.45
357
356
- Recommended Test 6.2.46
@@ -461,6 +460,7 @@ export const recommendedTest_6_2_17: DocumentTest
461
460
export const recommendedTest_6_2_18: DocumentTest
462
461
export const recommendedTest_6_2_22: DocumentTest
463
462
export const recommendedTest_6_2_23: DocumentTest
463
+ export const recommendedTest_6_2_43: DocumentTest
464
464
` ` `
465
465
466
466
[(back to top)](#bsi-csaf-validator-lib)
Original file line number Diff line number Diff line change @@ -32,3 +32,4 @@ export { recommendedTest_6_2_27 } from './recommendedTests/recommendedTest_6_2_2
32
32
export { recommendedTest_6_2_28 } from './recommendedTests/recommendedTest_6_2_28.js'
33
33
export { recommendedTest_6_2_29 } from './recommendedTests/recommendedTest_6_2_29.js'
34
34
export { recommendedTest_6_2_38 } from './recommendedTests/recommendedTest_6_2_38.js'
35
+ export { recommendedTest_6_2_43 } from './recommendedTests/recommendedTest_6_2_43.js'
Original file line number Diff line number Diff line change
1
+ import Ajv from 'ajv/dist/jtd.js'
2
+ const ajv = new Ajv ( )
3
+
4
+ /*
5
+ This is the jtd schema that needs to match the input document so that the
6
+ test is activated. If this schema doesn't match, it normally means that the input
7
+ document does not validate against the csaf JSON schema or optional fields that
8
+ the test checks are not present.
9
+ */
10
+ const inputSchema = /** @type {const } */ ( {
11
+ additionalProperties : true ,
12
+ properties : {
13
+ document : {
14
+ additionalProperties : true ,
15
+ properties : {
16
+ license_expression : {
17
+ type : 'string' ,
18
+ } ,
19
+ } ,
20
+ } ,
21
+ } ,
22
+ } )
23
+
24
+ const validateSchema = ajv . compile ( inputSchema )
25
+
26
+ /**
27
+ * It MUST be tested that the license expression is present and set
28
+ *
29
+ * @param {unknown } doc
30
+ */
31
+ export function recommendedTest_6_2_43 ( doc ) {
32
+ /*
33
+ The `ctx` variable holds the state that is accumulated during the test run and is
34
+ finally returned by the function.
35
+ */
36
+ const ctx = {
37
+ warnings :
38
+ /** @type {Array<{ instancePath: string; message: string }> } */ ( [ ] ) ,
39
+ }
40
+
41
+ if ( ! validateSchema ( doc ) ) {
42
+ ctx . warnings . push ( {
43
+ message : 'License expression is not set' ,
44
+ instancePath : '/document/license_expression' ,
45
+ } )
46
+ }
47
+
48
+ return ctx
49
+ }
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ const excluded = [
54
54
'6.2.40' ,
55
55
'6.2.41' ,
56
56
'6.2.42' ,
57
- '6.2.43' ,
58
57
'6.2.44' ,
59
58
'6.2.45' ,
60
59
'6.2.46' ,
Original file line number Diff line number Diff line change
1
+ import assert from 'node:assert'
2
+ import { recommendedTest_6_2_43 } from '../../csaf_2_1/recommendedTests.js'
3
+
4
+ describe ( 'recommendedTest_6_2_43' , function ( ) {
5
+ it ( 'only runs on relevant documents' , function ( ) {
6
+ assert . equal (
7
+ recommendedTest_6_2_43 ( { vulnerabilities : 'mydoc' } ) . warnings . length ,
8
+ 1
9
+ )
10
+ } )
11
+ } )
You can’t perform that action at this time.
0 commit comments