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 @@ -363,7 +363,6 @@ The following tests are not yet implemented and therefore missing:
363
363
- Recommended Test 6.2.40
364
364
- Recommended Test 6.2.41
365
365
- Recommended Test 6.2.42
366
- - Recommended Test 6.2.43
367
366
- Recommended Test 6.2.44
368
367
- Recommended Test 6.2.45
369
368
- Recommended Test 6.2.46
@@ -462,6 +461,7 @@ export const recommendedTest_6_2_16: DocumentTest
462
461
export const recommendedTest_6_2_17: DocumentTest
463
462
export const recommendedTest_6_2_18: DocumentTest
464
463
export const recommendedTest_6_2_22: DocumentTest
464
+ export const recommendedTest_6_2_43: DocumentTest
465
465
` ` `
466
466
467
467
[(back to top)](#bsi-csaf-validator-lib)
Original file line number Diff line number Diff line change @@ -31,3 +31,4 @@ export { recommendedTest_6_2_27 } from './recommendedTests/recommendedTest_6_2_2
31
31
export { recommendedTest_6_2_28 } from './recommendedTests/recommendedTest_6_2_28.js'
32
32
export { recommendedTest_6_2_29 } from './recommendedTests/recommendedTest_6_2_29.js'
33
33
export { recommendedTest_6_2_38 } from './recommendedTests/recommendedTest_6_2_38.js'
34
+ 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 @@ -63,7 +63,6 @@ const excluded = [
63
63
'6.2.40' ,
64
64
'6.2.41' ,
65
65
'6.2.42' ,
66
- '6.2.43' ,
67
66
'6.2.44' ,
68
67
'6.2.45' ,
69
68
'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