Skip to content

Commit 9604018

Browse files
committed
Add CRITICAL severity handling and update badge styles
1 parent 92472b6 commit 9604018

File tree

10 files changed

+74
-30
lines changed

10 files changed

+74
-30
lines changed

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,23 @@
201201
.badge-wrapper-CRITICAL .Polaris-Badge {
202202
background-color: #E45357 !important;
203203
color: white !important;
204+
font-weight: 500 !important;
204205
}
205206

206207
.badge-wrapper-HIGH .Polaris-Badge {
207208
background-color: #EF864C !important;
208209
color: white !important;
210+
font-weight: 500 !important;
209211
}
210212

211213
.badge-wrapper-MEDIUM .Polaris-Badge {
212214
background-color: #F6C564 !important;
213215
color: white !important;
216+
font-weight: 500 !important;
214217
}
215218

216219
.badge-wrapper-LOW .Polaris-Badge {
217220
background-color: #6FD1A6;
218221
color: white !important;
222+
font-weight: 500 !important;
219223
}

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/HomeDashboard.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function HomeDashboard() {
114114
finalResult.push({
115115
"testName": x["name"],
116116
"time": func.prettifyEpoch(x["run_time_epoch"]),
117+
"criticalCount": severityMap["critical"] ? severityMap["critical"] : "0",
117118
"highCount": severityMap["high"] ? severityMap["high"] : "0",
118119
"mediumCount": severityMap["medium"] ? severityMap["medium"] : "0",
119120
"lowCount": severityMap["low"] ? severityMap["low"] : "0",
@@ -450,7 +451,7 @@ function HomeDashboard() {
450451
) : null
451452

452453
function buildSeverityMap(severityInfo) {
453-
const countMap = { HIGH: 0, MEDIUM: 0, LOW: 0 }
454+
const countMap = { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 }
454455

455456
if (severityInfo && severityInfo != undefined && severityInfo != null && severityInfo instanceof Object) {
456457
for (const apiCollectionId in severityInfo) {
@@ -462,6 +463,11 @@ function HomeDashboard() {
462463
}
463464

464465
const result = {
466+
"Critical": {
467+
"text": countMap.CRITICAL || 0,
468+
"color": "#E45357",
469+
"filterKey": "Critical"
470+
},
465471
"High": {
466472
"text": countMap.HIGH || 0,
467473
"color": "#EF864C",

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/new_components/TestSummaryCard.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ function TestSummaryCard({ summaryItem }) {
1818
<VerticalStack gap={2}>
1919
<Text color='subdued' variant='headingXs' fontWeight='semibold'>Issues Found</Text>
2020
<HorizontalStack gap={2}>
21-
<Badge size="small" status="critical">{summaryItem.highCount}</Badge>
22-
<Badge size="small" status="warning">{summaryItem.mediumCount}</Badge>
23-
<Badge size="small" status="info">{summaryItem.lowCount}</Badge>
21+
<div className='badge-wrapper-CRITICAL'>
22+
<Badge size="small" status="critical">{summaryItem.criticalCount}</Badge>
23+
</div>
24+
25+
<div className='badge-wrapper-HIGH'>
26+
<Badge size="small" status="critical">{summaryItem.highCount}</Badge>
27+
</div>
28+
29+
<div className='badge-wrapper-MEDIUM'>
30+
<Badge size="small" status="warning">{summaryItem.mediumCount}</Badge>
31+
</div>
32+
33+
<div className='badge-wrapper-LOW'>
34+
<Badge size="small" status="info">{summaryItem.lowCount}</Badge>
35+
</div>
2436
</HorizontalStack>
2537
</VerticalStack>
2638
<VerticalStack gap={2}>

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/transform.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ const transform = {
403403
{
404404
Object.keys(severityInfo).length > 0 ? Object.keys(severityInfo).map((key,index)=>{
405405
return(
406-
<Badge size="small" status={this.getColor(key)} key={index}>{severityInfo[key].toString()}</Badge>
406+
<div className={`badge-wrapper-${key}`}>
407+
<Badge size="small" key={index}>{severityInfo[key].toString()}</Badge>
408+
</div>
407409
)
408410
}):
409411
<Text fontWeight="regular" variant="bodyMd" color="subdued">-</Text>

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/SingleTestRunPage/SingleTestRunPage.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,7 @@ const editableConfigsComp = (
701701
const tempSev = sev.length > 1 ? sev[1].toUpperCase() : ''
702702
return(
703703
<div className={`badge-wrapper-${tempSev}`}>
704-
<Badge key={item}>
705-
<Text fontWeight="regular">
706-
{item}
707-
</Text>
708-
</Badge>
704+
<Badge key={item}>{item}</Badge>
709705
</div>
710706
)
711707
}

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/TestRunsPage/TestRunsPage.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ const tableCountObj = func.getTabsCount(definedTableTabs, {}, initialCount)
149149
const tableTabs = func.getTableTabsContent(definedTableTabs, tableCountObj, setCurrentTab, currentTab, tabsInfo)
150150

151151
const [severityCountMap, setSeverityCountMap] = useState({
152-
HIGH: {text : 0, color: func.getColorForCharts("HIGH")},
153-
MEDIUM: {text : 0, color: func.getColorForCharts("MEDIUM")},
154-
LOW: {text : 0, color: func.getColorForCharts("LOW")},
152+
CRITICAL: {text : 0, color: func.getHexColorForSeverity("CRITICAL")},
153+
HIGH: {text : 0, color: func.getHexColorForSeverity("HIGH")},
154+
MEDIUM: {text : 0, color: func.getHexColorForSeverity("MEDIUM")},
155+
LOW: {text : 0, color: func.getHexColorForSeverity("LOW")},
155156
})
156157
const [subCategoryInfo, setSubCategoryInfo] = useState({})
157158
const [collapsible, setCollapsible] = useState(true)
@@ -295,7 +296,14 @@ const SummaryCardComponent = () =>{
295296
<Box paddingBlockStart={3}><Divider/></Box>
296297
<HorizontalGrid columns={2} gap={6}>
297298
<ChartypeComponent navUrl={"/dashboard/issues/"} data={subCategoryInfo} title={"Categories"} isNormal={true} boxHeight={'250px'}/>
298-
<ChartypeComponent data={severityCountMap} reverse={true} title={"Severity"} charTitle={totalVulnerabilities} chartSubtitle={"Total Vulnerabilities"}/>
299+
{/* <ChartypeComponent data={severityCountMap} reverse={true} title={"Severity"} charTitle={totalVulnerabilities} chartSubtitle={"Total Vulnerabilities"}/> */}
300+
<div style={{ marginTop: "20px" }}>
301+
<ChartypeComponent
302+
data={severityCountMap}
303+
navUrl={"/dashboard/issues/"} title={"Severity"} isNormal={true} boxHeight={'250px'} dataTableWidth="250px" boxPadding={0}
304+
pieInnerSize="50%"
305+
/>
306+
</div>
299307
</HorizontalGrid>
300308

301309
</LegacyCard.Subsection>

apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/transform.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ getInfoSectionsHeaders(){
710710
convertSubIntoSubcategory(resp){
711711
let obj = {}
712712
let countObj = {
713+
CRITICAL: 0,
713714
HIGH: 0,
714715
MEDIUM: 0,
715716
LOW: 0,

apps/dashboard/web/polaris_web/web/src/util/func.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,14 @@ mapCollectionIdToHostName(apiCollections){
13201320
},
13211321
getHexColorForSeverity(key){
13221322
switch(key){
1323+
case "CRITICAL":
1324+
return "#E45357"
13231325
case "HIGH":
1324-
return "#D72C0D"
1326+
return "#EF864C"
13251327
case "MEDIUM":
1326-
return "#FFD79D"
1328+
return "#F6C564"
13271329
case "LOW":
1328-
return "#2C6ECB"
1330+
return "#6FD1A6"
13291331
default:
13301332
return "#2C6ECB"
13311333
}

libs/dao/src/main/java/com/akto/dao/testing_run_findings/TestingRunIssuesDao.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.akto.dao.testing_run_findings;
22

3-
import java.util.ArrayList;
4-
import java.util.HashMap;
5-
import java.util.List;
6-
import java.util.Map;
3+
import java.util.*;
74

85
import org.bson.conversions.Bson;
96

@@ -108,19 +105,27 @@ public Map<Integer,Map<String,Integer>> getSeveritiesMapForCollections(Bson filt
108105
String severity = ((BasicDBObject) basicDBObject.get("_id")).getString("severity");
109106
int apiCollectionId = ((BasicDBObject) basicDBObject.get("_id")).getInt("apiCollectionId");
110107
int count = basicDBObject.getInt("count");
111-
if(resultMap.containsKey(apiCollectionId)){
112-
Map<String,Integer> severityMap = resultMap.get(apiCollectionId);
113-
severityMap.put(severity, count);
114-
}else{
115-
Map<String,Integer> severityMap = new HashMap<>();
116-
severityMap.put(severity, count);
117-
resultMap.put(apiCollectionId, severityMap);
118-
}
108+
resultMap.computeIfAbsent(apiCollectionId, k -> new LinkedHashMap<>());
109+
Map<String, Integer> severityMap = resultMap.get(apiCollectionId);
110+
111+
severityMap.put(severity, count);
119112

120113
} catch (Exception e) {
121114
e.printStackTrace();
122115
}
123116
}
117+
118+
String[] severityOrder = GlobalEnums.Severity.getNames();
119+
resultMap.forEach((apiCollectionId, severityMap) -> {
120+
Map<String, Integer> orderedMap = new LinkedHashMap<>();
121+
for (String severity : severityOrder) {
122+
if (severityMap.containsKey(severity)) {
123+
orderedMap.put(severity, severityMap.get(severity));
124+
}
125+
}
126+
resultMap.put(apiCollectionId, orderedMap);
127+
});
128+
124129
return resultMap;
125130
}
126131

libs/dao/src/main/java/com/akto/util/enums/GlobalEnums.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.akto.util.enums;
22

3+
import java.util.Arrays;
4+
35
public class GlobalEnums {
46
/* * * * * * * * Enums for Testing run issues * * * * * * * * * * * * */
57

@@ -95,7 +97,13 @@ public enum Severity {
9597
HIGH,
9698
MEDIUM,
9799
LOW,
98-
INFO
100+
INFO;
101+
102+
public static String[] getNames() {
103+
return Arrays.stream(Severity.values())
104+
.map(Enum::name)
105+
.toArray(String[]::new);
106+
}
99107
}
100108

101109
public enum TestRunIssueStatus {

0 commit comments

Comments
 (0)