From a6f4907dd7f79a6fef217f395b16bb8c05904bc4 Mon Sep 17 00:00:00 2001 From: Johanna Ahlskog Date: Wed, 4 Oct 2023 15:07:15 +0200 Subject: [PATCH] changes in pr --- src/lib/BodyBuilder.ts | 8 ++++---- src/lib/ResponseBodyBuilder.ts | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) 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; } }