Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edited VulnerabilityCard Severity Level Formatting (CRASM-1056) #748

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions frontend/src/pages/Risk/VulnerabilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ const VulnerabilityCard = (props: {
) => history.push(filteredVulnTableLink, { title: title });

const vulnerabilityGridContent = data.slice(0, 10).map((vuln) => {
const titleCase = (severity?: any) =>
severity.charAt(0).toUpperCase() + severity.slice(1).toLowerCase();
const severitylevels = [
'N/A',
'Low',
'Medium',
'High',
'Critical',
'Other'
];
const formatSeverity = (severity?: any) => {
const titleCaseSev = titleCase(severity);
if (severitylevels.includes(titleCaseSev)) {
return titleCaseSev;
}
if (
!titleCaseSev ||
['Null', 'N/a', 'undefined', ''].includes(titleCaseSev)
) {
return 'N/A';
} else {
return 'Other';
}
};
const formattedSeverity = formatSeverity(vuln.severity);
const filteredVulnTableLink = '/inventory/vulnerabilities';
const ariaLabel = `Details link to the vulnerabilities table filtered to ${vuln.title}.`;
const onRowKeyDown = (event: React.KeyboardEvent) => {
Expand Down Expand Up @@ -96,13 +121,13 @@ const VulnerabilityCard = (props: {
component="p"
sx={{
borderBottom: `6px solid ${getSeverityColor({
id: vuln.severity ?? ''
id: formattedSeverity ?? 'N/A'
})}`,
width: '80px',
display: 'inline-block'
}}
>
{vuln.severity}
{formattedSeverity}
</Box>
</TableCell>
<TableCell scope="row" padding="none" align="center">
Expand Down
Loading