File tree Expand file tree Collapse file tree 4 files changed +59
-2
lines changed Expand file tree Collapse file tree 4 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 11export {
22 informativeTest_6_3_2 ,
33 informativeTest_6_3_3 ,
4- informativeTest_6_3_4 ,
54 informativeTest_6_3_5 ,
65 informativeTest_6_3_6 ,
76 informativeTest_6_3_7 ,
@@ -11,3 +10,4 @@ export {
1110 informativeTest_6_3_11 ,
1211} from '../informativeTests.js'
1312export { informativeTest_6_3_1 } from './informativeTests/informativeTest_6_3_1.js'
13+ export { informativeTest_6_3_4 } from './informativeTests/informativeTest_6_3_4.js'
Original file line number Diff line number Diff line change 1+ import Ajv from 'ajv/dist/jtd.js'
2+
3+ const ajv = new Ajv ( )
4+
5+ const inputSchema = /** @type {const } */ ( {
6+ additionalProperties : true ,
7+ properties : {
8+ vulnerabilities : {
9+ elements : {
10+ additionalProperties : true ,
11+ optionalProperties : {
12+ cwes : {
13+ elements : {
14+ additionalProperties : true ,
15+ properties : { } ,
16+ } ,
17+ } ,
18+ } ,
19+ } ,
20+ } ,
21+ } ,
22+ } )
23+
24+ const validateInput = ajv . compile ( inputSchema )
25+
26+ /**
27+ * It MUST be tested that at least one CWE is given.
28+ * @param {unknown } doc
29+ * @returns
30+ */
31+ export function informativeTest_6_3_4 ( doc ) {
32+ const ctx = {
33+ infos : /** @type {Array<{ message: string; instancePath: string }> } */ ( [ ] ) ,
34+ }
35+
36+ if ( ! validateInput ( doc ) ) {
37+ return ctx
38+ }
39+
40+ doc . vulnerabilities . forEach ( ( vulnerability , vulnerabilityIndex ) => {
41+ if ( ! vulnerability ?. cwes ?. length ) {
42+ ctx . infos . push ( {
43+ instancePath : `/vulnerabilities/${ vulnerabilityIndex } ` ,
44+ message : 'missing cwe' ,
45+ } )
46+ }
47+ } )
48+
49+ return ctx
50+ }
Original file line number Diff line number Diff line change 1+ import assert from 'node:assert'
2+ import { informativeTest_6_3_4 } from '../../csaf_2_1/informativeTests.js'
3+
4+ describe ( 'informativeTest_6_3_4' , function ( ) {
5+ it ( 'only runs on relevant documents' , function ( ) {
6+ assert . equal ( informativeTest_6_3_4 ( { document : 'mydoc' } ) . infos . length , 0 )
7+ } )
8+ } )
Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ const excluded = [
5858 '6.2.39.2' ,
5959 '6.2.40' ,
6060 '6.3.2' ,
61- '6.3.4' ,
6261 '6.3.14' ,
6362 '6.3.15' ,
6463 '6.3.12' ,
You can’t perform that action at this time.
0 commit comments