Skip to content

Commit

Permalink
Merge pull request #1993 from akto-api-security/hotfix/critical_issue…
Browse files Browse the repository at this point in the history
…s_badge

Update severity handling to use 'Critical' label and refactor severit…
  • Loading branch information
Ark2307 authored Jan 17, 2025
2 parents b38ea96 + 3f59900 commit a4a6ce9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
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

0 comments on commit a4a6ce9

Please sign in to comment.