Skip to content

Commit

Permalink
Edited DrawerInterior.tsx to fix filter sort
Browse files Browse the repository at this point in the history
- Added sort to portFacet.
- Added sort to cveFacet.
- Severity levels are now sorted in order of Low, Medium, High, Critical.
  • Loading branch information
hawkishpolicy committed Dec 5, 2024
1 parent 3e772fd commit 186bbdc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/components/DrawerInterior.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,28 @@ export const DrawerInterior: React.FC<Props> = (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']
? facets['fromRootDomain'][0].data
: [];

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']
? facets['vulnerabilities.severity'][0].data
: [];

// 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 });
}
Expand Down

0 comments on commit 186bbdc

Please sign in to comment.