diff --git a/src/lib/BodyBuilder.ts b/src/lib/BodyBuilder.ts index 0a8115a3..414fd5aa 100644 --- a/src/lib/BodyBuilder.ts +++ b/src/lib/BodyBuilder.ts @@ -41,11 +41,11 @@ export class BodyBuilder { const sastNumberOfSeverity2: string = process.env.SASTnumberOfSeverity2 || ''; const sastNumberOfSeverity3: string = process.env.SASTnumberOfSeverity3 || ''; - const tmNumberOfActiveTickets: string = process.env.tmNumberOfActiveTickets || ''; - const tmNumberOfClosedTickets: string = process.env.tmNumberOfClosedTickets || ''; + const tmNumberOfActiveTickets: string | undefined = process.env.tmNumberOfActiveTickets || undefined; + const tmNumberOfClosedTickets: string | undefined = process.env.tmNumberOfClosedTickets || undefined; - const ptNumberOfActiveTickets: string = process.env.ptNumberOfActiveTickets || ''; - const ptNumberOfClosedTickets: string = process.env.ptNumberOfClosedTickets || ''; + const ptNumberOfActiveTickets: string | undefined = process.env.ptNumberOfActiveTickets || undefined; + const ptNumberOfClosedTickets: string | undefined = process.env.ptNumberOfClosedTickets || undefined; const numUserInProdSeverity1: string = process.env.numUserInProdSeverity1 || ''; const numUserInProdSeverity2: string = process.env.numUserInProdSeverity2 || ''; diff --git a/src/lib/ResponseBodyBuilder.ts b/src/lib/ResponseBodyBuilder.ts index 880e506a..205c96d5 100644 --- a/src/lib/ResponseBodyBuilder.ts +++ b/src/lib/ResponseBodyBuilder.ts @@ -45,14 +45,16 @@ export class ResponseBodyBuilder { setThreatModelingDate( threatModelingDate: string, - tmNumberOfActiveTickets: string, - tmNumberOfClosedTickets: string + tmNumberOfActiveTickets: string | undefined, + tmNumberOfClosedTickets: string | undefined ): this { if (!threatModelingDate) { return this; } else { - if ((!tmNumberOfActiveTickets && !tmNumberOfClosedTickets) || ((tmNumberOfActiveTickets && tmNumberOfClosedTickets) !== '')) { + if (tmNumberOfActiveTickets !== undefined) { this.responseBody.tmNumberOfActiveTickets = tmNumberOfActiveTickets; + } + if (tmNumberOfClosedTickets !== undefined) { this.responseBody.tmNumberOfClosedTickets = tmNumberOfClosedTickets; } this.responseBody.threatModelingDate = threatModelingDate; @@ -131,15 +133,17 @@ export class ResponseBodyBuilder { } } - setPentestDate(pentestDate: string, ptNumberOfActiveTickets: string, ptNumberOfClosedTickets: string): this { + setPentestDate(pentestDate: string, ptNumberOfActiveTickets: string | undefined, ptNumberOfClosedTickets: string | undefined): this { if (!pentestDate) { return this; } else { - if ((!ptNumberOfActiveTickets && !ptNumberOfClosedTickets) || ((ptNumberOfActiveTickets && ptNumberOfClosedTickets) !== '')) { - this.responseBody.ptNumberOfActiveTickets = ptNumberOfActiveTickets; - this.responseBody.ptNumberOfClosedTickets = ptNumberOfClosedTickets; + if (ptNumberOfActiveTickets !== undefined) { + this.responseBody.tmNumberOfActiveTickets = ptNumberOfActiveTickets; + } + if (ptNumberOfClosedTickets !== undefined) { + this.responseBody.tmNumberOfClosedTickets = ptNumberOfClosedTickets; } - this.responseBody.pentestDate = pentestDate; + this.responseBody.threatModelingDate = pentestDate; return this; } }