diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx index 8a76a9e200..02e9e2f2d5 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/CollectionComponent.jsx @@ -25,7 +25,7 @@ function CollectionComponent(props) { const { condition, index, dispatch, operatorComponent } = props const [apiEndpoints, setApiEndpoints] = useState({}) const initialRegexText = (condition && condition?.type === 'REGEX') ? (condition?.data?.regex || '') : '' - const initialHostRegexText = (condition && condition?.type === 'HOST_REGEX') ? (condition?.data?.host_regex || '') : '' + const initialHostRegexText = (condition && condition?.type === 'HOST_REGEX') ? (condition?.data?.regex || '') : '' const [regexText, setRegexText] = useState(initialRegexText) const [hostRegexText, setHostRegexText] = useState(initialHostRegexText) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/TitleWithInfo.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/TitleWithInfo.jsx index 1805d045b9..4d6518640a 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/TitleWithInfo.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/TitleWithInfo.jsx @@ -42,9 +42,9 @@ function TitleWithInfo({titleComp, textProps, titleText, tooltipContent, docsUrl {content} - :
+ : tooltipContent ?
-
+
: null } ) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/HomeDashboard.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/HomeDashboard.jsx index 8fb327d780..56c0cff74e 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/HomeDashboard.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/HomeDashboard.jsx @@ -29,7 +29,6 @@ import CriticalFindingsGraph from '../issues/IssuesPage/CriticalFindingsGraph'; function HomeDashboard() { const [loading, setLoading] = useState(true); - const [skip, setSkip] = useState(0) const [showBannerComponent, setShowBannerComponent] = useState(false) const [testSummaryInfo, setTestSummaryInfo] = useState([]) @@ -52,6 +51,7 @@ function HomeDashboard() { const initialStartTimestamp = func.timeNow() - 60 * 60 * 24 const initialEndTimestamp = func.timeNow() const [showTestingComponents, setShowTestingComponents] = useState(false) + const [customRiskScoreAvg, setCustomRiskScoreAvg] = useState(0) const tempVal = { alias: "custom", title: "Custom", period: { since: new Date(initialStartTimestamp * 1000), until: new Date(initialEndTimestamp * 1000) } } @@ -332,6 +332,21 @@ function HomeDashboard() { function buildSetRiskScoreData(apiStats) { const totalApisCount = apiStats.totalAPIs + let tempScore = 0, tempTotal = 0 + Object.keys(apiStats.riskScoreMap).forEach((x) => { + if(x > 1){ + const apisVal = apiStats.riskScoreMap[x] + tempScore += (x * apisVal) + tempTotal += apisVal + } + }) + if(tempScore > 0 && tempTotal > 0){ + let val = (tempScore * 1.0)/tempTotal + if(val >= 2){ + setCustomRiskScoreAvg(val) + } + } + const sumOfRiskScores = Object.values(apiStats.riskScoreMap).reduce((acc, value) => acc + value, 0); // Calculate the additional APIs that should be added to risk score "0" @@ -395,15 +410,17 @@ function HomeDashboard() { variant: 'heading2xl', color: 'critical', byLineComponent: observeFunc.generateByLineComponent((totalIssuesCount - oldIssueCount), func.timeDifference(startTimestamp, endTimestamp)), - smoothChartComponent: () + smoothChartComponent: (), }, { title: 'API Risk Score', - data: apiRiskScore, + data: customRiskScoreAvg !== 0 ? customRiskScoreAvg : apiRiskScore, variant: 'heading2xl', - color: apiRiskScore > 2.5 ? 'critical' : 'warning', + color: (customRiskScoreAvg > 2.5 || apiRiskScore > 2.5) ? 'critical' : 'warning', byLineComponent: observeFunc.generateByLineComponent((apiRiskScore - oldRiskScore).toFixed(2), func.timeDifference(startTimestamp, endTimestamp)), - smoothChartComponent: () + smoothChartComponent: (), + tooltipContent: 'This represents a cumulative risk score for the whole dashboard', + docsUrl: 'https://docs.akto.io/api-discovery/concepts/risk-score' }, { title: 'Test Coverage', diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/new_components/SummaryCard.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/new_components/SummaryCard.jsx index 199b70526b..c5de51ec5c 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/new_components/SummaryCard.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/dashboard/new_components/SummaryCard.jsx @@ -1,5 +1,6 @@ import { Box, Card, HorizontalGrid, HorizontalStack, Text, VerticalStack } from '@shopify/polaris' import React from 'react' +import TitleWithInfo from '../../../components/shared/TitleWithInfo' function SummaryCard({ summaryItems }) { return ( @@ -10,9 +11,15 @@ function SummaryCard({ summaryItems }) { - - {item.title} - + + {item.title} + + } + docsUrl={item?.docsUrl} + tooltipContent={item?.tooltipContent} + /> {item?.isComp ? item.data : diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/CriticalFindingsGraph.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/CriticalFindingsGraph.jsx index 15a4c9b330..1121e85e3e 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/CriticalFindingsGraph.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/issues/IssuesPage/CriticalFindingsGraph.jsx @@ -12,10 +12,14 @@ const CriticalFindingsGraph = ({ linkText, linkUrl }) => { const [showTestingComponents, setShowTestingComponents] = useState(false) function convertSubCategoryInfo(tempSubCategoryMap) { - const entries = Object.values(tempSubCategoryMap); + const entries = Object.keys(tempSubCategoryMap).map((x) => { + let tempObj = tempSubCategoryMap[x]; + tempObj.key = x + return tempObj + }) entries.sort((a, b) => b.text - a.text); const topEntries = entries.slice(0, 5); - const data = topEntries.map(entry => {return {text: entry.filterKey, value: entry.text, color: entry.color}}); + const data = topEntries.map(entry => {return {text: entry.key, value: entry.text, color: entry.color}}); setCriticalFindingsData(data) } diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/APIQuery.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/APIQuery.jsx index 12cec94a0d..7d057ecb45 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/APIQuery.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/observe/api_collections/APIQuery.jsx @@ -57,7 +57,11 @@ function APIQuery() { const getApiCollection = () => { collectionsApi.getCollection(collectionId).then((res) => { (res[0].conditions || []).forEach((x, index) => { - const tempEmptyCondition = getEmptyCondition(x.type) + let tempKey = x.type + if(x.actualType && x?.actualType !== undefined){ + tempKey = x.actualType + } + const tempEmptyCondition = getEmptyCondition(tempKey) dispatchConditions({ type: "add", obj: tempEmptyCondition }) dispatchConditions({ type: "updateKey", index: index, key: "operator", obj: x.operator }) if(x.type === 'CUSTOM'){ diff --git a/libs/dao/src/main/java/com/akto/dto/testing/HostRegexTestingEndpoints.java b/libs/dao/src/main/java/com/akto/dto/testing/HostRegexTestingEndpoints.java index 1fea02c5fe..df46734abe 100644 --- a/libs/dao/src/main/java/com/akto/dto/testing/HostRegexTestingEndpoints.java +++ b/libs/dao/src/main/java/com/akto/dto/testing/HostRegexTestingEndpoints.java @@ -6,6 +6,7 @@ import com.akto.dto.ApiInfo; import com.akto.dto.type.SingleTypeInfo; import com.mongodb.client.model.Filters; + import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; import org.bson.codecs.pojo.annotations.BsonIgnore; @@ -35,6 +36,18 @@ public HostRegexTestingEndpoints() { super(Type.REGEX, Operator.OR); } + + @BsonIgnore + Type actualType; + + public Type getActualType() { + return Type.HOST_REGEX; + } + + public void setActualType(Type actualType) { + this.actualType = Type.HOST_REGEX; + } + @Override public List returnApis() { throw new NotImplementedException();