diff --git a/src/assets/images/network.png b/src/assets/images/network.png new file mode 100644 index 00000000..5956ff1e Binary files /dev/null and b/src/assets/images/network.png differ diff --git a/src/pages/ModelOfInterest/index.tsx b/src/pages/ModelOfInterest/index.tsx index 0cffb952..670ba650 100644 --- a/src/pages/ModelOfInterest/index.tsx +++ b/src/pages/ModelOfInterest/index.tsx @@ -10,152 +10,94 @@ import MKTypography from "../../components/MKTypography"; import { useState } from "react"; import { verifyLink } from "../ShowModelDetails/AssessmentSummary"; import { modelOfInterestData } from "../../dataStore"; -import Language from "../../examples/Charts/PieChart/Languages"; -import theme from "../../assets/theme"; -import { debug } from "console"; -import ThreeWayToggle from "../../examples/Button/ThreeWayToggle" -function prepPieChartData( - setModelType: React.Dispatch>, - setRiskAnalysis: React.Dispatch>, - cache: any, - data: any -) { - const modelTypePieData: any = []; - const modelTypeCount: any = {}; - const riskAnalysisPieData: any = []; - const riskAnalysisCount: any = {}; - - data.forEach((item: any) => { - if (!modelTypeCount[item["type"]]) { - modelTypeCount[item["type"]] = 0; - } - modelTypeCount[item["type"]]++; - - // Check for the existence of quality_control - if (item["quality_control"]) { - if (item["quality_control"].length === 0) { - // Handling for empty quality_control - if (!riskAnalysisCount["Unanalyzed"]) { - riskAnalysisCount["Unanalyzed"] = 0; - } - riskAnalysisCount["Unanalyzed"]++; - } else { - item["quality_control"].forEach((qc: string) => { - if (!riskAnalysisCount[qc]) { - riskAnalysisCount[qc] = 0; - } - riskAnalysisCount[qc]++; - }); - } - } - }); - - for (let model of Object.keys(modelTypeCount)) { - modelTypePieData.push({ label: model, value: modelTypeCount[model] }); - } +import networkIcon from "../../assets/images/network.png" + +function statsTable(data: any) { - for (let risk of Object.keys(riskAnalysisCount)) { - riskAnalysisPieData.push({ label: risk, value: riskAnalysisCount[risk] }); + if (!Array.isArray(data) || data.length === 0) { + return
No data available
; // Return a message if data is empty or not an array } - setModelType(modelTypePieData); - setRiskAnalysis(riskAnalysisPieData); + const modelCount = data.length; + const classicCount = data.filter((item: { type: string }) => item.type === "Classic").length; + const llmCount = data.filter((item: { type: string }) => item.type === "LLM").length; + + const sastCount = data.filter((item: any) => Array.isArray(item.quality_control) && item.quality_control.includes("SAST")).length; + const fuzzCount = data.filter((item: any) => Array.isArray(item.quality_control) && item.quality_control.includes("Fuzz Test")).length; + const emptyAnalysisCount = data.filter((item: any) => Array.isArray(item.quality_control) && item.quality_control.length === 0).length; + return ( + + + + + + Models: {modelCount} + + + + + + Classic Models: {classicCount} | LLMs: {llmCount} + + + + + Risk Analysis: SAST = {sastCount} | Fuzz Test = {fuzzCount} | Unanalyzed = {emptyAnalysisCount} + + + + + ); } function ModelOfInterest() { - const [report, setreport]: any = useState([]); - const [modelType, setModelType]: any = useState([]); - const [riskAnalysis, setRiskAnalysis]: any = useState([]); + const [report, setReport]: any = useState(); + const [modelType, setModelType]: any = useState(); + const [riskAnalysis, setRiskAnalysis]: any = useState(); React.useEffect(() => { - const fetchData = async () => { - try { - const fetchedReport = await verifyLink(modelOfInterestData, setreport); - } catch (error) { - // Handle error - } - }; - - fetchData(); - }, []); - - React.useEffect(() => { - if (report.length > 0) { - prepPieChartData(setModelType, setRiskAnalysis, [], report); - } - }, [report, setModelType, setRiskAnalysis]); + verifyLink(modelOfInterestData, setReport); - const count = report.length; + }, []); return ( <> - - - - - - {/* */} - - - Model Count - - - {count} - - - {/* */} - - - - - - {/* Calling Language component for showing model type */} - - - - - - - - - + + + + Models of Interest + + + Gain visibility into vulnerabilities and security gaps within popular open source machine learning models. Empower your strategies for safer, more robust AI implementations. Navigate the Landscape of Open Source AI Risks. Delve into the strengths, weaknesses, and steps to fortify your models against potential threats in the ever-evolving realm of open source machine learning. + + + + + + + {statsTable(report)} + + + - +