-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1211 from akto-api-security/feature/improve-vulne…
…rability-report Feature/improve vulnerability report
- Loading branch information
Showing
20 changed files
with
995 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,6 +398,5 @@ export default { | |
method: 'post', | ||
data: {} | ||
}) | ||
} | ||
|
||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...rd/web/polaris_web/web/src/apps/dashboard/pages/testing/vulnerability_report/Category.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Box, Divider, Link, Text, VerticalStack } from "@shopify/polaris" | ||
import ReportSummaryInfoCard from "./ReportSummaryInfoCard" | ||
import Issue from "./Issue" | ||
|
||
function Category({ index, categoryName, categoryIssues, categoryMap, categoryVsApisCountMap }) { | ||
|
||
const categoryDisplayName = categoryMap?.[categoryName]?.displayName || "" | ||
|
||
const categorySummaryItems = [ | ||
{ | ||
title: "Total issues", | ||
data: categoryIssues.length, | ||
}, | ||
{ | ||
title: "APIs affected", | ||
data: categoryVsApisCountMap[categoryName] | ||
} | ||
] | ||
|
||
return ( | ||
<Box id={categoryName} paddingBlockStart={6} paddingBlockEnd={8} paddingInlineStart={5} paddingInlineEnd={5}> | ||
<VerticalStack gap="4"> | ||
<Text variant='headingMd'> | ||
2.{index + 1} {categoryDisplayName} | ||
</Text> | ||
|
||
<ReportSummaryInfoCard summaryItems={categorySummaryItems} /> | ||
|
||
<Box> | ||
<VerticalStack gap="2"> | ||
<Text variant='headingSm'> | ||
Issues | ||
</Text> | ||
<VerticalStack gap="2"> | ||
{categoryIssues.length > 0 && categoryIssues.map((issueDetails, index) => { | ||
const name = issueDetails?.name | ||
const testName = issueDetails?.testName | ||
return ( | ||
<Link key={index} url={`#${name}`} removeUnderline> | ||
<Text variant='bodySm' color='subdued'> | ||
{index + 1}. {testName} | ||
</Text> | ||
</Link> | ||
) | ||
})} | ||
</VerticalStack> | ||
</VerticalStack> | ||
</Box> | ||
|
||
<Divider/> | ||
|
||
<Box> | ||
{categoryIssues.map((issueDetails, index) => { | ||
return ( | ||
<Issue key={index} issueDetails={issueDetails} index={index} isLast={index === categoryIssues.length - 1}/> | ||
) | ||
})} | ||
</Box> | ||
|
||
</VerticalStack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default Category |
125 changes: 125 additions & 0 deletions
125
...board/web/polaris_web/web/src/apps/dashboard/pages/testing/vulnerability_report/Issue.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { Box, Divider, HorizontalStack, Link, Text, VerticalStack } from "@shopify/polaris" | ||
import { useEffect, useState } from "react" | ||
import GetPrettifyEndpoint from '@/apps/dashboard/pages/observe/GetPrettifyEndpoint'; | ||
import GithubSimpleTable from "@/apps/dashboard/components/tables/GithubSimpleTable"; | ||
|
||
function Issue({ index, issueDetails, isLast }) { | ||
const [vulnerableApisState, setVulnerableApisState] = useState([]) | ||
|
||
const removeTrailingQuotes = (str) => { | ||
return str.replace(/['"]+/g, '') | ||
} | ||
|
||
const getTestResultLink = () => { | ||
if (issueDetails.vulnerableTestingRunResults.length === 0) { | ||
return '' | ||
} | ||
|
||
const firstVulnerableApi = issueDetails.vulnerableTestingRunResults[0] | ||
const testRunResultSummaryHexId = firstVulnerableApi.testRunHexId | ||
const testRunId = firstVulnerableApi.hexId | ||
|
||
return `/dashboard/testing/${testRunResultSummaryHexId}/result/${testRunId}` | ||
} | ||
const testResultLink = getTestResultLink() | ||
|
||
const name = issueDetails?.name | ||
const testName = issueDetails?.testName | ||
const issueDescription = removeTrailingQuotes(issueDetails?.issueDescription) | ||
const issueImpact = removeTrailingQuotes(issueDetails?.issueImpact) | ||
|
||
const vulnerableApisCount = issueDetails?.vulnerableTestingRunResults.length | ||
|
||
const resourceName = { | ||
singular: 'API', | ||
plural: 'APIs', | ||
}; | ||
|
||
const apisHeader = ( | ||
<HorizontalStack align="space-between"> | ||
<Text variant="headingXs" fontWeight='bold'>{vulnerableApisCount} {vulnerableApisCount === 1 ? resourceName.singular : resourceName.plural} affected</Text> | ||
<Link url={testResultLink} removeUnderline target="_blank"> | ||
<Text variant='bodyMd'>See in akto</Text> | ||
</Link> | ||
</HorizontalStack> | ||
|
||
) | ||
const headers = [ | ||
{ | ||
text: apisHeader, | ||
title: apisHeader, | ||
value: 'apiDetails', | ||
textValue: 'apiDetailsText' | ||
} | ||
] | ||
|
||
useEffect(() => { | ||
let vulnerableApis = issueDetails?.vulnerableTestingRunResults.map((vulnerableApi, index) => { | ||
const { url, method } = vulnerableApi.apiInfoKey | ||
|
||
const apiDetails = ( | ||
<GetPrettifyEndpoint method={method} url={url} isNew={false} /> | ||
) | ||
|
||
return { | ||
key: index, | ||
apiDetailsText: `${method} ${url}`, | ||
apiDetails: apiDetails, | ||
} | ||
}) | ||
|
||
const VULNERABLE_APIS_LIMIT = 5 | ||
|
||
if (vulnerableApis.length > VULNERABLE_APIS_LIMIT) { | ||
const moreApisText = `+ ${vulnerableApis.length - VULNERABLE_APIS_LIMIT} more` | ||
vulnerableApis = vulnerableApis.slice(0, VULNERABLE_APIS_LIMIT) | ||
|
||
vulnerableApis.push({ | ||
key: VULNERABLE_APIS_LIMIT + 1, | ||
apiDetailsText: "+more", | ||
apiDetails: <Text variant='bodySm' fontWeight="bold" color="subdued">{moreApisText}</Text> | ||
}) | ||
} | ||
|
||
setVulnerableApisState(vulnerableApis) | ||
}, []) | ||
|
||
return ( | ||
<Box id={name} paddingBlockStart={ index === 0 ? 0 : 4}> | ||
<VerticalStack gap="4"> | ||
<Text variant='headingSm'> | ||
{index + 1}. {testName} | ||
</Text> | ||
|
||
<Text variant='bodySm' color='subdued'> | ||
{issueDescription} | ||
</Text> | ||
|
||
<GithubSimpleTable | ||
key="table" | ||
data={vulnerableApisState} | ||
resourceName={resourceName} | ||
headers={headers} | ||
useNewRow={true} | ||
condensedHeight={true} | ||
hideQueryField={true} | ||
headings={headers} | ||
hidePagination={true} | ||
/> | ||
|
||
<VerticalStack gap="1"> | ||
<Text variant='headingXs'> | ||
Why is this a problem? | ||
</Text> | ||
<Text variant='bodySm' color='subdued'> | ||
{issueImpact} | ||
</Text> | ||
</VerticalStack> | ||
|
||
{!isLast ? <Divider />: null} | ||
</VerticalStack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default Issue |
69 changes: 69 additions & 0 deletions
69
...web/polaris_web/web/src/apps/dashboard/pages/testing/vulnerability_report/IssuesGraph.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Box, Text, VerticalStack } from "@shopify/polaris"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import Highcharts from "highcharts" | ||
import { useRef } from "react"; | ||
|
||
function IssuesGraph({ categoryIssues }) { | ||
|
||
const issuesGraphRef = useRef(null) | ||
|
||
let dataArr = [] ; | ||
Object.values(categoryIssues).forEach((issuesList)=>{ | ||
dataArr.push(issuesList.length) | ||
}) | ||
|
||
const issuesGraphOptions = { | ||
chart: { | ||
type: 'column', | ||
height: '280px', | ||
spacing: [5, 0, 0, 0], | ||
}, | ||
credits: { | ||
enabled: false, | ||
}, | ||
title: { | ||
text: '', | ||
align: 'left', | ||
margin: 20 | ||
}, | ||
xAxis: { | ||
categories: Object.keys(categoryIssues), | ||
crosshair: true, | ||
accessibility: { | ||
description: 'Categories' | ||
} | ||
}, | ||
yAxis: { | ||
min: 0, | ||
title: { | ||
text: '# of issues' | ||
} | ||
}, | ||
legend: { | ||
enabled: false | ||
}, | ||
series: { | ||
minPointLength: 0, | ||
pointWidth: 40, | ||
color: "#FDA29B", | ||
cursor: 'pointer', | ||
data: dataArr | ||
} | ||
} | ||
|
||
return ( | ||
<VerticalStack gap={3}> | ||
<Text variant="headingXs">Number of issues</Text> | ||
<Box> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={issuesGraphOptions} | ||
ref={issuesGraphRef} | ||
/> | ||
</Box> | ||
|
||
</VerticalStack> | ||
) | ||
} | ||
|
||
export default IssuesGraph |
20 changes: 20 additions & 0 deletions
20
...s_web/web/src/apps/dashboard/pages/testing/vulnerability_report/ReportRecommendations.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Box, Text, VerticalStack } from "@shopify/polaris" | ||
|
||
function ReportRecommendations({ title, sno, itemsList }) { | ||
return ( | ||
<Box id="akto-recommendations" paddingBlockStart={6} paddingBlockEnd={8} paddingInlineStart={5} paddingInlineEnd={5}> | ||
<VerticalStack gap="3"> | ||
<Text variant="headingLg">{sno}. {title}</Text> | ||
{itemsList.map((item, index) => { | ||
return ( | ||
<Box key={index}> | ||
<Text variant='bodySm'> <b>{index + 1}. {item.title}: </b>{item.content}</Text> | ||
</Box> | ||
) | ||
})} | ||
</VerticalStack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ReportRecommendations |
Oops, something went wrong.