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

Update severity handling to use 'Critical' label and refactor severit… #1993

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SummaryInfo = ({ startTimestamp, endTimestamp }) => {
smoothChartComponent: (<SmoothAreaChart tickPositions={openIssues} />)
},
{
title: 'High',
title: 'Critical',
data: criticalIssues[criticalIssues.length-1],
variant: 'heading2xl',
color: 'critical',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import GithubServerTable from "../../../components/tables/GithubServerTable";
import {Text,IndexFiltersMode, LegacyCard, HorizontalStack, Button, Collapsible, HorizontalGrid, Box, Divider} from '@shopify/polaris';
import { ChevronDownMinor , ChevronUpMinor } from '@shopify/polaris-icons';
import api from "../api";
import testingApi from "../../testing/api";
import { useEffect, useReducer, useState } from 'react';
import transform from "../transform";
import PageWithMultipleCards from "../../../components/layouts/PageWithMultipleCards";
Expand Down Expand Up @@ -148,12 +149,7 @@ const [selected, setSelected] = useState(initialTabIdx)
const tableCountObj = func.getTabsCount(definedTableTabs, {}, initialCount)
const tableTabs = func.getTableTabsContent(definedTableTabs, tableCountObj, setCurrentTab, currentTab, tabsInfo)

const [severityCountMap, setSeverityCountMap] = useState({
CRITICAL: {text : 0, color: func.getHexColorForSeverity("CRITICAL")},
HIGH: {text : 0, color: func.getHexColorForSeverity("HIGH")},
MEDIUM: {text : 0, color: func.getHexColorForSeverity("MEDIUM")},
LOW: {text : 0, color: func.getHexColorForSeverity("LOW")},
})
const [severityMap, setSeverityMap] = useState({})
const [subCategoryInfo, setSubCategoryInfo] = useState({})
const [collapsible, setCollapsible] = useState(true)
const [hasUserInitiatedTestRuns, setHasUserInitiatedTestRuns] = useState(false)
Expand Down Expand Up @@ -249,12 +245,43 @@ function processData(testingRuns, latestTestingRunResultSummaries, cicd){
await api.getSummaryInfo(startTimestamp, endTimestamp).then((resp)=>{
const severityObj = transform.convertSubIntoSubcategory(resp)
setSubCategoryInfo(severityObj.subCategoryMap)
const severityMap = severityObj.countMap;
let tempMap = JSON.parse(JSON.stringify(severityCountMap))
Object.keys(tempMap).forEach((key) => {
tempMap[key].text = severityMap[key]
})
setSeverityCountMap(tempMap)
})
await testingApi.fetchSeverityInfoForIssues({}, [], 0).then(({ severityInfo }) => {
const countMap = { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 }

if (severityInfo && severityInfo != undefined && severityInfo != null && severityInfo instanceof Object) {
for (const apiCollectionId in severityInfo) {
let temp = severityInfo[apiCollectionId]
for (const key in temp) {
countMap[key] += temp[key]
}
}
}

const result = {
"CRITICAL": {
"text": countMap.CRITICAL || 0,
"color": func.getHexColorForSeverity("CRITICAL"),
"filterKey": "Critical"
},
"HIGH": {
"text": countMap.HIGH || 0,
"color": func.getHexColorForSeverity("HIGH"),
"filterKey": "High"
},
"MEDIUM": {
"text": countMap.MEDIUM || 0,
"color": func.getHexColorForSeverity("MEDIUM"),
"filterKey": "Medium"
},
"LOW": {
"text": countMap.LOW || 0,
"color": func.getHexColorForSeverity("LOW"),
"filterKey": "Low"
}
}

setSeverityMap(result)
})
}

Expand Down Expand Up @@ -282,7 +309,7 @@ function processData(testingRuns, latestTestingRunResultSummaries, cicd){

const iconSource = collapsible ? ChevronUpMinor : ChevronDownMinor
const SummaryCardComponent = () =>{
let totalVulnerabilities = severityCountMap?.HIGH?.text + severityCountMap?.MEDIUM?.text + severityCountMap?.LOW?.text
let totalVulnerabilities = severityMap?.CRITICAL?.text + severityMap?.HIGH?.text + severityMap?.MEDIUM?.text + severityMap?.LOW?.text
return(
<LegacyCard>
<LegacyCard.Section title={<Text fontWeight="regular" variant="bodySm" color="subdued">Vulnerabilities</Text>}>
Expand All @@ -296,9 +323,8 @@ const SummaryCardComponent = () =>{
<Box paddingBlockStart={3}><Divider/></Box>
<HorizontalGrid columns={2} gap={6}>
<ChartypeComponent navUrl={"/dashboard/issues/"} data={subCategoryInfo} title={"Categories"} isNormal={true} boxHeight={'250px'}/>
{/* <ChartypeComponent data={severityCountMap} reverse={true} title={"Severity"} charTitle={totalVulnerabilities} chartSubtitle={"Total Vulnerabilities"}/> */}
<ChartypeComponent
data={severityCountMap}
data={severityMap}
navUrl={"/dashboard/issues/"} title={"Severity"} isNormal={true} boxHeight={'250px'} dataTableWidth="250px" boxPadding={8}
pieInnerSize="50%"
/>
Expand Down
Loading