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 @@ -349,7 +349,6 @@ The following tests are not yet implemented and therefore missing:
349349- Recommended Test 6.2.40
350350- Recommended Test 6.2.41
351351- Recommended Test 6.2.42
352- - Recommended Test 6.2.43
353352- Recommended Test 6.2.44
354353- Recommended Test 6.2.45
355354- Recommended Test 6.2.46
@@ -461,6 +460,7 @@ export const recommendedTest_6_2_18: DocumentTest
461460export const recommendedTest_6_2_22: DocumentTest
462461export const recommendedTest_6_2_23: DocumentTest
463462export const recommendedTest_6_2_25: DocumentTest
463+ export const recommendedTest_6_2_43: DocumentTest
464464` ` `
465465
466466[(back to top)](#bsi-csaf-validator-lib)
Original file line number Diff line number Diff line change @@ -33,3 +33,4 @@ export { recommendedTest_6_2_27 } from './recommendedTests/recommendedTest_6_2_2
3333export { recommendedTest_6_2_28 } from './recommendedTests/recommendedTest_6_2_28.js'
3434export { recommendedTest_6_2_29 } from './recommendedTests/recommendedTest_6_2_29.js'
3535export { recommendedTest_6_2_38 } from './recommendedTests/recommendedTest_6_2_38.js'
36+ 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 @@ -52,7 +52,6 @@ const excluded = [
5252 '6.2.40' ,
5353 '6.2.41' ,
5454 '6.2.42' ,
55- '6.2.43' ,
5655 '6.2.44' ,
5756 '6.2.45' ,
5857 '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