From 305b6da3617980bd856e8efd33ed1a020c03ba98 Mon Sep 17 00:00:00 2001 From: Lola Date: Mon, 11 Dec 2023 09:02:54 -0500 Subject: [PATCH] [Cloud Security] fix accounts evaluation count issue (#173035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. The Account Evaluation counter only counts the type of benchmark. For instance, the `cis_azure` benchmark counter shows 1 because we count the benchmark type which is always 1. We need to display the `benchmark.meta.assetCount` will accurately display the number of accounts per benchmark ID. Screenshot 2023-12-11 at 6 09 41 AM --- .../public/components/accounts_evaluated_widget.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx b/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx index 98f99fbd29245..ef7e2750b34fd 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx +++ b/x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.tsx @@ -52,8 +52,8 @@ export const AccountsEvaluatedWidget = ({ }) => { const { euiTheme } = useEuiTheme(); - const filterBenchmarksById = (benchmarkId: string) => { - return benchmarkAssets?.filter((obj) => obj?.meta.benchmarkId === benchmarkId) || []; + const getBenchmarkById = (benchmarkId: string) => { + return benchmarkAssets?.find((obj) => obj?.meta.benchmarkId === benchmarkId); }; const navToFindings = useNavigateFindings(); @@ -67,7 +67,7 @@ export const AccountsEvaluatedWidget = ({ }; const benchmarkElements = benchmarks.map((benchmark) => { - const cloudAssetAmount = filterBenchmarksById(benchmark.type).length; + const cloudAssetAmount = getBenchmarkById(benchmark.type)?.meta?.assetCount || 0; return ( cloudAssetAmount > 0 && (