From 8106a28ed11364364ddaed8f1213ec57baeff782 Mon Sep 17 00:00:00 2001 From: ofiriro3 Date: Sun, 6 Nov 2022 18:32:24 +0200 Subject: [PATCH 1/2] Adding cluster name to cluster card --- .../cloud_security_posture/common/schemas/csp_finding.ts | 6 ++++-- .../server/routes/compliance_dashboard/get_clusters.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts b/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts index 636182e97e46f..4ef4a2c0ebb0f 100644 --- a/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts +++ b/x-pack/plugins/cloud_security_posture/common/schemas/csp_finding.ts @@ -12,8 +12,10 @@ import type { CspRuleMetadata } from './csp_rule_metadata'; export interface CspFinding { '@timestamp': string; cluster_id: string; - cluster?: { - name?: string; + orchestrator?: { + cluster?: { + name?: string; + }; }; result: CspFindingResult; resource: CspFindingResource; diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts index d768d65ac32c7..388672f25409d 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.ts @@ -71,7 +71,7 @@ export const getClustersFromAggs = (clusters: ClusterBucket[]): ClusterWithoutTr const meta = { clusterId: cluster.key, - clusterName: latestFindingHit._source.cluster?.name, + clusterName: latestFindingHit._source.orchestrator?.cluster?.name, benchmarkName: latestFindingHit._source.rule.benchmark.name, benchmarkId: latestFindingHit._source.rule.benchmark.id, lastUpdate: latestFindingHit._source['@timestamp'], From 8ff3d18e908734575e41c32bb8ae54f41f85f068 Mon Sep 17 00:00:00 2001 From: ofiriro3 Date: Mon, 7 Nov 2022 09:40:34 +0200 Subject: [PATCH 2/2] Fixing test --- .../server/routes/compliance_dashboard/get_clusters.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.test.ts b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.test.ts index 03767f366246c..2b288d6e696e8 100644 --- a/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.test.ts +++ b/x-pack/plugins/cloud_security_posture/server/routes/compliance_dashboard/get_clusters.test.ts @@ -18,7 +18,11 @@ const mockClusterBuckets: ClusterBucket[] = [ _id: '123', _index: '123', _source: { - cluster: { name: 'cluster_name' }, + orchestrator: { + cluster: { + name: 'cluster_name', + }, + }, rule: { benchmark: { name: 'CIS Kubernetes', id: 'cis_k8s' } }, '@timestamp': '123', },