diff --git a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.test.ts b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.test.ts
new file mode 100644
index 0000000000000..6207885b60ab0
--- /dev/null
+++ b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.test.ts
@@ -0,0 +1,100 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { useBenchmarkDynamicValues } from './use_benchmark_dynamic_values';
+import { renderHook } from '@testing-library/react-hooks/dom';
+import { useCspIntegrationLink } from '../navigation/use_csp_integration_link';
+import { BenchmarksCisId } from '../../../common/types/benchmarks/v2';
+
+jest.mock('../navigation/use_csp_integration_link');
+
+describe('useBenchmarkDynamicValues', () => {
+ const setupMocks = (cspmIntegrationLink: string, kspmIntegrationLink: string) => {
+ (useCspIntegrationLink as jest.Mock)
+ .mockReturnValueOnce(cspmIntegrationLink)
+ .mockReturnValueOnce(kspmIntegrationLink);
+ };
+
+ it('should return the correct dynamic benchmark values for each provided benchmark ID', () => {
+ setupMocks('cspm-integration-link', 'kspm-integration-link');
+ const { result } = renderHook(() => useBenchmarkDynamicValues());
+
+ const benchmarkValuesCisAws = result.current.getBenchmarkDynamicValues('cis_aws', 3);
+ expect(benchmarkValuesCisAws).toEqual({
+ integrationType: 'CSPM',
+ integrationName: 'AWS',
+ resourceName: 'Accounts',
+ resourceCountLabel: 'accounts',
+ integrationLink: 'cspm-integration-link',
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ });
+
+ const benchmarkValuesCisGcp = result.current.getBenchmarkDynamicValues('cis_gcp', 0);
+ expect(benchmarkValuesCisGcp).toEqual({
+ integrationType: 'CSPM',
+ integrationName: 'GCP',
+ resourceName: 'Projects',
+ resourceCountLabel: 'projects',
+ integrationLink: 'cspm-integration-link',
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ });
+
+ const benchmarkValuesCisAzure = result.current.getBenchmarkDynamicValues('cis_azure', 1);
+ expect(benchmarkValuesCisAzure).toEqual({
+ integrationType: 'CSPM',
+ integrationName: 'Azure',
+ resourceName: 'Subscriptions',
+ resourceCountLabel: 'subscription',
+ integrationLink: 'cspm-integration-link',
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ });
+
+ const benchmarkValuesCisK8s = result.current.getBenchmarkDynamicValues('cis_k8s', 0);
+ expect(benchmarkValuesCisK8s).toEqual({
+ integrationType: 'KSPM',
+ integrationName: 'Kubernetes',
+ resourceName: 'Clusters',
+ resourceCountLabel: 'clusters',
+ integrationLink: 'kspm-integration-link',
+ learnMoreLink: 'https://ela.st/kspm-get-started',
+ });
+
+ const benchmarkValuesCisEks = result.current.getBenchmarkDynamicValues('cis_eks');
+ expect(benchmarkValuesCisEks).toEqual({
+ integrationType: 'KSPM',
+ integrationName: 'EKS',
+ resourceName: 'Clusters',
+ resourceCountLabel: 'clusters',
+ integrationLink: 'kspm-integration-link',
+ learnMoreLink: 'https://ela.st/kspm-get-started',
+ });
+
+ const benchmarkValuesInvalid = result.current.getBenchmarkDynamicValues(
+ 'invalid_benchmark' as BenchmarksCisId
+ );
+ expect(benchmarkValuesInvalid).toEqual({});
+ });
+
+ it('should return the correct resource plurals based on the provided resource count', () => {
+ const { result } = renderHook(() => useBenchmarkDynamicValues());
+
+ const benchmarkValuesCisAws = result.current.getBenchmarkDynamicValues('cis_aws', 3);
+ expect(benchmarkValuesCisAws.resourceCountLabel).toBe('accounts');
+
+ const benchmarkValuesCisGcp = result.current.getBenchmarkDynamicValues('cis_gcp', 0);
+ expect(benchmarkValuesCisGcp.resourceCountLabel).toBe('projects');
+
+ const benchmarkValuesCisAzure = result.current.getBenchmarkDynamicValues('cis_azure', 1);
+ expect(benchmarkValuesCisAzure.resourceCountLabel).toBe('subscription');
+
+ const benchmarkValuesCisK8s = result.current.getBenchmarkDynamicValues('cis_k8s', 0);
+ expect(benchmarkValuesCisK8s.resourceCountLabel).toBe('clusters');
+
+ const benchmarkValuesCisEks = result.current.getBenchmarkDynamicValues('cis_eks');
+ expect(benchmarkValuesCisEks.resourceCountLabel).toBe('clusters');
+ });
+});
diff --git a/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts
new file mode 100644
index 0000000000000..5fe3f8f69050a
--- /dev/null
+++ b/x-pack/plugins/cloud_security_posture/public/common/hooks/use_benchmark_dynamic_values.ts
@@ -0,0 +1,149 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { useCspIntegrationLink } from '../navigation/use_csp_integration_link';
+import { CSPM_POLICY_TEMPLATE, KSPM_POLICY_TEMPLATE } from '../../../common/constants';
+import { BenchmarksCisId } from '../../../common/types/benchmarks/v2';
+
+type BenchmarkDynamicNames =
+ | {
+ integrationType: 'CSPM';
+ integrationName: 'AWS';
+ resourceName: 'Accounts';
+ }
+ | {
+ integrationType: 'CSPM';
+ integrationName: 'GCP';
+ resourceName: 'Projects';
+ }
+ | {
+ integrationType: 'CSPM';
+ integrationName: 'Azure';
+ resourceName: 'Subscriptions';
+ }
+ | {
+ integrationType: 'KSPM';
+ integrationName: 'Kubernetes';
+ resourceName: 'Clusters';
+ }
+ | {
+ integrationType: 'KSPM';
+ integrationName: 'EKS';
+ resourceName: 'Clusters';
+ };
+
+export type BenchmarkDynamicValues = BenchmarkDynamicNames & {
+ resourceCountLabel: string;
+ integrationLink: string;
+ learnMoreLink: string;
+};
+
+export type GetBenchmarkDynamicValues = (
+ benchmarkId: BenchmarksCisId,
+ resourceCount?: number
+) => BenchmarkDynamicValues;
+
+export const useBenchmarkDynamicValues = () => {
+ const cspmIntegrationLink = useCspIntegrationLink(CSPM_POLICY_TEMPLATE) || '';
+ const kspmIntegrationLink = useCspIntegrationLink(KSPM_POLICY_TEMPLATE) || '';
+
+ /**
+ * Retrieves dynamic benchmark values based on the provided benchmark ID and resource count.
+ *
+ * @param {BenchmarksCisId} benchmarkId - The benchmark ID.
+ * @param {number} [resourceCount] - The count of resources (optional).
+ * @returns {BenchmarkDynamicValues} The dynamic benchmark values including integration details,
+ * resource name, resource count label in plurals/singular, integration link, and learn more link.
+ *
+ * @example
+ * const benchmarkValues = getBenchmarkDynamicValues('cis_aws', 3);
+ * // Returns:
+ * // {
+ * // integrationType: 'CSPM',
+ * // integrationName: 'AWS',
+ * // resourceName: 'Accounts',
+ * // resourceCountLabel: 'accounts',
+ * // integrationLink: 'cspm-integration-link',
+ * // learnMoreLink: 'https://ela.st/cspm-get-started'
+ * // }
+ */
+ const getBenchmarkDynamicValues: GetBenchmarkDynamicValues = (
+ benchmarkId: BenchmarksCisId,
+ resourceCount?: number
+ ): BenchmarkDynamicValues => {
+ switch (benchmarkId) {
+ case 'cis_aws':
+ return {
+ integrationType: 'CSPM',
+ integrationName: 'AWS',
+ resourceName: 'Accounts',
+ resourceCountLabel: i18n.translate('xpack.csp.benchmarkDynamicValues.AwsAccountPlural', {
+ defaultMessage: '{resourceCount, plural, one {account} other {accounts}}',
+ values: { resourceCount: resourceCount || 0 },
+ }),
+ integrationLink: cspmIntegrationLink,
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ };
+ case 'cis_gcp':
+ return {
+ integrationType: 'CSPM',
+ integrationName: 'GCP',
+ resourceName: 'Projects',
+ resourceCountLabel: i18n.translate('xpack.csp.benchmarkDynamicValues.GcpAccountPlural', {
+ defaultMessage: '{resourceCount, plural, one {project} other {projects}}',
+ values: { resourceCount: resourceCount || 0 },
+ }),
+ integrationLink: cspmIntegrationLink,
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ };
+ case 'cis_azure':
+ return {
+ integrationType: 'CSPM',
+ integrationName: 'Azure',
+ resourceName: 'Subscriptions',
+ resourceCountLabel: i18n.translate(
+ 'xpack.csp.benchmarkDynamicValues.AzureAccountPlural',
+ {
+ defaultMessage: '{resourceCount, plural, one {subscription} other {subscriptions}}',
+ values: { resourceCount: resourceCount || 0 },
+ }
+ ),
+ integrationLink: cspmIntegrationLink,
+ learnMoreLink: 'https://ela.st/cspm-get-started',
+ };
+ case 'cis_k8s':
+ return {
+ integrationType: 'KSPM',
+ integrationName: 'Kubernetes',
+ resourceName: 'Clusters',
+ resourceCountLabel: i18n.translate('xpack.csp.benchmarkDynamicValues.K8sAccountPlural', {
+ defaultMessage: '{resourceCount, plural, one {cluster} other {clusters}}',
+ values: { resourceCount: resourceCount || 0 },
+ }),
+ integrationLink: kspmIntegrationLink,
+ learnMoreLink: 'https://ela.st/kspm-get-started',
+ };
+ case 'cis_eks':
+ return {
+ integrationType: 'KSPM',
+ integrationName: 'EKS',
+ resourceName: 'Clusters',
+ resourceCountLabel: i18n.translate('xpack.csp.benchmarkDynamicValues.EksAccountPlural', {
+ defaultMessage: '{resourceCount, plural, one {cluster} other {clusters}}',
+ values: { resourceCount: resourceCount || 0 },
+ }),
+ integrationLink: kspmIntegrationLink,
+ learnMoreLink: 'https://ela.st/kspm-get-started',
+ };
+ default:
+ return {} as BenchmarkDynamicValues;
+ }
+ };
+
+ return { getBenchmarkDynamicValues };
+};
diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx
index 25690410a9780..32cb0c6f11f98 100644
--- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx
+++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks_table.tsx
@@ -15,12 +15,14 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiLink,
+ EuiButtonEmpty,
} from '@elastic/eui';
import React, { useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { generatePath } from 'react-router-dom';
-import { useKibana } from '@kbn/kibana-react-plugin/public';
+import { FINDINGS_GROUPING_OPTIONS } from '../../common/constants';
+import { useNavigateFindings } from '../../common/hooks/use_navigate_findings';
import type { BenchmarkScore, Benchmark, BenchmarksCisId } from '../../../common/types/latest';
import * as TEST_SUBJ from './test_subjects';
import { isCommonError } from '../../components/cloud_posture_page';
@@ -29,6 +31,11 @@ import { ComplianceScoreBar } from '../../components/compliance_score_bar';
import { getBenchmarkCisName, getBenchmarkApplicableTo } from '../../../common/utils/helpers';
import { CISBenchmarkIcon } from '../../components/cis_benchmark_icon';
import { benchmarksNavigation } from '../../common/navigation/constants';
+import {
+ GetBenchmarkDynamicValues,
+ useBenchmarkDynamicValues,
+} from '../../common/hooks/use_benchmark_dynamic_values';
+import { useKibana } from '../../common/hooks/use_kibana';
export const ERROR_STATE_TEST_SUBJECT = 'benchmark_page_error';
@@ -62,51 +69,6 @@ const BenchmarkButtonLink = ({
);
};
-export const getBenchmarkPlurals = (benchmarkId: string, accountEvaluation: number) => {
- switch (benchmarkId) {
- case 'cis_k8s':
- return (
-