@@ -36,7 +36,7 @@ const loggerOptions: LoggerOptions = {
3636 colors : false ,
3737 path : '.' ,
3838 colorwarn : ( ) => '' ,
39- jsRepo : 'testrepo.json' ,
39+ jsRepo : [ 'testrepo.json' ] ,
4040} ;
4141
4242describe ( 'cyclonedx-json' , ( ) => {
@@ -61,6 +61,9 @@ describe('cyclonedx-json', () => {
6161 assert . strictEqual ( res . valid , true ) ;
6262 assert . strictEqual ( output . bomFormat , 'CycloneDX' ) ;
6363 assert . strictEqual ( output . specVersion , '1.4' ) ;
64+ assert . deepStrictEqual ( output . metadata . properties , [
65+ { name : 'retirejs:vulnerability-repository' , value : 'testrepo.json' } ,
66+ ] ) ;
6467 } ) ;
6568
6669 it ( 'should validate report according to schema 1.6' , ( ) => {
@@ -85,6 +88,37 @@ describe('cyclonedx-json', () => {
8588 assert . strictEqual ( output . bomFormat , 'CycloneDX' ) ;
8689 assert . strictEqual ( output . specVersion , '1.6' ) ;
8790 assert . strictEqual ( output . components [ 0 ] . evidence . occurrences [ 0 ] . location , relative ) ;
91+ assert . deepStrictEqual ( output . metadata . properties , [
92+ { name : 'retirejs:vulnerability-repository' , value : 'testrepo.json' } ,
93+ ] ) ;
94+ } ) ;
95+
96+ it ( 'should validate VEX report according to schema 1.6' , ( ) => {
97+ const data : unknown [ ] = [ ] ;
98+ const writer : Writer = {
99+ out : ( a ) => data . push ( a ) ,
100+ err : ( a ) => data . push ( a ) ,
101+ close : ( ) => undefined ,
102+ } ;
103+ const vexOptions : LoggerOptions = { ...loggerOptions , outputformat : 'cyclonedxJSON1_6_VEX' } ;
104+ const logger = reporting . open ( vexOptions ) ;
105+ jsonLogger1_6 . configure ( logger , writer , vexOptions , hash ) ;
106+ const result1 = retire . scanFileContent ( '/*! jQuery v1.8.1 asdasd ' , repo , hash ) ;
107+ result1 [ 0 ] . licenses = [ 'MIT' ] ;
108+ logger . logVulnerableDependency ( { results : result1 , file : jqFile } ) ;
109+ logger . close ( ) ;
110+ const validator = new Validator ( ) ;
111+ validator . addSchema ( jsfSchema , 'jsf-0.82.schema.json#/definitions/signature' ) ;
112+ const output = JSON . parse ( data . join ( '' ) ) ;
113+ const res = validator . validate ( output , jsonSchema1_6 ) ;
114+ assert . strictEqual ( res . valid , true , res . errors . join ( '\n' ) ) ;
115+ assert . ok ( output . vulnerabilities . length > 0 ) ;
116+ const vulnerability = output . vulnerabilities [ 0 ] ;
117+ assert . deepStrictEqual ( vulnerability . source , { name : 'Retire.js' , url : 'testrepo.json' } ) ;
118+ assert . deepStrictEqual ( vulnerability . ratings [ 0 ] . source , { name : 'Retire.js' , url : 'testrepo.json' } ) ;
119+ assert . strictEqual ( vulnerability . affects [ 0 ] . ref , 'pkg:npm/jquery@1.8.1' ) ;
120+ assert . strictEqual ( vulnerability . affects [ 0 ] . versions [ 0 ] . status , 'affected' ) ;
121+ assert . ok ( vulnerability . affects [ 0 ] . versions [ 0 ] . range . startsWith ( 'vers:npm/' ) ) ;
88122 } ) ;
89123
90124 /*it('should validate report according to xml schema', async () => {
0 commit comments