-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add filters per severity on vulnerabilities, misconfigurations …
…and secrets (#64)
- Loading branch information
1 parent
d7f3168
commit 17d6bc7
Showing
9 changed files
with
204 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* SeverityToolbar.css */ | ||
.ant-btn { | ||
border: none; | ||
margin-right: 8px; | ||
} | ||
|
||
.ant-space-item:last-child .ant-btn { | ||
margin-right: 0; | ||
} |
72 changes: 72 additions & 0 deletions
72
src/frontend-app/src/components/shared/SeverityToolbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Button, Space } from 'antd'; | ||
import './SeverityToolbar.css'; | ||
import { NormalizedResultForDataTable } from '../../types'; | ||
import { SeverityCount } from '../../types/ui/index.ts'; | ||
|
||
interface SeverityToolbarProps { | ||
result: NormalizedResultForDataTable[]; | ||
onSeverityClick: (severity: string) => void; | ||
} | ||
|
||
const SeverityToolbar: React.FC<SeverityToolbarProps> = ({ result, onSeverityClick }) => { | ||
const [resultsPerSeverity, setResultsPerSeverity] = useState<SeverityCount[]>([]); | ||
|
||
useEffect(() => { | ||
const tmpResult = { | ||
critical: 0, | ||
high: 0, | ||
medium: 0, | ||
low: 0, | ||
negligible: 0 | ||
}; | ||
|
||
result.forEach(item => { | ||
switch (item.Severity?.toLowerCase()) { | ||
case 'critical': | ||
tmpResult.critical += 1; | ||
break; | ||
case 'high': | ||
tmpResult.high += 1; | ||
break; | ||
case 'medium': | ||
tmpResult.medium += 1; | ||
break; | ||
case 'low': | ||
tmpResult.low += 1; | ||
break; | ||
default: | ||
tmpResult.negligible += 1; | ||
break; | ||
} | ||
}); | ||
|
||
setResultsPerSeverity([ | ||
{ severity: 'Critical', count: tmpResult.critical, color: '#FF6666' }, | ||
{ severity: 'High', count: tmpResult.high, color: '#FF9966' }, | ||
{ severity: 'Medium', count: tmpResult.medium, color: '#FFCC66' }, | ||
{ severity: 'Low', count: tmpResult.low, color: '#FFFF99' }, | ||
{ severity: 'Negligible', count: tmpResult.negligible, color: '#CCFFFF' }, | ||
{ severity: 'All', count: result.length, color: '#DDEE' }, | ||
]); | ||
}, [result]); | ||
|
||
return ( | ||
<Space> | ||
{resultsPerSeverity.map(({ severity, count, color }) => ( | ||
<Button | ||
key={severity} | ||
style={{ | ||
backgroundColor: color, | ||
color: '#000', // Set text color to black | ||
}} | ||
onClick={() => onSeverityClick(severity.toLowerCase())} | ||
> | ||
{count} {severity} | ||
</Button> | ||
))} | ||
</Space> | ||
); | ||
}; | ||
|
||
export default SeverityToolbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.