File tree Expand file tree Collapse file tree 4 files changed +59
-1
lines changed Expand file tree Collapse file tree 4 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ export {
1919 optionalTest_6_2_20 ,
2020} from '../optionalTests.js'
2121export { optionalTest_6_2_3 } from './optionalTests/optionalTest_6_2_3.js'
22+ export { optionalTest_6_2_22 } from './optionalTests/optionalTest_6_2_22.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+ document : {
9+ additionalProperties : true ,
10+ properties : {
11+ title : { type : 'string' } ,
12+ tracking : {
13+ additionalProperties : true ,
14+ properties : {
15+ id : { type : 'string' } ,
16+ } ,
17+ } ,
18+ } ,
19+ } ,
20+ } ,
21+ } )
22+
23+ const validate = ajv . compile ( inputSchema )
24+
25+ /**
26+ * @param {any } doc
27+ */
28+ export function optionalTest_6_2_22 ( doc ) {
29+ /** @type {Array<{ message: string; instancePath: string }> } */
30+ const warnings = [ ]
31+ const context = { warnings }
32+
33+ if ( ! validate ( doc ) ) {
34+ return context
35+ }
36+
37+ const trackingId = doc . document . tracking . id
38+ const documentTitle = doc . document . title
39+ if ( documentTitle . includes ( trackingId ) ) {
40+ context . warnings . push ( {
41+ message : `document title contains the tracking id ${ trackingId } ` ,
42+ instancePath : `/document/title` ,
43+ } )
44+ }
45+
46+ return context
47+ }
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ const excluded = [
3838 '6.2.11' ,
3939 '6.2.19' ,
4040 '6.2.21' ,
41- '6.2.22' ,
4241 '6.2.23' ,
4342 '6.2.24' ,
4443 '6.2.25' ,
Original file line number Diff line number Diff line change 1+ import assert from 'node:assert'
2+ import { optionalTest_6_2_22 } from '../../csaf_2_1/optionalTests.js'
3+
4+ describe ( 'optionalTest_6_2_22' , function ( ) {
5+ it ( 'only runs on relevant documents' , function ( ) {
6+ assert . equal (
7+ optionalTest_6_2_22 ( { vulnerabilities : 'mydoc' } ) . warnings . length ,
8+ 0
9+ )
10+ } )
11+ } )
You can’t perform that action at this time.
0 commit comments