mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 6655eeff50
)
Co-authored-by: Or Ouziel <or.ouziel@elastic.co>
This commit is contained in:
parent
31726b19b9
commit
50da9dc827
6 changed files with 68 additions and 1 deletions
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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 { type CustomAssetsAccordionProps, CustomAssetsAccordion } from '@kbn/fleet-plugin/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useKibana } from '../../common/hooks/use_kibana';
|
||||
import { cloudPosturePages } from '../../common/navigation/constants';
|
||||
|
||||
const SECURITY_APP_NAME = 'securitySolutionUI';
|
||||
|
||||
export const CspCustomAssetsExtension = () => {
|
||||
const { application } = useKibana().services;
|
||||
|
||||
const views: CustomAssetsAccordionProps['views'] = [
|
||||
{
|
||||
name: cloudPosturePages.dashboard.name,
|
||||
url: application.getUrlForApp(SECURITY_APP_NAME, { path: cloudPosturePages.dashboard.path }),
|
||||
description: i18n.translate(
|
||||
'xpack.csp.createPackagePolicy.customAssetsTab.dashboardViewLabel',
|
||||
{ defaultMessage: 'View CSP Dashboard' }
|
||||
),
|
||||
},
|
||||
{
|
||||
name: cloudPosturePages.findings.name,
|
||||
url: application.getUrlForApp(SECURITY_APP_NAME, { path: cloudPosturePages.findings.path }),
|
||||
description: i18n.translate(
|
||||
'xpack.csp.createPackagePolicy.customAssetsTab.findingsViewLabel',
|
||||
{ defaultMessage: 'View CSP Findings ' }
|
||||
),
|
||||
},
|
||||
{
|
||||
name: cloudPosturePages.rules.name,
|
||||
url: application.getUrlForApp(SECURITY_APP_NAME, { path: cloudPosturePages.benchmarks.path }),
|
||||
description: i18n.translate('xpack.csp.createPackagePolicy.customAssetsTab.rulesViewLabel', {
|
||||
defaultMessage: 'Manage CSP Rules ',
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
return <CustomAssetsAccordion views={views} initialIsOpen />;
|
||||
};
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export { CspCustomAssetsExtension as default };
|
|
@ -27,6 +27,7 @@ import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects';
|
|||
import { render } from '@testing-library/react';
|
||||
import { useFindingsEsPit } from './es_pit/use_findings_es_pit';
|
||||
import { expectIdsInDoc } from '../../test/utils';
|
||||
import { fleetMock } from '@kbn/fleet-plugin/public/mocks';
|
||||
|
||||
jest.mock('../../common/api/use_latest_findings_data_view');
|
||||
jest.mock('../../common/api/use_setup_status_api');
|
||||
|
@ -55,6 +56,7 @@ const renderFindingsPage = () => {
|
|||
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
discover: discoverPluginMock.createStartContract(),
|
||||
fleet: fleetMock.createStartMock(),
|
||||
}}
|
||||
>
|
||||
<Findings />
|
||||
|
|
|
@ -23,6 +23,7 @@ import { getPaginationQuery } from '../utils/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';
|
||||
import { fleetMock } from '@kbn/fleet-plugin/public/mocks';
|
||||
|
||||
jest.mock('../../../common/api/use_latest_findings_data_view');
|
||||
jest.mock('../../../common/api/use_cis_kubernetes_integration');
|
||||
|
@ -68,6 +69,7 @@ describe('<LatestFindingsContainer />', () => {
|
|||
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
discover: discoverPluginMock.createStartContract(),
|
||||
fleet: fleetMock.createStartMock(),
|
||||
}}
|
||||
>
|
||||
<FindingsEsPitContext.Provider value={{ setPitId, pitIdRef, pitQuery }}>
|
||||
|
|
|
@ -16,6 +16,11 @@ import type {
|
|||
CspClientPluginSetupDeps,
|
||||
CspClientPluginStartDeps,
|
||||
} from './types';
|
||||
import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME } from '../common/constants';
|
||||
|
||||
const LazyCspCustomAssets = lazy(
|
||||
() => import('./components/fleet_extensions/custom_assets_extension')
|
||||
);
|
||||
|
||||
const CspRouterLazy = lazy(() => import('./application/csp_router'));
|
||||
const CspRouter = (props: CspRouterProps) => (
|
||||
|
@ -42,6 +47,12 @@ export class CspPlugin
|
|||
}
|
||||
|
||||
public start(core: CoreStart, plugins: CspClientPluginStartDeps): CspClientPluginStart {
|
||||
plugins.fleet.registerExtension({
|
||||
package: CLOUD_SECURITY_POSTURE_PACKAGE_NAME,
|
||||
view: 'package-detail-assets',
|
||||
Component: LazyCspCustomAssets,
|
||||
});
|
||||
|
||||
return {
|
||||
getCloudSecurityPostureRouter: () => (props: CspRouterProps) =>
|
||||
(
|
||||
|
|
|
@ -16,6 +16,7 @@ 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 { fleetMock } from '@kbn/fleet-plugin/public/mocks';
|
||||
import type { CspClientPluginStartDeps } from '../types';
|
||||
|
||||
interface CspAppDeps {
|
||||
|
@ -31,6 +32,7 @@ export const TestProvider: React.FC<Partial<CspAppDeps>> = ({
|
|||
unifiedSearch: unifiedSearchPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
discover: discoverPluginMock.createStartContract(),
|
||||
fleet: fleetMock.createStartMock(),
|
||||
},
|
||||
params = coreMock.createAppMountParameters(),
|
||||
children,
|
||||
|
|
|
@ -10,6 +10,7 @@ import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/
|
|||
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';
|
||||
import type { FleetSetup, FleetStart } from '@kbn/fleet-plugin/public';
|
||||
import type { CspRouterProps } from './application/csp_router';
|
||||
import type { BreadcrumbEntry, CloudSecurityPosturePageId } from './common/navigation/types';
|
||||
|
||||
|
@ -30,7 +31,7 @@ export interface CspClientPluginStart {
|
|||
export interface CspClientPluginSetupDeps {
|
||||
// required
|
||||
data: DataPublicPluginSetup;
|
||||
|
||||
fleet: FleetSetup;
|
||||
// optional
|
||||
}
|
||||
|
||||
|
@ -40,6 +41,7 @@ export interface CspClientPluginStartDeps {
|
|||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
discover: DiscoverStart;
|
||||
fleet: FleetStart;
|
||||
// optional
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue