From 186bbdcc75d004c85037dbee233da2beb3d5d036 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 5 Dec 2024 12:26:55 -0500 Subject: [PATCH 01/10] Edited DrawerInterior.tsx to fix filter sort - Added sort to portFacet. - Added sort to cveFacet. - Severity levels are now sorted in order of Low, Medium, High, Critical. --- frontend/src/components/DrawerInterior.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 3b43e432..f9945e5f 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -151,7 +151,9 @@ export const DrawerInterior: React.FC = (props) => { ); const portFacet: any[] = facets['services.port'] - ? facets['services.port'][0].data + ? facets['services.port'][0].data.sort( + (a: { value: number }, b: { value: number }) => a.value - b.value + ) : []; const fromDomainFacet: any[] = facets['fromRootDomain'] @@ -159,7 +161,10 @@ export const DrawerInterior: React.FC = (props) => { : []; const cveFacet: any[] = facets['vulnerabilities.cve'] - ? facets['vulnerabilities.cve'][0].data + ? facets['vulnerabilities.cve'][0].data.sort( + (a: { value: string }, b: { value: string }) => + a.value.localeCompare(b.value) + ) : []; const severityFacet: any[] = facets['vulnerabilities.severity'] @@ -167,7 +172,7 @@ export const DrawerInterior: React.FC = (props) => { : []; // Always show all severities - for (const value of ['Critical', 'High', 'Medium', 'Low']) { + for (const value of ['Low', 'Medium', 'High', 'Critical']) { if (!severityFacet.find((severity) => value === severity.value)) severityFacet.push({ value, count: 0 }); } From 938777f16a111391af52fed552dd1df62a6d7203 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 10 Dec 2024 09:29:06 -0500 Subject: [PATCH 02/10] Edited severityFacet logic and syncdb script - npm run syncdb was not syncing domains on run due to it being nested inside syncdb -- -d populate. -- Thus changes to local db were not being reflected in the search index. - Edited severityFacet logic to only show severity filters if there are severity filters to show. - Added a sort to display severity filters in the following order: N/A, Low, Medium, High, Critical, Other. --- backend/src/tasks/search-sync-domains.ts | 12 +++++------- backend/src/tasks/syncdb.ts | 11 +---------- frontend/src/components/DrawerInterior.tsx | 14 +++++++------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/backend/src/tasks/search-sync-domains.ts b/backend/src/tasks/search-sync-domains.ts index 849ac4fa..8f5749b4 100644 --- a/backend/src/tasks/search-sync-domains.ts +++ b/backend/src/tasks/search-sync-domains.ts @@ -11,9 +11,7 @@ import pRetry from 'p-retry'; export const DOMAIN_CHUNK_SIZE = typeof jest === 'undefined' ? 50 : 10; export const ORGANIZATION_CHUNK_SIZE = typeof jest === 'undefined' ? 50 : 10; -export const handler = async (commandOptions: CommandOptions) => { - const { organizationId, domainId } = commandOptions; - +export const handler = async () => { console.log('Running searchSync'); await connectToDatabase(); @@ -35,10 +33,10 @@ export const handler = async (commandOptions: CommandOptions) => { .groupBy('domain.id, organization.id, vulnerabilities.id, services.id') .select(['domain.id']); - if (organizationId) { - // This parameter is used for testing only - qs.where('organization.id=:org', { org: organizationId }); - } + // if (organizationId) { + // // This parameter is used for testing only + // qs.where('organization.id=:org', { org: organizationId }); + // } qs.andWhere( '(domain."isFceb" = true OR (domain."isFceb" = false AND domain."fromCidr" = true))' diff --git a/backend/src/tasks/syncdb.ts b/backend/src/tasks/syncdb.ts index 1f966255..ee3622cb 100644 --- a/backend/src/tasks/syncdb.ts +++ b/backend/src/tasks/syncdb.ts @@ -139,17 +139,8 @@ export const handler: Handler = async (event) => { } } - console.log('Done. Running search sync...'); - for (const organizationId of organizationIds) { - await searchSyncDomains({ - organizationId, - scanId: 'scanId', - scanName: 'scanName', - organizationName: 'organizationName', - scanTaskId: 'scanTaskId' - }); - } console.log('Done.'); } + await searchSyncDomains(); await searchSyncOrgs(); }; diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index f9945e5f..5edb81db 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -167,15 +167,15 @@ export const DrawerInterior: React.FC = (props) => { ) : []; + const severityLevels = ['N/A', 'Low', 'Medium', 'High', 'Critical', 'Other']; const severityFacet: any[] = facets['vulnerabilities.severity'] - ? facets['vulnerabilities.severity'][0].data + ? facets['vulnerabilities.severity'][0].data.sort( + (a: { value: string }, b: { value: string }) => + severityLevels.indexOf(a.value) - severityLevels.indexOf(b.value) + ) : []; - - // Always show all severities - for (const value of ['Low', 'Medium', 'High', 'Critical']) { - if (!severityFacet.find((severity) => value === severity.value)) - severityFacet.push({ value, count: 0 }); - } + console.log(facets); + console.log('severityFacet', severityFacet); return ( From 48a5907d1eefad3c0bd8d0658724ab96df20ee39 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Dec 2024 09:28:59 -0500 Subject: [PATCH 03/10] Edited Severity Facet Filter in DrawerInterior.tsx - Added data validation logic to group irregular severity values into appropriate categories. - Null, empty string, N/A, and undefined values are grouped into the "N/A" category. - Special characters, numbers, and Other are grouped into the "Other" category. - All categories are case insensitive. - Edited vulnerability.severity agg in buildRequest.ts to inclues "null" values. - Increased aggregation size to 50 to include all severity values. --- backend/src/api/search/buildRequest.ts | 4 +- frontend/src/components/DrawerInterior.tsx | 84 +++++++++++++++++++--- 2 files changed, 78 insertions(+), 10 deletions(-) diff --git a/backend/src/api/search/buildRequest.ts b/backend/src/api/search/buildRequest.ts index b22d2758..5ef3ad74 100644 --- a/backend/src/api/search/buildRequest.ts +++ b/backend/src/api/search/buildRequest.ts @@ -196,7 +196,9 @@ export function buildRequest( aggs: { severity: { terms: { - field: 'vulnerabilities.severity.keyword' + field: 'vulnerabilities.severity.keyword', + missing: 'null', + size: 50 } }, cve: { diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 5edb81db..e4383a14 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -44,6 +44,15 @@ interface Props { initialFilters: any[]; } +interface SeverityData { + value: string; + count: number; +} + +interface GroupedData { + [key: string]: number; +} + const FiltersApplied: React.FC = () => { return (
@@ -167,15 +176,72 @@ export const DrawerInterior: React.FC = (props) => { ) : []; - const severityLevels = ['N/A', 'Low', 'Medium', 'High', 'Critical', 'Other']; - const severityFacet: any[] = facets['vulnerabilities.severity'] - ? facets['vulnerabilities.severity'][0].data.sort( - (a: { value: string }, b: { value: string }) => - severityLevels.indexOf(a.value) - severityLevels.indexOf(b.value) + // const severityFacet: any[] = facets['vulnerabilities.severity'] + // ? facets['vulnerabilities.severity'][0].data.sort( + // (a: { value: string }, b: { value: string }) => + // severityLevels.indexOf(a.value) - severityLevels.indexOf(b.value) + // ) + // : []; + + console.log('facets', facets['vulnerabilities.severity']); + const titleCaseSeverityFacet = facets['vulnerabilities.severity'] + ? facets['vulnerabilities.severity'][0].data.map( + (d: { value: string; count: number }) => { + if ( + d.value === 'null' || + d.value === null || + d.value === '' || + d.value === 'undefined' || + d.value === 'N/A' + ) { + return { value: 'N/A', count: d.count }; + } else { + return { + value: + d.value[0]?.toUpperCase() + d.value.slice(1)?.toLowerCase(), + count: d.count + }; + } + } ) : []; - console.log(facets); - console.log('severityFacet', severityFacet); + console.log('titleCaseSeverityFacet', titleCaseSeverityFacet); + + const groupedData: GroupedData = titleCaseSeverityFacet + .map((d: SeverityData) => { + const severityLevels = [ + 'N/A', + 'Low', + 'Medium', + 'High', + 'Critical', + 'Other' + ]; + if (severityLevels.includes(d.value)) { + return d; + } else { + return { value: 'Other', count: d.count }; + } + }) + .reduce((acc: GroupedData, curr: SeverityData) => { + if (acc[curr.value]) { + acc[curr.value] += curr.count; + } else { + acc[curr.value] = curr.count; + } + return acc; + }, {}); + + console.log('groupedData', groupedData); + + const sortedSeverityFacets = Object.entries(groupedData) + .map(([value, count]) => ({ value, count })) + .sort((a, b) => { + const order = ['N/A', 'Low', 'Medium', 'High', 'Critical', 'Other']; + return order.indexOf(a.value) - order.indexOf(b.value); + }); + + console.log('sortedSeverityFacets', sortedSeverityFacets); return ( @@ -365,7 +431,7 @@ export const DrawerInterior: React.FC = (props) => { )} - {severityFacet.length > 0 && ( + {sortedSeverityFacets.length > 0 && ( = (props) => { addFilter('vulnerabilities.severity', value, 'any') From 7e9723fe8ef4e98f98efc710fb4c5b9f8c9d7edd Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Dec 2024 09:35:52 -0500 Subject: [PATCH 04/10] Cleaned up code - Removed console.logs. - Removed commented out code. --- frontend/src/components/DrawerInterior.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index e4383a14..111c0a53 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -176,13 +176,6 @@ export const DrawerInterior: React.FC = (props) => { ) : []; - // const severityFacet: any[] = facets['vulnerabilities.severity'] - // ? facets['vulnerabilities.severity'][0].data.sort( - // (a: { value: string }, b: { value: string }) => - // severityLevels.indexOf(a.value) - severityLevels.indexOf(b.value) - // ) - // : []; - console.log('facets', facets['vulnerabilities.severity']); const titleCaseSeverityFacet = facets['vulnerabilities.severity'] ? facets['vulnerabilities.severity'][0].data.map( @@ -205,7 +198,6 @@ export const DrawerInterior: React.FC = (props) => { } ) : []; - console.log('titleCaseSeverityFacet', titleCaseSeverityFacet); const groupedData: GroupedData = titleCaseSeverityFacet .map((d: SeverityData) => { @@ -232,8 +224,6 @@ export const DrawerInterior: React.FC = (props) => { return acc; }, {}); - console.log('groupedData', groupedData); - const sortedSeverityFacets = Object.entries(groupedData) .map(([value, count]) => ({ value, count })) .sort((a, b) => { @@ -241,8 +231,6 @@ export const DrawerInterior: React.FC = (props) => { return order.indexOf(a.value) - order.indexOf(b.value); }); - console.log('sortedSeverityFacets', sortedSeverityFacets); - return ( From 443ef4234ecc366fea0e20a5d03d87cf1be53a5c Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Dec 2024 10:31:58 -0500 Subject: [PATCH 05/10] Added sort logic to root domain filter --- frontend/src/components/DrawerInterior.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 111c0a53..47bce71f 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -166,7 +166,10 @@ export const DrawerInterior: React.FC = (props) => { : []; const fromDomainFacet: any[] = facets['fromRootDomain'] - ? facets['fromRootDomain'][0].data + ? facets['fromRootDomain'][0].data.sort( + (a: { value: string }, b: { value: string }) => + a.value.localeCompare(b.value) + ) : []; const cveFacet: any[] = facets['vulnerabilities.cve'] From eadf4093575f426d2fc9d7cd1c7137f418a0368a Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Dec 2024 11:03:02 -0500 Subject: [PATCH 06/10] Updated backend snapshots --- backend/test/__snapshots__/search.test.ts.snap | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/test/__snapshots__/search.test.ts.snap b/backend/test/__snapshots__/search.test.ts.snap index 62bbe255..fbeba217 100644 --- a/backend/test/__snapshots__/search.test.ts.snap +++ b/backend/test/__snapshots__/search.test.ts.snap @@ -57,6 +57,8 @@ Object { "severity": Object { "terms": Object { "field": "vulnerabilities.severity.keyword", + "missing": "null", + "size": 50, }, }, }, @@ -195,6 +197,8 @@ Object { "severity": Object { "terms": Object { "field": "vulnerabilities.severity.keyword", + "missing": "null", + "size": 50, }, }, }, From 563f4c63098dd40b48173395085a9eda943228fc Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Dec 2024 11:22:44 -0500 Subject: [PATCH 07/10] Commented out args in searchSync test --- backend/src/tasks/test/search-sync.test.ts | 134 +++++++++++---------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/backend/src/tasks/test/search-sync.test.ts b/backend/src/tasks/test/search-sync.test.ts index 5e2a9793..184c2f42 100644 --- a/backend/src/tasks/test/search-sync.test.ts +++ b/backend/src/tasks/test/search-sync.test.ts @@ -45,13 +45,14 @@ describe('search_sync', () => { domain }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).not.toBeCalled(); }); @@ -71,13 +72,14 @@ describe('search_sync', () => { updatedAt: new Date('9999-10-11') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).toBeCalled(); }); @@ -97,14 +99,14 @@ describe('search_sync', () => { updatedAt: new Date('9999-9-11') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); - + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).not.toBeCalled(); }); @@ -122,13 +124,14 @@ describe('search_sync', () => { updatedAt: new Date('9999-10-11') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).toBeCalled(); }); @@ -147,13 +150,14 @@ describe('search_sync', () => { updatedAt: new Date('9999-9-11') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).not.toBeCalled(); }); @@ -174,13 +178,14 @@ describe('search_sync', () => { syncedAt: new Date('9999-10-10') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).toBeCalled(); }); @@ -201,13 +206,14 @@ describe('search_sync', () => { syncedAt: new Date('9999-10-10') }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).not.toBeCalled(); }); @@ -233,13 +239,14 @@ describe('search_sync', () => { domain }).save(); - await searchSync({ - organizationId: organization.id, - organizationName: 'organizationName', - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // organizationName: 'organizationName', + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).toBeCalled(); expect( @@ -272,12 +279,13 @@ describe('search_sync', () => { ) ); - await searchSync({ - organizationId: organization.id, - scanId: 'scanId', - scanName: 'scanName', - scanTaskId: 'scanTaskId' - }); + await searchSync(); + // { + // organizationId: organization.id, + // scanId: 'scanId', + // scanName: 'scanName', + // scanTaskId: 'scanTaskId' + // } expect(updateDomains).toBeCalledTimes(2); }); From 537da7e978f372a1121e9b8cfce1795656fc70b1 Mon Sep 17 00:00:00 2001 From: Janson Bunce Date: Wed, 18 Dec 2024 09:42:19 -0800 Subject: [PATCH 08/10] Fixes search-sync test --- backend/src/tasks/search-sync-domains.ts | 10 +++++----- backend/src/tasks/test/search-sync.test.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/src/tasks/search-sync-domains.ts b/backend/src/tasks/search-sync-domains.ts index 8f5749b4..3b158b62 100644 --- a/backend/src/tasks/search-sync-domains.ts +++ b/backend/src/tasks/search-sync-domains.ts @@ -11,7 +11,7 @@ import pRetry from 'p-retry'; export const DOMAIN_CHUNK_SIZE = typeof jest === 'undefined' ? 50 : 10; export const ORGANIZATION_CHUNK_SIZE = typeof jest === 'undefined' ? 50 : 10; -export const handler = async () => { +export const handler = async (organizationId?: string) => { console.log('Running searchSync'); await connectToDatabase(); @@ -33,10 +33,10 @@ export const handler = async () => { .groupBy('domain.id, organization.id, vulnerabilities.id, services.id') .select(['domain.id']); - // if (organizationId) { - // // This parameter is used for testing only - // qs.where('organization.id=:org', { org: organizationId }); - // } + if (organizationId) { + // This parameter is used for testing only + qs.where('organization.id=:org', { org: organizationId }); + } qs.andWhere( '(domain."isFceb" = true OR (domain."isFceb" = false AND domain."fromCidr" = true))' diff --git a/backend/src/tasks/test/search-sync.test.ts b/backend/src/tasks/test/search-sync.test.ts index 184c2f42..c49384c7 100644 --- a/backend/src/tasks/test/search-sync.test.ts +++ b/backend/src/tasks/test/search-sync.test.ts @@ -45,7 +45,7 @@ describe('search_sync', () => { domain }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -72,7 +72,7 @@ describe('search_sync', () => { updatedAt: new Date('9999-10-11') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -99,7 +99,7 @@ describe('search_sync', () => { updatedAt: new Date('9999-9-11') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -124,7 +124,7 @@ describe('search_sync', () => { updatedAt: new Date('9999-10-11') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -150,7 +150,7 @@ describe('search_sync', () => { updatedAt: new Date('9999-9-11') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -178,7 +178,7 @@ describe('search_sync', () => { syncedAt: new Date('9999-10-10') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -206,7 +206,7 @@ describe('search_sync', () => { syncedAt: new Date('9999-10-10') }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -239,7 +239,7 @@ describe('search_sync', () => { domain }).save(); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // organizationName: 'organizationName', @@ -279,7 +279,7 @@ describe('search_sync', () => { ) ); - await searchSync(); + await searchSync(organization.id); // { // organizationId: organization.id, // scanId: 'scanId', From 86bb333b5698ee62a8f3f17232bb706300a85dfe Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 18 Dec 2024 14:15:53 -0500 Subject: [PATCH 09/10] Removed console.logs and commented out code --- backend/src/tasks/test/search-sync.test.ts | 63 +--------------------- frontend/src/components/DrawerInterior.tsx | 1 - 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/backend/src/tasks/test/search-sync.test.ts b/backend/src/tasks/test/search-sync.test.ts index c49384c7..6a72ce2b 100644 --- a/backend/src/tasks/test/search-sync.test.ts +++ b/backend/src/tasks/test/search-sync.test.ts @@ -46,13 +46,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).not.toBeCalled(); }); @@ -73,13 +66,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).toBeCalled(); }); @@ -100,13 +86,7 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } + expect(updateDomains).not.toBeCalled(); }); @@ -125,13 +105,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).toBeCalled(); }); @@ -151,13 +124,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).not.toBeCalled(); }); @@ -179,13 +145,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).toBeCalled(); }); @@ -207,13 +166,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).not.toBeCalled(); }); @@ -240,13 +192,6 @@ describe('search_sync', () => { }).save(); await searchSync(organization.id); - // { - // organizationId: organization.id, - // organizationName: 'organizationName', - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).toBeCalled(); expect( @@ -280,12 +225,6 @@ describe('search_sync', () => { ); await searchSync(organization.id); - // { - // organizationId: organization.id, - // scanId: 'scanId', - // scanName: 'scanName', - // scanTaskId: 'scanTaskId' - // } expect(updateDomains).toBeCalledTimes(2); }); diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 47bce71f..002687c7 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -179,7 +179,6 @@ export const DrawerInterior: React.FC = (props) => { ) : []; - console.log('facets', facets['vulnerabilities.severity']); const titleCaseSeverityFacet = facets['vulnerabilities.severity'] ? facets['vulnerabilities.severity'][0].data.map( (d: { value: string; count: number }) => { From 73b1a8eea9fc7489685af0adc3ac05e290c22258 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 23 Dec 2024 11:43:32 -0500 Subject: [PATCH 10/10] Refined if check for N/A severity level values - Now includes permutations of NUll, N/A, empty string, and undefined values. --- frontend/src/components/DrawerInterior.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/DrawerInterior.tsx b/frontend/src/components/DrawerInterior.tsx index 002687c7..25be18ad 100644 --- a/frontend/src/components/DrawerInterior.tsx +++ b/frontend/src/components/DrawerInterior.tsx @@ -179,14 +179,16 @@ export const DrawerInterior: React.FC = (props) => { ) : []; + // To-Do: Create array(s) to handle permutations of null and N/A values const titleCaseSeverityFacet = facets['vulnerabilities.severity'] ? facets['vulnerabilities.severity'][0].data.map( (d: { value: string; count: number }) => { if ( - d.value === 'null' || d.value === null || + d.value === 'null' || + d.value === 'NULL' || + d.value === undefined || d.value === '' || - d.value === 'undefined' || d.value === 'N/A' ) { return { value: 'N/A', count: d.count };