mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Cloud Posture] Add latest-findings index link (#136096)
This commit is contained in:
parent
ca2d1d6975
commit
89dd6cb91e
6 changed files with 54 additions and 7 deletions
|
@ -10,6 +10,6 @@
|
|||
"description": "The cloud security posture plugin",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["navigation", "data", "fleet", "unifiedSearch", "taskManager", "security", "charts"],
|
||||
"requiredPlugins": ["navigation", "data", "fleet", "unifiedSearch", "taskManager", "security", "charts", "discover"],
|
||||
"requiredBundles": ["kibanaReact"]
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import { useCisKubernetesIntegration } from '../../common/api/use_cis_kubernetes
|
|||
import type { DataView } from '@kbn/data-plugin/common';
|
||||
import { chartPluginMock } from '@kbn/charts-plugin/public/mocks';
|
||||
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
import { discoverPluginMock } from '@kbn/discover-plugin/public/mocks';
|
||||
import type { DiscoverStart } from '@kbn/discover-plugin/public';
|
||||
|
||||
jest.mock('../../common/api/use_latest_findings_data_view');
|
||||
jest.mock('../../common/api/use_cis_kubernetes_integration');
|
||||
|
@ -34,12 +36,14 @@ const Wrapper = ({
|
|||
data = dataPluginMock.createStartContract(),
|
||||
unifiedSearch = unifiedSearchPluginMock.createStartContract(),
|
||||
charts = chartPluginMock.createStartContract(),
|
||||
discover = discoverPluginMock.createStartContract(),
|
||||
}: {
|
||||
data: DataPublicPluginStart;
|
||||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
discover: DiscoverStart;
|
||||
}) => (
|
||||
<TestProvider deps={{ data, unifiedSearch, charts }}>
|
||||
<TestProvider deps={{ data, unifiedSearch, charts, discover }}>
|
||||
<Findings />
|
||||
</TestProvider>
|
||||
);
|
||||
|
@ -49,6 +53,7 @@ describe.skip('<Findings />', () => {
|
|||
const data = dataPluginMock.createStartContract();
|
||||
const unifiedSearch = unifiedSearchPluginMock.createStartContract();
|
||||
const charts = chartPluginMock.createStartContract();
|
||||
const discover = discoverPluginMock.createStartContract();
|
||||
const source = await data.search.searchSource.create();
|
||||
|
||||
(useCisKubernetesIntegration as jest.Mock).mockImplementation(() => ({
|
||||
|
@ -65,7 +70,9 @@ describe.skip('<Findings />', () => {
|
|||
}),
|
||||
} as UseQueryResult<DataView>);
|
||||
|
||||
render(<Wrapper data={data} unifiedSearch={unifiedSearch} charts={charts} />);
|
||||
render(
|
||||
<Wrapper data={data} unifiedSearch={unifiedSearch} charts={charts} discover={discover} />
|
||||
);
|
||||
|
||||
expect(await screen.findByTestId(TEST_SUBJECTS.FINDINGS_CONTAINER)).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
@ -5,18 +5,29 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { EuiAccordion, EuiDescriptionList, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import {
|
||||
EuiAccordion,
|
||||
EuiDescriptionList,
|
||||
EuiLink,
|
||||
EuiPanel,
|
||||
EuiSpacer,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import React, { useMemo } from 'react';
|
||||
import moment from 'moment';
|
||||
import type { EuiDescriptionListProps, EuiAccordionProps } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useLatestFindingsDataView } from '../../../common/api/use_latest_findings_data_view';
|
||||
import { useKibana } from '../../../common/hooks/use_kibana';
|
||||
import { CspFinding } from '../types';
|
||||
import { CisKubernetesIcons, Markdown, CodeBlock } from './findings_flyout';
|
||||
|
||||
type Accordion = Pick<EuiAccordionProps, 'title' | 'id' | 'initialIsOpen'> &
|
||||
Pick<EuiDescriptionListProps, 'listItems'>;
|
||||
|
||||
const getDetailsList = (data: CspFinding) => [
|
||||
const INDEX_LINK_NAME = 'logs-cloud_security_posture.findings_latest-default';
|
||||
|
||||
const getDetailsList = (data: CspFinding, discoverIndexLink: string | undefined) => [
|
||||
{
|
||||
title: i18n.translate('xpack.csp.findings.findingsFlyout.overviewTab.ruleNameTitle', {
|
||||
defaultMessage: 'Rule Name',
|
||||
|
@ -47,6 +58,16 @@ const getDetailsList = (data: CspFinding) => [
|
|||
}),
|
||||
description: data.rule.section,
|
||||
},
|
||||
{
|
||||
title: i18n.translate('xpack.csp.findings.findingsFlyout.overviewTab.indexTitle', {
|
||||
defaultMessage: 'Index',
|
||||
}),
|
||||
description: discoverIndexLink ? (
|
||||
<EuiLink href={discoverIndexLink}>{INDEX_LINK_NAME}</EuiLink>
|
||||
) : (
|
||||
INDEX_LINK_NAME
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export const getRemediationList = (rule: CspFinding['rule']) => [
|
||||
|
@ -99,6 +120,19 @@ const getEvidenceList = ({ result }: CspFinding) =>
|
|||
].filter(Boolean) as EuiDescriptionListProps['listItems'];
|
||||
|
||||
export const OverviewTab = ({ data }: { data: CspFinding }) => {
|
||||
const {
|
||||
services: { discover },
|
||||
} = useKibana();
|
||||
const latestFindingsDataView = useLatestFindingsDataView();
|
||||
|
||||
const discoverIndexLink = useMemo(
|
||||
() =>
|
||||
discover.locator?.getRedirectUrl({
|
||||
indexPatternId: latestFindingsDataView.data?.id,
|
||||
}),
|
||||
[discover.locator, latestFindingsDataView.data?.id]
|
||||
);
|
||||
|
||||
const accordions: Accordion[] = useMemo(
|
||||
() => [
|
||||
{
|
||||
|
@ -107,7 +141,7 @@ export const OverviewTab = ({ data }: { data: CspFinding }) => {
|
|||
defaultMessage: 'Details',
|
||||
}),
|
||||
id: 'detailsAccordion',
|
||||
listItems: getDetailsList(data),
|
||||
listItems: getDetailsList(data, discoverIndexLink),
|
||||
},
|
||||
{
|
||||
initialIsOpen: true,
|
||||
|
@ -127,7 +161,7 @@ export const OverviewTab = ({ data }: { data: CspFinding }) => {
|
|||
listItems: getEvidenceList(data),
|
||||
},
|
||||
],
|
||||
[data]
|
||||
[data, discoverIndexLink]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
@ -22,6 +22,7 @@ import { buildEsQuery } from '@kbn/es-query';
|
|||
import { getPaginationQuery } from '../utils';
|
||||
import { FindingsEsPitContext } from '../es_pit/findings_es_pit_context';
|
||||
import { chartPluginMock } from '@kbn/charts-plugin/public/mocks';
|
||||
import { discoverPluginMock } from '@kbn/discover-plugin/public/mocks';
|
||||
|
||||
jest.mock('../../../common/api/use_latest_findings_data_view');
|
||||
jest.mock('../../../common/api/use_cis_kubernetes_integration');
|
||||
|
@ -66,6 +67,7 @@ describe('<LatestFindingsContainer />', () => {
|
|||
data: dataMock,
|
||||
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
discover: discoverPluginMock.createStartContract(),
|
||||
}}
|
||||
>
|
||||
<FindingsEsPitContext.Provider value={{ setPitId, pitIdRef, pitQuery }}>
|
||||
|
|
|
@ -14,6 +14,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
|
|||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { chartPluginMock } from '@kbn/charts-plugin/public/mocks';
|
||||
import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks';
|
||||
import { discoverPluginMock } from '@kbn/discover-plugin/public/mocks';
|
||||
import type { CspAppDeps } from '../application/app';
|
||||
|
||||
export const TestProvider: React.FC<Partial<CspAppDeps>> = ({
|
||||
|
@ -22,6 +23,7 @@ export const TestProvider: React.FC<Partial<CspAppDeps>> = ({
|
|||
data: dataPluginMock.createStartContract(),
|
||||
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
discover: discoverPluginMock.createStartContract(),
|
||||
},
|
||||
params = coreMock.createAppMountParameters(),
|
||||
children,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||
import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
import type { DiscoverStart } from '@kbn/discover-plugin/public';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface CspClientPluginSetup {}
|
||||
|
@ -26,5 +27,6 @@ export interface CspClientPluginStartDeps {
|
|||
data: DataPublicPluginStart;
|
||||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
discover: DiscoverStart;
|
||||
// optional
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue