From 0c880e0db9018d9139704293afdf8d1f21ed9b8f Mon Sep 17 00:00:00 2001 From: maira-samtek Date: Thu, 27 Jun 2024 10:01:48 -0400 Subject: [PATCH 1/3] feat(other-products): added logic for other products logic --- src/libs/security-hub-lib.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libs/security-hub-lib.ts b/src/libs/security-hub-lib.ts index 8b92832..edacf2d 100644 --- a/src/libs/security-hub-lib.ts +++ b/src/libs/security-hub-lib.ts @@ -5,6 +5,7 @@ import { GetFindingsCommandOutput, Remediation, AwsSecurityFinding, + AwsSecurityFindingFilters, } from "@aws-sdk/client-securityhub"; export interface Resource { @@ -61,13 +62,12 @@ export class SecurityHub { : 24 * 60 * 60 * 1000; // 1 day const maxDatetime = new Date(currentTime.getTime() - delayForNewIssues); - const filters = { + const filters: AwsSecurityFindingFilters = { RecordState: [{ Comparison: "EQUALS", Value: "ACTIVE" }], WorkflowStatus: [ { Comparison: "EQUALS", Value: "NEW" }, { Comparison: "EQUALS", Value: "NOTIFIED" }, ], - ProductName: [{ Comparison: "EQUALS", Value: "Security Hub" }], SeverityLabel: this.severityLabels, CreatedAt: [ { @@ -76,7 +76,21 @@ export class SecurityHub { }, ], }; - + if (process.env.INCLUDES_ALL_PRODUCTS !== "true") { + filters.ProductName = [{ Comparison: "EQUALS", Value: "Security Hub" }]; + } + if (process.env.SKIP_PRODUCTS) { + const skipList: string[] = process.env.SKIP_PRODUCTS.split(","); + skipList.forEach((product) => { + if (!filters.ProductName) { + filters.ProductName = []; + } + filters.ProductName?.push({ + Comparison: "NOT_EQUALS", + Value: product, + }); + }); + } // use an object to store unique findings by title const uniqueFindings: { [title: string]: SecurityHubFinding } = {}; From 1fe82afd5763ebfdca0f7b0cd51448cbf6d2e057 Mon Sep 17 00:00:00 2001 From: maira-samtek Date: Thu, 27 Jun 2024 10:10:44 -0400 Subject: [PATCH 2/3] fix(other-products): handled resources issue --- src/macpro-security-hub-sync.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/macpro-security-hub-sync.ts b/src/macpro-security-hub-sync.ts index d6d24d3..1942156 100644 --- a/src/macpro-security-hub-sync.ts +++ b/src/macpro-security-hub-sync.ts @@ -162,9 +162,9 @@ export class SecurityHubJiraSync { let Table = `${title}| Partition | Region | Type \n`; resources.forEach(({ Id, Partition, Region, Type }) => { - Table += `${Id.padEnd(maxLength + 2)}| ${Partition.padEnd( + Table += `${Id.padEnd(maxLength + 2)}| ${(Partition ?? "").padEnd( 11 - )} | ${Region.padEnd(9)} | ${Type} \n`; + )} | ${(Region ?? "").padEnd(9)} | ${Type ?? ""} \n`; }); Table += `------------------------------------------------------------------------------------------------`; From 9f2a2d4859220f2e526e158336906a27b68d7534 Mon Sep 17 00:00:00 2001 From: maira-samtek Date: Thu, 27 Jun 2024 10:28:02 -0400 Subject: [PATCH 3/3] fix(other-products): updated verbiage --- src/libs/security-hub-lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/security-hub-lib.ts b/src/libs/security-hub-lib.ts index edacf2d..6e665b4 100644 --- a/src/libs/security-hub-lib.ts +++ b/src/libs/security-hub-lib.ts @@ -76,7 +76,7 @@ export class SecurityHub { }, ], }; - if (process.env.INCLUDES_ALL_PRODUCTS !== "true") { + if (process.env.INCLUDE_ALL_PRODUCTS !== "true") { filters.ProductName = [{ Comparison: "EQUALS", Value: "Security Hub" }]; } if (process.env.SKIP_PRODUCTS) {