mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Cloud Posture] add icon for EKS (#137100)
This commit is contained in:
parent
3b0fc945aa
commit
fb3e7185df
9 changed files with 64 additions and 15 deletions
|
@ -34,6 +34,7 @@ export interface Cluster {
|
|||
meta: {
|
||||
clusterId: string;
|
||||
benchmarkName: string;
|
||||
benchmarkId: BenchmarkId;
|
||||
lastUpdate: number; // unix epoch time
|
||||
};
|
||||
stats: Stats;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 37.118 41.778"><defs><linearGradient id="a" x1="3.067" y1="9.93" x2="29.54" y2="36.403" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#c8511b"/><stop offset="1" stop-color="#f90"/></linearGradient><linearGradient id="b" x1="13.233" y1="-1.89" x2="40.402" y2="25.278" xlink:href="#a"/><linearGradient id="c" x1="5.454" y1="6.948" x2="32.426" y2="33.92" xlink:href="#a"/></defs><path d="M18.56 41.779a.77.77 0 0 1-.387-.1L.387 31.409A.773.773 0 0 1 0 30.737V10.2a.774.774 0 0 1 .387-.673L16.627.1a.774.774 0 0 1 1.16.673v8.9a.775.775 0 0 1-.387.673L9.28 15.09v10.726l9.28 5.359 8.1-4.64a.773.773 0 0 1 .773 0L35.166 31a.772.772 0 0 1 0 1.345l-16.221 9.333a.774.774 0 0 1-.385.101ZM1.545 30.287l17.013 9.829 14.693-8.507-6.186-3.572-8.12 4.709a.775.775 0 0 1-.774 0L8.118 26.939a.775.775 0 0 1-.387-.673v-11.6a.775.775 0 0 1 .387-.673l8.12-4.725V2.115L1.545 10.621Z" transform="translate(0 -.001)" style="fill:url(#a)"/><path d="M36.345 29.73a.77.77 0 0 1-.387-.1l-7.733-4.447a.67.67 0 0 1-.348-.673v-9.419l-8.159-4.64a.775.775 0 0 1-.387-.673V.862a.774.774 0 0 1 .387-.673.82.82 0 0 1 .773 0l16.24 9.334a.775.775 0 0 1 .387.673v18.761a.773.773 0 0 1-.773.773Zm-6.96-5.661 6.186 3.542V10.646L20.878 2.2v7.139L29 13.979a.776.776 0 0 1 .387.666Z" transform="translate(0 -.001)" style="fill:url(#b)"/><path d="M14.693 26.3V14.7h1.552v5.282l5.027-5.282h2.041l-5.248 5.649 5.7 5.955h-2.112l-5.408-5.418V26.3Z" transform="translate(0 -.001)" style="fill:url(#c)"/></svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 React from 'react';
|
||||
import { EuiIcon } from '@elastic/eui';
|
||||
import type { BenchmarkId } from '../../common/types';
|
||||
import cisK8sVanillaIcon from '../assets/icons/k8s_logo.svg';
|
||||
import cisEksIcon from '../assets/icons/cis_eks_logo.svg';
|
||||
|
||||
interface Props {
|
||||
type: BenchmarkId;
|
||||
}
|
||||
|
||||
const getBenchmarkIdIconType = (props: Props): string => {
|
||||
switch (props.type) {
|
||||
case 'cis_eks':
|
||||
return cisEksIcon;
|
||||
case 'cis_k8s':
|
||||
default:
|
||||
return cisK8sVanillaIcon;
|
||||
}
|
||||
};
|
||||
|
||||
export const CISBenchmarkIcon = (props: Props) => (
|
||||
<EuiIcon type={getBenchmarkIdIconType(props)} size="xxl" />
|
||||
);
|
|
@ -20,6 +20,7 @@ import moment from 'moment';
|
|||
import { PartitionElementEvent } from '@elastic/charts';
|
||||
import { EuiThemeComputed } from '@elastic/eui/src/services/theme/types';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { CISBenchmarkIcon } from '../../../components/cis_benchmark_icon';
|
||||
import { CloudPostureScoreChart } from '../compliance_charts/cloud_posture_score_chart';
|
||||
import { ChartPanel } from '../../../components/chart_panel';
|
||||
import type { ComplianceDashboardData, Evaluation } from '../../../../common/types';
|
||||
|
@ -61,7 +62,6 @@ export const BenchmarksSection = ({
|
|||
<>
|
||||
{complianceData.clusters.map((cluster) => {
|
||||
const shortId = cluster.meta.clusterId.slice(0, 6);
|
||||
|
||||
return (
|
||||
<React.Fragment key={cluster.meta.clusterId}>
|
||||
<EuiPanel hasBorder hasShadow={false} paddingSize="none">
|
||||
|
@ -82,8 +82,7 @@ export const BenchmarksSection = ({
|
|||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
{/* TODO: change default k8s logo to use a getBenchmarkLogo function */}
|
||||
<EuiIcon type="logoKubernetes" size="xxl" />
|
||||
<CISBenchmarkIcon type={cluster.meta.benchmarkId} />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
{INTERNAL_FEATURE_FLAGS.showManageRulesMock && (
|
||||
|
|
|
@ -30,7 +30,8 @@ import { ResourceTab } from './resource_tab';
|
|||
import { JsonTab } from './json_tab';
|
||||
import { OverviewTab } from './overview_tab';
|
||||
import { RuleTab } from './rule_tab';
|
||||
import k8sLogoIcon from '../../../assets/icons/k8s_logo.svg';
|
||||
import type { BenchmarkId } from '../../../../common/types';
|
||||
import { CISBenchmarkIcon } from '../../../components/cis_benchmark_icon';
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
|
@ -74,13 +75,13 @@ export const Markdown: React.FC<PropsOf<typeof EuiMarkdownFormat>> = (props) =>
|
|||
<EuiMarkdownFormat textSize="s" {...props} />
|
||||
);
|
||||
|
||||
export const CisKubernetesIcons = () => (
|
||||
export const CisKubernetesIcons = ({ benchmarkId }: { benchmarkId: BenchmarkId }) => (
|
||||
<EuiFlexGroup gutterSize="s">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiIcon type={cisLogoIcon} size="xxl" />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiIcon type={k8sLogoIcon} size="xxl" />
|
||||
<CISBenchmarkIcon type={benchmarkId} />
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
);
|
||||
|
|
|
@ -49,7 +49,7 @@ const getDetailsList = (data: CspFinding, discoverIndexLink: string | undefined)
|
|||
title: i18n.translate('xpack.csp.findings.findingsFlyout.overviewTab.frameworkSourcesTitle', {
|
||||
defaultMessage: 'Framework Sources',
|
||||
}),
|
||||
description: <CisKubernetesIcons />,
|
||||
description: <CisKubernetesIcons benchmarkId={data.rule.benchmark.id} />,
|
||||
},
|
||||
{
|
||||
title: i18n.translate('xpack.csp.findings.findingsFlyout.overviewTab.cisSectionTitle', {
|
||||
|
|
|
@ -28,7 +28,7 @@ export const getRuleList = (rule: CspFinding['rule']) => [
|
|||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.frameworkSourcesTitle', {
|
||||
defaultMessage: 'Framework Sources',
|
||||
}),
|
||||
description: <CisKubernetesIcons />,
|
||||
description: <CisKubernetesIcons benchmarkId={rule.benchmark.id} />,
|
||||
},
|
||||
{
|
||||
title: i18n.translate('xpack.csp.findings.findingsFlyout.ruleTab.cisSectionTitle', {
|
||||
|
|
|
@ -11,9 +11,12 @@ const mockClusterBuckets: ClusterBucket[] = [
|
|||
{
|
||||
key: 'cluster_id',
|
||||
doc_count: 10,
|
||||
benchmarks: {
|
||||
benchmarkName: {
|
||||
buckets: [{ key: 'CIS Kubernetes', doc_count: 10 }],
|
||||
},
|
||||
benchmarkId: {
|
||||
buckets: [{ key: 'cis_k8s', doc_count: 10 }],
|
||||
},
|
||||
timestamps: {
|
||||
buckets: [{ key: 123, doc_count: 1 }],
|
||||
},
|
||||
|
@ -59,6 +62,7 @@ describe('getClustersFromAggs', () => {
|
|||
lastUpdate: 123,
|
||||
clusterId: 'cluster_id',
|
||||
benchmarkName: 'CIS Kubernetes',
|
||||
benchmarkId: 'cis_k8s',
|
||||
},
|
||||
stats: {
|
||||
totalFindings: 12,
|
||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
|||
QueryDslQueryContainer,
|
||||
SearchRequest,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
import { Cluster } from '../../../common/types';
|
||||
import type { BenchmarkId, Cluster } from '../../../common/types';
|
||||
import {
|
||||
getFailedFindingsFromAggs,
|
||||
failedFindingsAggQuery,
|
||||
|
@ -29,7 +29,8 @@ export interface ClusterBucket extends FailedFindingsQueryResult, KeyDocCount {
|
|||
passed_findings: {
|
||||
doc_count: number;
|
||||
};
|
||||
benchmarks: Aggregation<KeyDocCount>;
|
||||
benchmarkName: Aggregation<KeyDocCount>;
|
||||
benchmarkId: Aggregation<KeyDocCount<BenchmarkId>>;
|
||||
timestamps: Aggregation<KeyDocCount<UnixEpochTime>>;
|
||||
}
|
||||
|
||||
|
@ -48,11 +49,16 @@ export const getClustersQuery = (query: QueryDslQueryContainer, pitId: string):
|
|||
field: 'cluster_id',
|
||||
},
|
||||
aggs: {
|
||||
benchmarks: {
|
||||
benchmarkName: {
|
||||
terms: {
|
||||
field: 'rule.benchmark.name',
|
||||
},
|
||||
},
|
||||
benchmarkId: {
|
||||
terms: {
|
||||
field: 'rule.benchmark.id',
|
||||
},
|
||||
},
|
||||
timestamps: {
|
||||
terms: {
|
||||
field: '@timestamp',
|
||||
|
@ -75,14 +81,21 @@ export const getClustersQuery = (query: QueryDslQueryContainer, pitId: string):
|
|||
export const getClustersFromAggs = (clusters: ClusterBucket[]): ClusterWithoutTrend[] =>
|
||||
clusters.map((cluster) => {
|
||||
// get cluster's meta data
|
||||
const benchmarks = cluster.benchmarks.buckets;
|
||||
if (!Array.isArray(benchmarks)) throw new Error('missing aggs by benchmarks per cluster');
|
||||
const benchmarkNames = cluster.benchmarkName.buckets;
|
||||
const benchmarkIds = cluster.benchmarkId.buckets;
|
||||
|
||||
if (!Array.isArray(benchmarkIds) || benchmarkIds.length === 0)
|
||||
throw new Error('missing aggs by benchmarkIds per cluster');
|
||||
|
||||
if (!Array.isArray(benchmarkNames)) throw new Error('missing aggs by benchmarks per cluster');
|
||||
|
||||
const timestamps = cluster.timestamps.buckets;
|
||||
if (!Array.isArray(timestamps)) throw new Error('missing aggs by timestamps per cluster');
|
||||
|
||||
const meta = {
|
||||
clusterId: cluster.key,
|
||||
benchmarkName: benchmarks[0].key,
|
||||
benchmarkName: benchmarkNames[0].key,
|
||||
benchmarkId: benchmarkIds[0].key,
|
||||
lastUpdate: timestamps[0].key,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue