diff --git a/src/pages/BesVersionHistory/AssessmentAnalytics/index.tsx b/src/pages/BesVersionHistory/AssessmentAnalytics/index.tsx index 2af2f2bf..580f1e62 100644 --- a/src/pages/BesVersionHistory/AssessmentAnalytics/index.tsx +++ b/src/pages/BesVersionHistory/AssessmentAnalytics/index.tsx @@ -79,8 +79,8 @@ const FetchCritical = ({ riskData }: any) => { let des: string = vul.description; return ( <> - - {name} : {name} + + {name} : {name} ) @@ -92,14 +92,14 @@ const FetchCritical = ({ riskData }: any) => { return(<>{res}); }else{ return(<> - + No Critical Issues Found ); } }else{ return(<> - + No Data Available ); @@ -129,9 +129,10 @@ const FetchData = ({version, name, report, versionDetails, masterData}: any) => const [severityData, setSeverity] = React.useState([]); const [vulHistoryData, setVulHistory] = React.useState([]); React.useEffect(() => { + let link: string = ""; if (version.trim()) { - let link: string = `${assessment_datastore}/${name}/${version}/${assessment_path["Codeql"]}/${name}-${version}-${assessment_report["Codeql"]}-report.json`; - getLinkData(link, setRiskData); + link = `${assessment_datastore}/${name}/${version}/${assessment_path["Codeql"]}/${name}-${version}-${assessment_report["Codeql"]}-report.json`; + getLinkData(link, setRiskData); } }, [version]); React.useEffect(() => { @@ -170,7 +171,7 @@ const FetchData = ({version, name, report, versionDetails, masterData}: any) => - + No Data Available @@ -219,21 +220,21 @@ const FetchData = ({version, name, report, versionDetails, masterData}: any) => const GetHeadings = ({ receivedValue }: any) => { //const [fieldInfo, setfieldInfo]: any = React.useState({}); if(receivedValue === "Risk Posture"){ - return(<> Risk Posture - + return(<> {" "} Risk Posture + info ); }else if(receivedValue === "Critical Issues"){ - return(<> Critical SAST - + return(<> {" "} Top Vulnerabilities + info ); }else if(receivedValue === "Vulnerability History"){ - return(<> CVE History - + return(<> {" "} CVE History + info ); @@ -250,27 +251,17 @@ function AssessmentAnalytics({ title, name, version, versionDetails, masterData, "Vulnerability History" ]; return ( - {report.map((value, index) => { return ( <> - - - - - - - - - - - - - + + + + + - ); diff --git a/src/pages/BesVersionHistory/AssessmentReport/index.tsx b/src/pages/BesVersionHistory/AssessmentReport/index.tsx index d6233099..7388ad6e 100644 --- a/src/pages/BesVersionHistory/AssessmentReport/index.tsx +++ b/src/pages/BesVersionHistory/AssessmentReport/index.tsx @@ -7,11 +7,13 @@ 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 { forEach } from "lodash"; export const verifyLink = async (link: any, setLinkStatus: any) => { try { @@ -42,7 +44,293 @@ export const verifyLink = async (link: any, setLinkStatus: any) => { } }; -const CheckLink = ({ version, name, report }: any) => { +const FetchLowScores = ({ data }: any) => { + let lowscorers: any = []; + let displayData: any = {}; + data.checks.forEach ((issue) => { + if(issue.hasOwnProperty('score')){ + if(issue.score <= 5) + lowscorers.push(issue); + } + else + { + lowscorers.push(issue); + } + }); + displayData = lowscorers.map(function(iss:any, index:number) + { + return(<> +
  • + + {iss.name} : {iss.reason} + +
  • + + ) + }) + return(<> + +
      + {displayData} +
    +
    + + ) +}; + +const FetchCS = ({ data }: any) => { + + return(<> + +
      +
    • + + Age : {data.created_since} months + +
    • +
    • + + No. Of Contributors : {data.contributor_count} + +
    • +
    • + + Update Frequency : {data.commit_frequency} + +
    • +
    • + + Organisations : {data.org_count} + +
    • +
    • + + Issue Fixed : {data.closed_issues_count} + +
    • +
    • + + Last Updated : {data.updated_since} + +
    • +
    +
    + + ); +}; + +const FetchSAST = ({ data }: any) => { + + let critical: number = 0; + let high: number = 0; + let medium: number = 0; + let low: number = 0; + + data.forEach ((vul) => { + if(vul.rule.security_severity_level === "critical"){ + critical++; + }else if(vul.rule.security_severity_level === "high"){ + high++; + }else if(vul.rule.security_severity_level === "medium"){ + medium++; + }else if(vul.rule.security_severity_level === "high"){ + low++; + } + }); + + return(<> + + + + + Critical : {critical} + + + + + High : {high} + + + + + + + Medium : {medium} + + + + + Low : {low} + + + + + + ); +}; + +const FetchLicense = ({ data, uniq_lic, itemData }: any) => { + + let license_list: string [] = []; + let non_lic_files: number = 0; + + uniq_lic.forEach ((ul) => { + if(ul.length !== 0) + license_list.push(" "+ ul + ",") + }); + + data.forEach((ld) => { + if(ld.LicenseConcluded && (ld.LicenseConcluded === "NOASSERTION" || + ld.LicenseConcluded.length === 0 )) + non_lic_files++; + }); + + return(<> + + + + + Project License : {itemData.license.key} + + + + + No. of Non License Files : {non_lic_files} + + + + + Unique Licenses : {license_list} + + + + + + ); +}; + +const FetchSBOM = ({ data, masterData }: any) => { + + let tracked: string []= []; + let dis: any = {}; + + data.forEach((dp) => { + masterData.forEach((tp) => { + let duplicate: boolean = false; + if(dp.name === tp.name){ + tracked.forEach((tmptracked) => { + if(tmptracked === dp.name) + duplicate = true; + }); + + if(!duplicate) + tracked.push(dp.name); + } + }); + }); + + dis = tracked.map(function( td: string, index: number){ + return(<> + + + {td} + + + + ); + }); + + return(<> + + + Projects Under BeS : + + + {dis} + + + + ); +}; + +const CheckLink = ({ version, name, report, itemData, masterData }: any) => { const [linkStatus, setLinkStatus]: any = React.useState({}); let reportNameMap = ""; if (report === "Criticality Score") { @@ -59,33 +347,96 @@ const CheckLink = ({ version, name, report }: any) => { React.useEffect(() => { if (version.trim()) { - let link: string = `${assessment_datastore}/${name}/${version}/${assessment_path[reportNameMap]}/${name}-${version}-${assessment_report[reportNameMap]}-report.json`; + let link: string = ""; + link= `${assessment_datastore}/${name}/${version}/${assessment_path[reportNameMap]}/${name}-${version}-${assessment_report[reportNameMap]}-report.json`; verifyLink(link, setLinkStatus); } }, [version]); + let linkStatusLength: number = Object.values(linkStatus).length; - if (report === "Criticality Score" && linkStatusLength !== 0) { + if (report === "Criticality Score" && linkStatusLength !== 0){ return ( - - {linkStatus.criticality_score} - + <> + + {linkStatus.criticality_score} + + + + + + + ); } + const pathName: string = `/BeSLighthouse/bes_assessment_report/:${name}/:${version}/:${reportNameMap}`; const myObject = { pathname: pathName, state: linkStatus } as { pathname: string; }; - if (report === "ScoreCard" && linkStatusLength !== 0) { - return {linkStatus.score}; + if (report === "ScoreCard" && linkStatusLength !== 0) { + return (<> + + + {linkStatus.score} + + + + + + + + + ); } - if (report === "Vulnerabilities" && linkStatusLength !== 0) { - return {linkStatus.length}; + + if (report === "Vulnerabilities" && linkStatusLength !== 0) { + return (<> + + + {linkStatus.length} + + + + + + + ); } + if (report === "License Compliance" && linkStatusLength !== 0) { let uniqueLicenses: any = []; + for (let i = 0; i < linkStatus.length; i++) { - let flag = 0; + let flag: number = 0; for (let j = 0; j < uniqueLicenses.length; j++) { if ( linkStatus[i].LicenseConcluded === uniqueLicenses[j] || @@ -95,95 +446,120 @@ const CheckLink = ({ version, name, report }: any) => { break; } } - if (flag === 0) { + if (flag === 0 && linkStatus[i].hasOwnProperty('LicenseConcluded') && linkStatus[i].LicenseConcluded.length !== 0) { uniqueLicenses.push(linkStatus[i].LicenseConcluded); } } - console.log("UniqueLicenses Are=" + uniqueLicenses); - return {uniqueLicenses.length}; + return( + <> + + + {uniqueLicenses.length} + + + + + + + + + ); } + if (report === "Dependencies" && linkStatusLength !== 0) { - return {linkStatus.packages.length}; + return (<> + + + {linkStatus.packages.length} + + + + + + + + + ); } - + return ( - + -- ); }; + const GetHeadings = ({ receivedValue }: any) => { - //const [fieldInfo, setfieldInfo]: any = React.useState({}); - if (receivedValue === "License Compliance") { - return ( - <> - {" "} - Unique Licenses - - info - - - ); - } else if (receivedValue === "Dependencies") { - return ( - <> - {" "} - Dependencies(SBOM) - - info - - - ); - } else if (receivedValue === "ScoreCard") { - return ( - <> - {" "} - {receivedValue} - - info - - - ); - } else if (receivedValue === "Criticality Score") { - return ( - <> - {" "} - {receivedValue} - - info - - - ); - } else if (receivedValue === "Vulnerabilities") { - return ( - <> - {" "} - SAST Risks - - info - - - ); - } else { - return receivedValue; - } -}; -function AssessmentReport({ title, name, version, ...other }: 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 AssessmentReport({ title, name, version, itemData, masterData, ...other }: any) { const report: string[] = [ "ScoreCard", "Criticality Score", @@ -191,38 +567,50 @@ function AssessmentReport({ title, name, version, ...other }: any) { "License Compliance", "Dependencies" ]; - return ( - - + return ( + + {report.map((value, index) => { return ( <> - - - - + + + + - - + + - + - + @@ -233,10 +621,10 @@ function AssessmentReport({ title, name, version, ...other }: any) { ); - })} - - + }) + } +
    ); -} +}; export default AssessmentReport; diff --git a/src/pages/BesVersionHistory/index.tsx b/src/pages/BesVersionHistory/index.tsx index bbc59f35..f7d4b83d 100644 --- a/src/pages/BesVersionHistory/index.tsx +++ b/src/pages/BesVersionHistory/index.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import Grid from "@mui/material/Grid"; import Card from "@mui/material/Card"; - +import { Link } from "react-router-dom"; import { useParams } from "react-router-dom"; import { projectOfInterestData } from "../../utils/poi_data"; import { MenuItem, Select } from "@mui/material"; @@ -12,6 +12,7 @@ import AssessmentReport from "./AssessmentReport"; import AssessmentAnalytics from "./AssessmentAnalytics"; import DefaultNavbar from "../../examples/Navbars/DefaultNavbar"; import routes from "../../routes"; +import { Divider } from '@mui/material'; export const osspoiMasterAndSummary = async ( setData: any, @@ -32,7 +33,7 @@ export const osspoiMasterAndSummary = async ( const useStyles: any = makeStyles(() => ({ select: { - minWidth: "155px", + minWidth: "calc(3rem + 0.5vw)", "& .css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input.MuiSelect-select": { padding: "4px" @@ -46,7 +47,48 @@ const useStyles: any = makeStyles(() => ({ } } })); +const FetchRecomedations = ({itemData, masterData}: any) => { + return ( + <> +
      +
    • + + recomentaion 1: Fetch the recomendations from master jason as suggested by the POD team. + +
    • +
    • + + recomentaion 2: Fetch the recomendations from master jason as suggested by the POD team. + +
    • +
    • + + recomentaion 3: Fetch the recomendations from master jason as suggested by the POD team. + +
    • +
    + + ) +} function BesVersionHistory() { const classes = useStyles(); const { besId, besName }: any = useParams(); @@ -80,23 +122,46 @@ function BesVersionHistory() { const chartContentData: any = {}; const gridJsx: JSX.Element[] = []; - + return ( <> - - + + {data.map((item: any) => { if (`:${item.name}` === besName) { + let definedScore: string = "0"; + if(item.hasOwnProperty('score')) + definedScore = item.score; + else + definedScore = "--"; + const envpath: string = `https://github.com/Be-Secure/besecure-ce-env-repo/tree/master/${item.name}/0.0.1/`; + return ( <> - - - - + + + + + + Project Name:   @@ -104,120 +169,233 @@ function BesVersionHistory() { variant="h6" fontWeight="regular" color="text" + style={{fontSize: "calc(0.4rem + 0.5vw)"}} > {item.name}
    - - + + + Version:   - - - - - BeS Tracking Id:   - - - {item.id} - - - + + + + Score:   + + + {definedScore} + + + + + + + + + + + BeS Tracking Id:   + + + {item.id} + + + + + + + BeS Tech Stack:   + + + {item.bes_technology_stack} + + + + + + + BeS Environment:   + + + {item.name} + + + + + + + + + + + - BeS Tech Stack:   + Description:   - - {item.bes_technology_stack} + {item.description} - - - Description:   - - - {item.description} - - - - - - - + + + + + + + + - - - - - - + + + + + - + /> - - - ); - } - })} - - - ); + + + + ); + } + })} + + +); } export default BesVersionHistory;