33 * Export a security debt from DefectDojo.
44 */
55
6- import { join } from "path" ;
6+ import assert from "node:assert/strict" ;
7+ import { join } from "node:path" ;
78import { parseArgs } from "./cli.js" ;
89import { loadConfig } from "./config.js" ;
910import { DefectDojoApiClient } from "./defectdojo.js" ;
@@ -40,6 +41,8 @@ export async function main() {
4041 return [ ...results , ...engagements ] ;
4142 } , [ ] ) ;
4243
44+ assert ( engagements . length > 0 , "No engagement found" ) ;
45+
4346 // Fetch vulnerabilities
4447 const findings = await defectDojo
4548 . getFindings ( engagements . map ( e => e . id ) , opts . status )
@@ -58,7 +61,7 @@ export async function main() {
5861 for ( const finding of findings ) {
5962 // Resultant criticity
6063 finding . severity = finding . severity ?. toLowerCase ( ) ;
61- const i = Math . max ( impacts . findIndex ( i => i == finding . severity ) , 0 ) ;
64+ const i = Math . max ( impacts . findIndex ( i => i === finding . severity ) , 0 ) ;
6265 const e = easeTags . indexOf ( finding . tags ?. find ( t => easeTags . includes ( t ) ) ?? easeTags [ 0 ] ) ;
6366 finding . ease_index = e ;
6467 finding . ease = eases [ e ] ;
@@ -82,13 +85,13 @@ export async function main() {
8285 ( f2 . severity_index - f1 . severity_index ) || f1 . title . localeCompare ( f2 . title ) ) ;
8386
8487 console . log ( "[info] Vulnerabilities:" , criticities . map ( c =>
85- findings . filter ( f => f . criticity == c ) . length + " " + c ) . join ( ", " ) ) ;
88+ findings . filter ( f => f . criticity === c ) . length + " " + c ) . join ( ", " ) ) ;
8689
8790 /*
8891 * Generate reports
8992 */
9093
91- const defaultReportName = "Security-Debt" + ( products . length == 1 ? `_${ products [ 0 ] . name } ` : "" ) ;
94+ const defaultReportName = "Security-Debt" + ( products . length === 1 ? `_${ products [ 0 ] . name } ` : "" ) ;
9295 const path = opts . output ?? join ( process . cwd ( ) , defaultReportName ) ;
9396
9497 for ( const format of opts . format ) {
0 commit comments