From c5a3da832f9cffb723202a3ee58e5c5a83e92c38 Mon Sep 17 00:00:00 2001 From: Sudhir Verma Date: Thu, 22 Feb 2024 20:28:32 +0530 Subject: [PATCH] Fix count for SonarQube data --- .../AssessmentReport/index.tsx | 303 +----------------- src/pages/BesVersionHistory/index.tsx | 13 +- 2 files changed, 12 insertions(+), 304 deletions(-) diff --git a/src/pages/BesVersionHistory/AssessmentReport/index.tsx b/src/pages/BesVersionHistory/AssessmentReport/index.tsx index 05d4355c..38158820 100644 --- a/src/pages/BesVersionHistory/AssessmentReport/index.tsx +++ b/src/pages/BesVersionHistory/AssessmentReport/index.tsx @@ -1,64 +1,30 @@ import * as React from "react"; - import Icon from "@mui/material/Icon"; - import { Backdrop, Box, Button, - Divider, Fade, Grid, Modal, - Typography, } from "@mui/material"; import { fetchJsonReport } from "../../../utils/fatch_json_report"; - import { Link } from "react-router-dom"; - import { assessment_datastore } from "../../../dataStore"; - -import MKBox from "../../../components/MKBox"; - import MKTypography from "../../../components/MKTypography"; - import { assessment_path, assessment_report, } from "../../../utils/assessmentReport"; - import FetchSAST from "./FetchSastReport"; - -import SastToggleButton from "./SastToggleButton"; - import { useState } from "react"; import vulnerabilityIcon from "../../../assets/images/bug.png"; - import dependencyIcon from "../../../assets/images/data-flow.png"; - import licenseIcon from "../../../assets/images/certificate.png"; - import scorecardIcon from "../../../assets/images/speedometer.png"; - import tavossIcon from "../../../assets/images/verified.png"; - -import Table from "@mui/material/Table"; - -import TableBody from "@mui/material/TableBody"; - -import TableCell from "@mui/material/TableCell"; - -import TableContainer from "@mui/material/TableContainer"; - -import TableHead from "@mui/material/TableHead"; - -import TableRow from "@mui/material/TableRow"; - -import Paper from "@mui/material/Paper"; - -import { link } from "fs"; import BasicTable from "./BasicTable"; export const fetchJsonData = async (link: any, setJsonData: any) => { @@ -106,7 +72,6 @@ export const fetchvulJsonData = async ( try { let data = JSON.parse(response); - if (vulTool === "codeql") { setCQData(data); } else if (vulTool === "sonarqube") { @@ -156,13 +121,6 @@ const FetchLowScores = ({ data }: any) => { return ( <> - {/* - - {displayData} - - */} { if (version?.trim()) { let link: string = ""; - - link = `${assessment_datastore}/${name}/${version}/${assessment_path[reportNameMapSonar]}/${name}-${version}-sonarqube-report.json`; - + //Fix me + link = `${assessment_datastore}/${name}/${version}/sast/${name}-${version}-sonarqube-report.json`; fetchvulJsonData(link, "sonarqube", setCQData, setSQData); } }, [version]); @@ -550,7 +507,6 @@ function GetAssessmentData(version, name, report, itemData, masterData) { myObject, ]); } - if ( report === "Vulnerabilities" && Object.values(codeQlData).length !== 0 && @@ -568,9 +524,14 @@ function GetAssessmentData(version, name, report, itemData, masterData) { Object.values(codeQlData).length === 0 ) { let issues: any = Object.values(sonarqubeData)[5]; - + let count = 0; + if (issues && issues.length > 0) { + for (let i = 0; i < issues.length; i++) { + if (issues[i]["severity"] === "CRITICAL" || issues[i]["severity"] === "MAJOR" || issues[i]["severity"] === "MINOR" || issues[i]["severity"] === "BLOCKER") count++; + } + } return (data_array = [ - sonarqubeData.total, + count, , "", "", @@ -632,8 +593,6 @@ function GetAssessmentData(version, name, report, itemData, masterData) { ]); } - let flag = false; - if (report === "Dependencies" && jsonDataLength !== 0) { if ( !( @@ -673,92 +632,6 @@ function GetAssessmentData(version, name, report, itemData, masterData) { ); } -const GetHeadings = ({ receivedValue }: any) => { - if (receivedValue === "License Compliance") { - return ( - <> - {" "} - - License Compatibiltity - - info - - - - ); - } else if (receivedValue === "Dependencies") { - return ( - <> - {" "} - - Dependencies - - info - - - - ); - } else if (receivedValue === "ScoreCard") { - return ( - <> - {" "} - - OpenSSF Scorecard (0-10) - - info - - - - ); - } else if (receivedValue === "Criticality Score") { - return ( - <> - {" "} - - OpenSSF Criticality Score (0-1) - - info - - - - ); - } else if (receivedValue === "Vulnerabilities") { - return ( - <> - {" "} - - Static Analysis Summary - - info - - - - ); - } else { - return receivedValue; - } -}; - function printText(item) { if (item == "Dependencies") { return item + " found"; @@ -1057,14 +930,6 @@ const ReportModal = ({ version, name, item, itemData, masterData }: any) => { > - {/* - Summary Report for {item} - */} {data ? data[1] : "Not found"} {data && data[3] ? ( @@ -1091,24 +956,17 @@ const ReportModal = ({ version, name, item, itemData, masterData }: any) => { }; function AssessmentReport({ - title, name, version, itemData, masterData, - ...other }: any) { const reports: string[] = [ "Vulnerabilities", - "Dependencies", - "License Compliance", - "ScoreCard", - "Criticality Score", - "TAVOSS Score", ]; @@ -1116,21 +974,6 @@ function AssessmentReport({ <> {reports.map((item, index) => ( - {/* */} ))} - - {/* Getting the assessment report */} - - {/* {report.map((value, index) => { */} - - {/* // return ( */} - - {/* // <> */} - - {/* */} - - {/* // ); */} - - {/* }) */} - - {/* } */} ); } diff --git a/src/pages/BesVersionHistory/index.tsx b/src/pages/BesVersionHistory/index.tsx index 1249b5f3..ca79fa3c 100644 --- a/src/pages/BesVersionHistory/index.tsx +++ b/src/pages/BesVersionHistory/index.tsx @@ -215,13 +215,6 @@ export const ModalForEnvsAndPlaybook = (): any => { ); } -// function selectFilter(type: any, event: MouseEvent) { -// console.log("called") -// ProjectDisplay({type}) -// debugger -// event.preventDefault(); -// } - // This function is returns the full form of the project tags function getProjectTags(value: any) { // projectTags is the Object name @@ -449,7 +442,7 @@ function BesVersionHistory() { {item.id} - + {/* For Open Source Assurance Provider */} + > + >