From 3bc07467b73a57790dfb75e3ed4ce72554985e8b Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 23 Feb 2023 22:25:48 -0500 Subject: [PATCH 1/9] Add 'enabled' config option to multiple plugins for projects. --- config/serverless.oblt.yml | 8 ++++++++ x-pack/plugins/apm/server/index.ts | 1 + x-pack/plugins/canvas/server/index.ts | 8 ++++++++ x-pack/plugins/enterprise_search/server/index.ts | 1 + x-pack/plugins/fleet/common/authz.ts | 2 +- x-pack/plugins/fleet/server/config.ts | 1 + x-pack/plugins/observability/server/index.ts | 1 + x-pack/plugins/security/server/config.test.ts | 3 +++ x-pack/plugins/security/server/config.ts | 1 + x-pack/plugins/security_solution/server/config.mock.ts | 1 + x-pack/plugins/security_solution/server/config.ts | 1 + x-pack/plugins/synthetics/common/config.ts | 1 + x-pack/plugins/synthetics/kibana.jsonc | 6 +++--- .../legacy_uptime/lib/adapters/framework/adapter_types.ts | 3 ++- .../synthetics_service/get_service_locations.test.ts | 3 +++ .../private_location/synthetics_private_location.ts | 2 +- .../server/synthetics_service/synthetics_service.test.ts | 3 ++- x-pack/plugins/watcher/server/index.ts | 8 ++++++++ 18 files changed, 47 insertions(+), 7 deletions(-) diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index e69de29bb2d1d..58d786b798fc9 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -0,0 +1,8 @@ +enterpriseSearch.enabled: false +xpack.canvas.enabled: false +xpack.cloudSecurityPosture.enabled: false +xpack.reporting.enabled: false +xpack.securitySolution.enabled: false +xpack.watcher.enabled: false + +uiSettings.overrides.defaultRoute: /app/observability/overview diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index 74eea568788b5..dba2d6e29ae7c 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -53,6 +53,7 @@ const configSchema = schema.object({ onboarding: schema.string({ defaultValue: 'apm-*' }), }), forceSyntheticSource: schema.boolean({ defaultValue: false }), + enabled: schema.boolean({ defaultValue: true }), }); // plugin config diff --git a/x-pack/plugins/canvas/server/index.ts b/x-pack/plugins/canvas/server/index.ts index d6d375b7259ac..d25ad10dd8e34 100644 --- a/x-pack/plugins/canvas/server/index.ts +++ b/x-pack/plugins/canvas/server/index.ts @@ -6,7 +6,15 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; +import { schema } from '@kbn/config-schema'; + import { CanvasPlugin } from './plugin'; export const plugin = (initializerContext: PluginInitializerContext) => new CanvasPlugin(initializerContext); + +export const config = { + schema: schema.object({ + enabled: schema.boolean({ defaultValue: true }), + }), +}; diff --git a/x-pack/plugins/enterprise_search/server/index.ts b/x-pack/plugins/enterprise_search/server/index.ts index b8f65c23ab674..e1a1b33fa67ab 100644 --- a/x-pack/plugins/enterprise_search/server/index.ts +++ b/x-pack/plugins/enterprise_search/server/index.ts @@ -18,6 +18,7 @@ export const configSchema = schema.object({ accessCheckTimeout: schema.number({ defaultValue: 5000 }), accessCheckTimeoutWarning: schema.number({ defaultValue: 300 }), customHeaders: schema.maybe(schema.object({}, { unknowns: 'allow' })), + enabled: schema.boolean({ defaultValue: true }), host: schema.maybe(schema.string()), ssl: schema.object({ certificateAuthorities: schema.maybe( diff --git a/x-pack/plugins/fleet/common/authz.ts b/x-pack/plugins/fleet/common/authz.ts index fa30f2b8f7f33..a275a55a48206 100644 --- a/x-pack/plugins/fleet/common/authz.ts +++ b/x-pack/plugins/fleet/common/authz.ts @@ -99,7 +99,7 @@ export function calculatePackagePrivilegesFromCapabilities( return { ...acc, [privilege]: { - executePackageAction: capabilities.siem[privilegeName] || false, + executePackageAction: (capabilities.siem && capabilities.siem[privilegeName]) || false, }, }; }, diff --git a/x-pack/plugins/fleet/server/config.ts b/x-pack/plugins/fleet/server/config.ts index d5312bf9bc65c..41eb7e03e29c7 100644 --- a/x-pack/plugins/fleet/server/config.ts +++ b/x-pack/plugins/fleet/server/config.ts @@ -158,6 +158,7 @@ export const config: PluginConfigDescriptor = { } }, }), + enabled: schema.boolean({ defaultValue: true }), }), }; diff --git a/x-pack/plugins/observability/server/index.ts b/x-pack/plugins/observability/server/index.ts index ec930b813fb36..2ae55b5fa0b5f 100644 --- a/x-pack/plugins/observability/server/index.ts +++ b/x-pack/plugins/observability/server/index.ts @@ -47,6 +47,7 @@ const configSchema = schema.object({ }), }), }), + enabled: schema.boolean({ defaultValue: true }), }); export const config: PluginConfigDescriptor = { diff --git a/x-pack/plugins/security/server/config.test.ts b/x-pack/plugins/security/server/config.test.ts index 8b7324e70d646..49c1e4b951e92 100644 --- a/x-pack/plugins/security/server/config.test.ts +++ b/x-pack/plugins/security/server/config.test.ts @@ -60,6 +60,7 @@ describe('config schema', () => { "selector": Object {}, }, "cookieName": "sid", + "enabled": true, "encryptionKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "loginAssistanceMessage": "", "public": Object {}, @@ -113,6 +114,7 @@ describe('config schema', () => { "selector": Object {}, }, "cookieName": "sid", + "enabled": true, "encryptionKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "loginAssistanceMessage": "", "public": Object {}, @@ -166,6 +168,7 @@ describe('config schema', () => { "selector": Object {}, }, "cookieName": "sid", + "enabled": true, "loginAssistanceMessage": "", "public": Object {}, "secureCookies": false, diff --git a/x-pack/plugins/security/server/config.ts b/x-pack/plugins/security/server/config.ts index e3584427964f3..5620b35c1fef7 100644 --- a/x-pack/plugins/security/server/config.ts +++ b/x-pack/plugins/security/server/config.ts @@ -295,6 +295,7 @@ export const ConfigSchema = schema.object({ ) ), }), + enabled: schema.boolean({ defaultValue: true }), }); export function createConfig( diff --git a/x-pack/plugins/security_solution/server/config.mock.ts b/x-pack/plugins/security_solution/server/config.mock.ts index c1faa6f401a1d..6fcaa94629643 100644 --- a/x-pack/plugins/security_solution/server/config.mock.ts +++ b/x-pack/plugins/security_solution/server/config.mock.ts @@ -31,6 +31,7 @@ export const createMockConfig = (): ConfigType => { alertIgnoreFields: [], experimentalFeatures: parseExperimentalConfigValue(enableExperimental), + enabled: true, }; }; diff --git a/x-pack/plugins/security_solution/server/config.ts b/x-pack/plugins/security_solution/server/config.ts index 26f1be4f014b3..a0283858590cb 100644 --- a/x-pack/plugins/security_solution/server/config.ts +++ b/x-pack/plugins/security_solution/server/config.ts @@ -122,6 +122,7 @@ export const configSchema = schema.object({ * the package is not already installed. */ prebuiltRulesPackageVersion: schema.maybe(schema.string()), + enabled: schema.boolean({ defaultValue: true }), }); export type ConfigSchema = TypeOf; diff --git a/x-pack/plugins/synthetics/common/config.ts b/x-pack/plugins/synthetics/common/config.ts index c9c48e5878391..9da43f8bf9a08 100644 --- a/x-pack/plugins/synthetics/common/config.ts +++ b/x-pack/plugins/synthetics/common/config.ts @@ -23,6 +23,7 @@ const serviceConfig = schema.object({ const uptimeConfig = schema.object({ index: schema.maybe(schema.string()), service: schema.maybe(serviceConfig), + enabled: schema.boolean({ defaultValue: true }), }); export const config: PluginConfigDescriptor = { diff --git a/x-pack/plugins/synthetics/kibana.jsonc b/x-pack/plugins/synthetics/kibana.jsonc index 3236a730f1a59..5e6f1a6f30233 100644 --- a/x-pack/plugins/synthetics/kibana.jsonc +++ b/x-pack/plugins/synthetics/kibana.jsonc @@ -15,6 +15,8 @@ "actions", "alerting", "cases", + "data", + "fleet", "embeddable", "discover", "dataViews", @@ -35,8 +37,6 @@ ], "optionalPlugins": [ "cloud", - "data", - "fleet", "home", "ml", "telemetry" @@ -52,4 +52,4 @@ "indexLifecycleManagement" ] } -} +} \ No newline at end of file diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/adapters/framework/adapter_types.ts index ec77b83977a09..2237fe29df0d5 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/adapters/framework/adapter_types.ts @@ -28,7 +28,7 @@ import { MlPluginSetup as MlSetup } from '@kbn/ml-plugin/server'; import { RuleRegistryPluginSetupContract } from '@kbn/rule-registry-plugin/server'; import { SecurityPluginStart } from '@kbn/security-plugin/server'; import { CloudSetup } from '@kbn/cloud-plugin/server'; -import { SpacesPluginStart } from '@kbn/spaces-plugin/server'; +import { SpacesPluginSetup, SpacesPluginStart } from '@kbn/spaces-plugin/server'; import { FleetStartContract } from '@kbn/fleet-plugin/server'; import { BfetchServerSetup } from '@kbn/bfetch-plugin/server'; import { UptimeEsClient } from '../../lib'; @@ -76,6 +76,7 @@ export interface UptimeCorePluginsSetup { usageCollection: UsageCollectionSetup; ml: MlSetup; cloud?: CloudSetup; + spaces: SpacesPluginSetup; ruleRegistry: RuleRegistryPluginSetupContract; encryptedSavedObjects: EncryptedSavedObjectsPluginSetup; taskManager: TaskManagerSetupContract; diff --git a/x-pack/plugins/synthetics/server/synthetics_service/get_service_locations.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/get_service_locations.test.ts index 1fed640bcb4e8..58faf6ba14877 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/get_service_locations.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/get_service_locations.test.ts @@ -50,6 +50,7 @@ describe('getServiceLocations', function () { manifestUrl: 'http://local.dev', showExperimentalLocations: false, }, + enabled: true, }, // @ts-ignore logger: { @@ -101,6 +102,7 @@ describe('getServiceLocations', function () { manifestUrl: 'http://local.dev', showExperimentalLocations: false, }, + enabled: true, }, // @ts-ignore logger: { @@ -138,6 +140,7 @@ describe('getServiceLocations', function () { manifestUrl: 'http://local.dev', showExperimentalLocations: true, }, + enabled: true, }, // @ts-ignore logger: { diff --git a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts index 02a1828c1f56c..41410f3c0aa3a 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/private_location/synthetics_private_location.ts @@ -356,7 +356,7 @@ export class SyntheticsPrivateLocation { } ); - return agentPolicies.items; + return agentPolicies.items || []; } } diff --git a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.test.ts index 7144284e6b4f0..abb56011a14b9 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.test.ts @@ -42,7 +42,7 @@ describe('SyntheticsService', () => { } as unknown as UptimeServerSetup; const getMockedService = (locationsNum: number = 1) => { - serverMock.config = { service: { devUrl: 'http://localhost' } }; + serverMock.config = { service: { devUrl: 'http://localhost' }, enabled: true }; const service = new SyntheticsService(serverMock); const locations = times(locationsNum).map((n) => { @@ -116,6 +116,7 @@ describe('SyntheticsService', () => { username: 'dev', password: '12345', }, + enabled: true, }; const service = new SyntheticsService(serverMock); diff --git a/x-pack/plugins/watcher/server/index.ts b/x-pack/plugins/watcher/server/index.ts index 0aba44ed82838..36453f571f162 100644 --- a/x-pack/plugins/watcher/server/index.ts +++ b/x-pack/plugins/watcher/server/index.ts @@ -6,6 +6,14 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; +import { schema } from '@kbn/config-schema'; + import { WatcherServerPlugin } from './plugin'; export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(ctx); + +export const config = { + schema: schema.object({ + enabled: schema.boolean({ defaultValue: true }), + }), +}; From 9ea16a7168256da017db7fc53fe47572407f63c6 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 23 Feb 2023 22:30:03 -0500 Subject: [PATCH 2/9] Add ability to hide Observability navigation --- .../page_template/lazy_page_template.tsx | 28 +++++++++++++------ .../page_template/page_template.test.tsx | 1 + .../shared/page_template/page_template.tsx | 6 +++- x-pack/plugins/observability/public/plugin.ts | 2 ++ .../public/services/navigation_registry.ts | 10 ++++++- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx index 7c61cae4f2c73..7bbc0dbc9ea70 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx @@ -6,6 +6,7 @@ */ import React from 'react'; +import useObservable from 'react-use/lib/useObservable'; import type { ObservabilityPageTemplateDependencies, WrappedPageTemplateProps, @@ -15,12 +16,23 @@ export const LazyObservabilityPageTemplate = React.lazy(() => import('./page_tem export type LazyObservabilityPageTemplateProps = WrappedPageTemplateProps; -export function createLazyObservabilityPageTemplate( - injectedDeps: ObservabilityPageTemplateDependencies -) { - return (pageTemplateProps: LazyObservabilityPageTemplateProps) => ( - - - - ); +export function createLazyObservabilityPageTemplate({ + isSidebarEnabled$, + ...injectedDeps +}: ObservabilityPageTemplateDependencies) { + return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { + const isSidebarEnabled = useObservable(isSidebarEnabled$, true); + const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; + let showSolutionNav = showSolutionNavProp; + + if (!isSidebarEnabled) { + showSolutionNav = false; + } + + return ( + + + + ); + }; } diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx index 2a5324ddb5397..ae221fce17319 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx @@ -56,6 +56,7 @@ describe('Page template', () => { navigationSections$: navigationRegistry.sections$, getPageTemplateServices, guidedOnboardingApi: guidedOnboardingMock.createStart().guidedOnboardingApi, + isSidebarEnabled$: of(true), }); const component = shallow( diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx index cafe693b8832b..c4dae7c1dc745 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx @@ -53,9 +53,13 @@ export interface ObservabilityPageTemplateDependencies { navigationSections$: Observable; getPageTemplateServices: () => KibanaPageTemplateKibanaDependencies; guidedOnboardingApi: GuidedOnboardingPluginStart['guidedOnboardingApi']; + isSidebarEnabled$: Observable; } -export type ObservabilityPageTemplateProps = ObservabilityPageTemplateDependencies & +export type ObservabilityPageTemplateProps = Omit< + ObservabilityPageTemplateDependencies, + 'isSidebarEnabled$' +> & WrappedPageTemplateProps; export function ObservabilityPageTemplate({ diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index e43725d0c5681..69c1a56084c20 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -316,6 +316,7 @@ export class Plugin observabilityRuleTypeRegistry: this.observabilityRuleTypeRegistry, navigation: { registerSections: this.navigationRegistry.registerSections, + setIsSidebarEnabled: this.navigationRegistry.setIsSidebarEnabled, }, useRulesLink: createUseRulesLink(), }; @@ -341,6 +342,7 @@ export class Plugin navigationSections$: this.navigationRegistry.sections$, guidedOnboardingApi: pluginsStart.guidedOnboarding.guidedOnboardingApi, getPageTemplateServices: () => ({ coreStart }), + isSidebarEnabled$: this.navigationRegistry.isSidebarEnabled$, }); const getAsyncO11yAlertsTableConfiguration = async () => { diff --git a/x-pack/plugins/observability/public/services/navigation_registry.ts b/x-pack/plugins/observability/public/services/navigation_registry.ts index 5f10a6f6c6851..e18929799b5fb 100644 --- a/x-pack/plugins/observability/public/services/navigation_registry.ts +++ b/x-pack/plugins/observability/public/services/navigation_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { combineLatest, Observable, ReplaySubject } from 'rxjs'; +import { combineLatest, Observable, ReplaySubject, BehaviorSubject } from 'rxjs'; import { map, scan, shareReplay, switchMap } from 'rxjs/operators'; export interface NavigationSection { @@ -45,6 +45,8 @@ export interface NavigationEntry { export interface NavigationRegistry { registerSections: (sections$: Observable) => void; sections$: Observable; + isSidebarEnabled$: Observable; + setIsSidebarEnabled: (enabled: boolean) => void; } export const createNavigationRegistry = (): NavigationRegistry => { @@ -54,6 +56,8 @@ export const createNavigationRegistry = (): NavigationRegistry => { registeredSections$.next(sections$); }; + const isSidebarEnabled$ = new BehaviorSubject(true); + const sections$: Observable = registeredSections$.pipe( scan( (accumulatedSections$, newSections) => accumulatedSections$.add(newSections), @@ -69,5 +73,9 @@ export const createNavigationRegistry = (): NavigationRegistry => { return { registerSections, sections$, + isSidebarEnabled$, + setIsSidebarEnabled: (enabled) => { + isSidebarEnabled$.next(enabled); + }, }; }; From a5b1fa6e9f858582e8e0b4a4e088fad0e2c37692 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 23 Feb 2023 23:01:20 -0500 Subject: [PATCH 3/9] Create Serverless o11y plugin; hide internal nav via API --- .github/CODEOWNERS | 1 + config/serverless.oblt.yml | 2 ++ docs/developer/plugin-list.asciidoc | 4 +++ package.json | 1 + packages/kbn-optimizer/limits.yml | 1 + tsconfig.base.json | 2 ++ .../serverless_observability/.gitignore | 2 ++ .../serverless_observability/.i18nrc.json | 7 ++++ .../serverless_observability/README.md | 3 ++ .../serverless_observability/common/index.ts | 9 +++++ .../serverless_observability/kibana.jsonc | 21 ++++++++++++ .../serverless_observability/package.json | 11 +++++++ .../serverless_observability/public/index.ts | 19 +++++++++++ .../serverless_observability/public/plugin.ts | 33 +++++++++++++++++++ .../serverless_observability/public/types.ts | 21 ++++++++++++ .../serverless_observability/server/config.ts | 23 +++++++++++++ .../serverless_observability/server/index.ts | 23 +++++++++++++ .../serverless_observability/server/plugin.ts | 26 +++++++++++++++ .../serverless_observability/server/types.ts | 11 +++++++ .../serverless_observability/tsconfig.json | 22 +++++++++++++ yarn.lock | 4 +++ 21 files changed, 246 insertions(+) create mode 100644 x-pack/plugins/serverless_observability/.gitignore create mode 100644 x-pack/plugins/serverless_observability/.i18nrc.json create mode 100755 x-pack/plugins/serverless_observability/README.md create mode 100644 x-pack/plugins/serverless_observability/common/index.ts create mode 100644 x-pack/plugins/serverless_observability/kibana.jsonc create mode 100644 x-pack/plugins/serverless_observability/package.json create mode 100644 x-pack/plugins/serverless_observability/public/index.ts create mode 100644 x-pack/plugins/serverless_observability/public/plugin.ts create mode 100644 x-pack/plugins/serverless_observability/public/types.ts create mode 100644 x-pack/plugins/serverless_observability/server/config.ts create mode 100644 x-pack/plugins/serverless_observability/server/index.ts create mode 100644 x-pack/plugins/serverless_observability/server/plugin.ts create mode 100644 x-pack/plugins/serverless_observability/server/types.ts create mode 100644 x-pack/plugins/serverless_observability/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 27a7f01ec78e9..23a5df45f9951 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -547,6 +547,7 @@ packages/kbn-securitysolution-t-grid @elastic/security-solution-platform packages/kbn-securitysolution-utils @elastic/security-solution-platform packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/apm-ui +x-pack/plugins/serverless_observability @elastic/appex-sharedux test/plugin_functional/plugins/session_notifications @elastic/kibana-core x-pack/plugins/session_view @elastic/awp-viz packages/kbn-set-map @elastic/kibana-operations diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index 58d786b798fc9..b35e67c81aee7 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -5,4 +5,6 @@ xpack.reporting.enabled: false xpack.securitySolution.enabled: false xpack.watcher.enabled: false +xpack.serverless.observability.enabled: true + uiSettings.overrides.defaultRoute: /app/observability/overview diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 3cdca29fcb49d..fa1c4080fe42b 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -689,6 +689,10 @@ Kibana. |Welcome to the Kibana Security Solution plugin! This README will go over getting started with development and testing. +|{kib-repo}blob/{branch}/x-pack/plugins/serverless_observability/README.md[serverlessObservability] +|A witty, fitting description to come. + + |{kib-repo}blob/{branch}/x-pack/plugins/session_view/README.md[sessionView] |Session View is meant to provide a visualization into what is going on in a particular Linux environment where the agent is running. It looks likes a terminal emulator; however, it is a tool for introspecting process activity and understanding user and service behaviour in your Linux servers and infrastructure. It is a time-ordered series of process executions displayed in a tree over time. diff --git a/package.json b/package.json index a363b2c162e56..5e34275fd563e 100644 --- a/package.json +++ b/package.json @@ -549,6 +549,7 @@ "@kbn/securitysolution-utils": "link:packages/kbn-securitysolution-utils", "@kbn/server-http-tools": "link:packages/kbn-server-http-tools", "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", + "@kbn/serverless-observability": "link:x-pack/plugins/serverless_observability", "@kbn/session-notifications-plugin": "link:test/plugin_functional/plugins/session_notifications", "@kbn/session-view-plugin": "link:x-pack/plugins/session_view", "@kbn/set-map": "link:packages/kbn-set-map", diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index ad2fd0490197e..a343faa89a9a4 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -112,6 +112,7 @@ pageLoadAssetSize: searchprofiler: 67080 security: 65433 securitySolution: 66738 + serverlessObservability: 16582 sessionView: 77750 share: 71239 snapshotRestore: 79032 diff --git a/tsconfig.base.json b/tsconfig.base.json index 1e8bd1ef0ade0..4e252683b2a94 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1088,6 +1088,8 @@ "@kbn/server-http-tools/*": ["packages/kbn-server-http-tools/*"], "@kbn/server-route-repository": ["packages/kbn-server-route-repository"], "@kbn/server-route-repository/*": ["packages/kbn-server-route-repository/*"], + "@kbn/serverless-observability": ["x-pack/plugins/serverless_observability"], + "@kbn/serverless-observability/*": ["x-pack/plugins/serverless_observability/*"], "@kbn/session-notifications-plugin": ["test/plugin_functional/plugins/session_notifications"], "@kbn/session-notifications-plugin/*": ["test/plugin_functional/plugins/session_notifications/*"], "@kbn/session-view-plugin": ["x-pack/plugins/session_view"], diff --git a/x-pack/plugins/serverless_observability/.gitignore b/x-pack/plugins/serverless_observability/.gitignore new file mode 100644 index 0000000000000..c3dca1b96fcc2 --- /dev/null +++ b/x-pack/plugins/serverless_observability/.gitignore @@ -0,0 +1,2 @@ +/build +/target diff --git a/x-pack/plugins/serverless_observability/.i18nrc.json b/x-pack/plugins/serverless_observability/.i18nrc.json new file mode 100644 index 0000000000000..623c26e73e4da --- /dev/null +++ b/x-pack/plugins/serverless_observability/.i18nrc.json @@ -0,0 +1,7 @@ +{ + "prefix": "serverlessObservability", + "paths": { + "serverlessObservability": "." + }, + "translations": ["translations/ja-JP.json"] +} diff --git a/x-pack/plugins/serverless_observability/README.md b/x-pack/plugins/serverless_observability/README.md new file mode 100755 index 0000000000000..25d55bd95bb40 --- /dev/null +++ b/x-pack/plugins/serverless_observability/README.md @@ -0,0 +1,3 @@ +# serverlessObservability + +A witty, fitting description to come. \ No newline at end of file diff --git a/x-pack/plugins/serverless_observability/common/index.ts b/x-pack/plugins/serverless_observability/common/index.ts new file mode 100644 index 0000000000000..d6a5ea767034c --- /dev/null +++ b/x-pack/plugins/serverless_observability/common/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export const PLUGIN_ID = 'serverlessObservability'; +export const PLUGIN_NAME = 'serverlessObservability'; diff --git a/x-pack/plugins/serverless_observability/kibana.jsonc b/x-pack/plugins/serverless_observability/kibana.jsonc new file mode 100644 index 0000000000000..0f0e911e6807f --- /dev/null +++ b/x-pack/plugins/serverless_observability/kibana.jsonc @@ -0,0 +1,21 @@ +{ + "type": "plugin", + "id": "@kbn/serverless-observability", + "owner": "@elastic/appex-sharedux", + "description": "Serverless customizations for observability.", + "plugin": { + "id": "serverlessObservability", + "server": true, + "browser": true, + "configPath": [ + "xpack", + "serverless", + "observability" + ], + "requiredPlugins": [ + "observability" + ], + "optionalPlugins": [], + "requiredBundles": [] + } +} diff --git a/x-pack/plugins/serverless_observability/package.json b/x-pack/plugins/serverless_observability/package.json new file mode 100644 index 0000000000000..64b310d7eabae --- /dev/null +++ b/x-pack/plugins/serverless_observability/package.json @@ -0,0 +1,11 @@ +{ + "name": "@kbn/serverless-observability", + "version": "1.0.0", + "license": "Elastic License 2.0", + "private": true, + "scripts": { + "build": "yarn plugin-helpers build", + "plugin-helpers": "node ../../../scripts/plugin_helpers", + "kbn": "node ../../../scripts/kbn" + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless_observability/public/index.ts b/x-pack/plugins/serverless_observability/public/index.ts new file mode 100644 index 0000000000000..a785b68735375 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/index.ts @@ -0,0 +1,19 @@ +/* + * 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 { ServerlessObservabilityPlugin } from './plugin'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. +export function plugin() { + return new ServerlessObservabilityPlugin(); +} + +export type { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, +} from './types'; diff --git a/x-pack/plugins/serverless_observability/public/plugin.ts b/x-pack/plugins/serverless_observability/public/plugin.ts new file mode 100644 index 0000000000000..dd1c5bfbc39c7 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/plugin.ts @@ -0,0 +1,33 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, + AppPluginSetupDependencies, +} from './types'; + +export class ServerlessObservabilityPlugin + implements Plugin +{ + public setup( + _core: CoreSetup, + setupDeps: AppPluginSetupDependencies + ): ServerlessObservabilityPluginSetup { + setupDeps.observability.navigation.setIsSidebarEnabled(false); + + // Return methods that should be available to other plugins + return {}; + } + + public start(_core: CoreStart): ServerlessObservabilityPluginStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_observability/public/types.ts b/x-pack/plugins/serverless_observability/public/types.ts new file mode 100644 index 0000000000000..73ab40e9257f7 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/types.ts @@ -0,0 +1,21 @@ +/* + * 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 { ObservabilityPublicSetup } from '@kbn/observability-plugin/public'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginStart {} + +export interface AppPluginSetupDependencies { + observability: ObservabilityPublicSetup; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface AppPluginStartDependencies {} diff --git a/x-pack/plugins/serverless_observability/server/config.ts b/x-pack/plugins/serverless_observability/server/config.ts new file mode 100644 index 0000000000000..599a9f2bd7769 --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/config.ts @@ -0,0 +1,23 @@ +/* + * 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 { schema, TypeOf } from '@kbn/config-schema'; +import { PluginConfigDescriptor } from '@kbn/core/server'; + +export * from './types'; + +const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +type ConfigType = TypeOf; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export type ServerlessObservabilityConfig = TypeOf; diff --git a/x-pack/plugins/serverless_observability/server/index.ts b/x-pack/plugins/serverless_observability/server/index.ts new file mode 100644 index 0000000000000..c45e363a429bf --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/index.ts @@ -0,0 +1,23 @@ +/* + * 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 { PluginInitializerContext } from '@kbn/core/server'; + +import { ServerlessObservabilityPlugin } from './plugin'; +export { config } from './config'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. + +export function plugin(initializerContext: PluginInitializerContext) { + return new ServerlessObservabilityPlugin(initializerContext); +} + +export type { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, +} from './types'; diff --git a/x-pack/plugins/serverless_observability/server/plugin.ts b/x-pack/plugins/serverless_observability/server/plugin.ts new file mode 100644 index 0000000000000..8b28ba2b0a4ac --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/plugin.ts @@ -0,0 +1,26 @@ +/* + * 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 { PluginInitializerContext, Plugin } from '@kbn/core/server'; + +import { ServerlessObservabilityPluginSetup, ServerlessObservabilityPluginStart } from './types'; + +export class ServerlessObservabilityPlugin + implements Plugin +{ + constructor(_initializerContext: PluginInitializerContext) {} + + public setup() { + return {}; + } + + public start() { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_observability/server/types.ts b/x-pack/plugins/serverless_observability/server/types.ts new file mode 100644 index 0000000000000..f8a587103e886 --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/types.ts @@ -0,0 +1,11 @@ +/* + * 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. + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginSetup {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginStart {} diff --git a/x-pack/plugins/serverless_observability/tsconfig.json b/x-pack/plugins/serverless_observability/tsconfig.json new file mode 100644 index 0000000000000..4c9f7b818b430 --- /dev/null +++ b/x-pack/plugins/serverless_observability/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../../typings/**/*" + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/config-schema", + "@kbn/observability-plugin", + ] +} diff --git a/yarn.lock b/yarn.lock index 6ffc80f4e34d5..1c0e10bfe2fd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4913,6 +4913,10 @@ version "0.0.0" uid "" +"@kbn/serverless-observability@link:x-pack/plugins/serverless_observability": + version "0.0.0" + uid "" + "@kbn/session-notifications-plugin@link:test/plugin_functional/plugins/session_notifications": version "0.0.0" uid "" From a828a34e0cc498a8d5841dc7d068e8b8c45681ef Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Sat, 25 Feb 2023 23:16:04 -0500 Subject: [PATCH 4/9] Add ability to hide Security navigation --- .../use_primary_navigation.tsx | 10 ++++++++++ .../public/common/lib/kibana/kibana_react.mock.ts | 2 ++ x-pack/plugins/security_solution/public/index.ts | 4 ++-- x-pack/plugins/security_solution/public/plugin.tsx | 12 ++++++++++-- x-pack/plugins/security_solution/public/types.ts | 9 +++++++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/navigation/use_security_solution_navigation/use_primary_navigation.tsx b/x-pack/plugins/security_solution/public/common/components/navigation/use_security_solution_navigation/use_primary_navigation.tsx index 647193357b66b..867cda2bcf4e8 100644 --- a/x-pack/plugins/security_solution/public/common/components/navigation/use_security_solution_navigation/use_primary_navigation.tsx +++ b/x-pack/plugins/security_solution/public/common/components/navigation/use_security_solution_navigation/use_primary_navigation.tsx @@ -9,10 +9,12 @@ import React, { useEffect, useState, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template'; +import useObservable from 'react-use/lib/useObservable'; import type { PrimaryNavigationProps } from './types'; import { usePrimaryNavigationItems } from './use_navigation_items'; import { useIsGroupedNavigationEnabled } from '../helpers'; import { SecuritySideNav } from '../security_side_nav'; +import { useKibana } from '../../../lib/kibana'; const translatedNavTitle = i18n.translate('xpack.securitySolution.navigation.mainLabel', { defaultMessage: 'Security', @@ -45,6 +47,14 @@ export const usePrimaryNavigation = ({ selectedTabId, }); + const { isSidebarEnabled$ } = useKibana().services; + + const isSidebarEnabled = useObservable(isSidebarEnabled$); + + if (!isSidebarEnabled) { + return undefined; + } + return { canBeCollapsed: true, name: translatedNavTitle, diff --git a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts index efa9ce4831be7..01b67365b6926 100644 --- a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts +++ b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts @@ -45,6 +45,7 @@ import { triggersActionsUiMock } from '@kbn/triggers-actions-ui-plugin/public/mo import { mockApm } from '../apm/service.mock'; import { cloudExperimentsMock } from '@kbn/cloud-experiments-plugin/common/mocks'; import { guidedOnboardingMock } from '@kbn/guided-onboarding-plugin/public/mocks'; +import { of } from 'rxjs'; const mockUiSettings: Record = { [DEFAULT_TIME_RANGE]: { from: 'now-15m', to: 'now', mode: 'quick' }, @@ -176,6 +177,7 @@ export const createStartServicesMock = ( triggersActionsUi, cloudExperiments, guidedOnboarding, + isSidebarEnabled$: of(true), } as unknown as StartServices; }; diff --git a/x-pack/plugins/security_solution/public/index.ts b/x-pack/plugins/security_solution/public/index.ts index 1f6f121e04209..7ac596d087fca 100644 --- a/x-pack/plugins/security_solution/public/index.ts +++ b/x-pack/plugins/security_solution/public/index.ts @@ -7,10 +7,10 @@ import type { PluginInitializerContext } from '@kbn/core/public'; import { Plugin } from './plugin'; -import type { PluginSetup } from './types'; +import type { PluginSetup, PluginStart } from './types'; export type { TimelineModel } from './timelines/store/timeline/model'; export const plugin = (context: PluginInitializerContext): Plugin => new Plugin(context); -export type { PluginSetup }; +export type { PluginSetup, PluginStart }; export { Plugin }; diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index abc9c41101e25..616168b52cbba 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import type { Subscription } from 'rxjs'; -import { Subject } from 'rxjs'; +import { BehaviorSubject, Subject } from 'rxjs'; import { combineLatestWith } from 'rxjs/operators'; import type * as H from 'history'; import type { @@ -84,6 +84,7 @@ export class Plugin implements IPlugin; constructor(private readonly initializerContext: PluginInitializerContext) { this.config = this.initializerContext.config.get(); @@ -91,6 +92,7 @@ export class Plugin implements IPlugin(true); } private appUpdater$ = new Subject(); @@ -159,6 +161,7 @@ export class Plugin implements IPlugin SecuritySolutionTemplateWrapper, }, + isSidebarEnabled$: this.isSidebarEnabled$, }; return services; }; @@ -296,7 +299,12 @@ export class Plugin implements IPlugin { + this.isSidebarEnabled$.next(enabled); + }, + }; } public stop() { diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index 65b43d3d4635b..76349ec3c8db5 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -43,6 +43,7 @@ import type { ThreatIntelligencePluginStart } from '@kbn/threat-intelligence-plu import type { CloudExperimentsPluginStart } from '@kbn/cloud-experiments-plugin/common'; import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import type { DataViewsServicePublic } from '@kbn/data-views-plugin/public'; +import type { BehaviorSubject } from 'rxjs'; import type { ResolverPluginSetup } from './resolver/types'; import type { Inspect } from '../common/search_strategy'; import type { Detections } from './detections'; @@ -116,13 +117,17 @@ export type StartServices = CoreStart & securityLayout: { getPluginWrapper: () => typeof SecuritySolutionTemplateWrapper; }; + isSidebarEnabled$: BehaviorSubject; }; export interface PluginSetup { resolver: () => Promise; } -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface PluginStart {} + +export interface PluginStart { + isSidebarEnabled$: BehaviorSubject; + setIsSidebarEnabled: (enabled: boolean) => void; +} export interface AppObservableLibs { kibana: CoreStart; From 64b62883a35eda40c09a97062c2ade6c35710ca3 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Sat, 25 Feb 2023 23:16:11 -0500 Subject: [PATCH 5/9] Create Serverless security plugin; hide internal nav via API --- .github/CODEOWNERS | 1 + config/serverless.security.yml | 10 +++++ docs/developer/plugin-list.asciidoc | 4 ++ package.json | 1 + packages/kbn-optimizer/limits.yml | 1 + tsconfig.base.json | 2 + .../security_solution/public/plugin.tsx | 10 ++--- .../plugins/security_solution/public/types.ts | 7 ++-- x-pack/plugins/serverless_security/.gitignore | 2 + .../plugins/serverless_security/.i18nrc.json | 9 ++++ x-pack/plugins/serverless_security/README.md | 3 ++ .../serverless_security/common/index.ts | 9 ++++ .../plugins/serverless_security/kibana.jsonc | 22 ++++++++++ .../plugins/serverless_security/package.json | 11 +++++ .../serverless_security/public/index.ts | 16 ++++++++ .../serverless_security/public/plugin.ts | 41 +++++++++++++++++++ .../serverless_security/public/types.ts | 28 +++++++++++++ .../serverless_security/server/config.ts | 23 +++++++++++ .../serverless_security/server/index.ts | 20 +++++++++ .../serverless_security/server/plugin.ts | 37 +++++++++++++++++ .../serverless_security/server/types.ts | 27 ++++++++++++ .../plugins/serverless_security/tsconfig.json | 23 +++++++++++ yarn.lock | 4 ++ 23 files changed, 301 insertions(+), 10 deletions(-) create mode 100644 x-pack/plugins/serverless_security/.gitignore create mode 100644 x-pack/plugins/serverless_security/.i18nrc.json create mode 100755 x-pack/plugins/serverless_security/README.md create mode 100644 x-pack/plugins/serverless_security/common/index.ts create mode 100644 x-pack/plugins/serverless_security/kibana.jsonc create mode 100644 x-pack/plugins/serverless_security/package.json create mode 100644 x-pack/plugins/serverless_security/public/index.ts create mode 100644 x-pack/plugins/serverless_security/public/plugin.ts create mode 100644 x-pack/plugins/serverless_security/public/types.ts create mode 100644 x-pack/plugins/serverless_security/server/config.ts create mode 100644 x-pack/plugins/serverless_security/server/index.ts create mode 100644 x-pack/plugins/serverless_security/server/plugin.ts create mode 100644 x-pack/plugins/serverless_security/server/types.ts create mode 100644 x-pack/plugins/serverless_security/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 23a5df45f9951..e84a4aaf463ce 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -548,6 +548,7 @@ packages/kbn-securitysolution-utils @elastic/security-solution-platform packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/apm-ui x-pack/plugins/serverless_observability @elastic/appex-sharedux +x-pack/plugins/serverless_security @elastic/appex-sharedux test/plugin_functional/plugins/session_notifications @elastic/kibana-core x-pack/plugins/session_view @elastic/awp-viz packages/kbn-set-map @elastic/kibana-operations diff --git a/config/serverless.security.yml b/config/serverless.security.yml index e69de29bb2d1d..a5e1c170ddccd 100644 --- a/config/serverless.security.yml +++ b/config/serverless.security.yml @@ -0,0 +1,10 @@ +xpack.apm.enabled: false +xpack.canvas.enabled: false +xpack.observability.enabled: false +xpack.reporting.enabled: false +xpack.uptime.enabled: false +xpack.watcher.enabled: false + +xpack.serverless.security.enabled: true + +uiSettings.overrides.defaultRoute: /app/security/get_started diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index fa1c4080fe42b..0502017da81a4 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -693,6 +693,10 @@ Kibana. |A witty, fitting description to come. +|{kib-repo}blob/{branch}/x-pack/plugins/serverless_security/README.md[serverlessSecurity] +|A witty, fitting description to come. + + |{kib-repo}blob/{branch}/x-pack/plugins/session_view/README.md[sessionView] |Session View is meant to provide a visualization into what is going on in a particular Linux environment where the agent is running. It looks likes a terminal emulator; however, it is a tool for introspecting process activity and understanding user and service behaviour in your Linux servers and infrastructure. It is a time-ordered series of process executions displayed in a tree over time. diff --git a/package.json b/package.json index 5e34275fd563e..44ce771c57a1a 100644 --- a/package.json +++ b/package.json @@ -550,6 +550,7 @@ "@kbn/server-http-tools": "link:packages/kbn-server-http-tools", "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", "@kbn/serverless-observability": "link:x-pack/plugins/serverless_observability", + "@kbn/serverless-security": "link:x-pack/plugins/serverless_security", "@kbn/session-notifications-plugin": "link:test/plugin_functional/plugins/session_notifications", "@kbn/session-view-plugin": "link:x-pack/plugins/session_view", "@kbn/set-map": "link:packages/kbn-set-map", diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index a343faa89a9a4..886ca3817fe0f 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -113,6 +113,7 @@ pageLoadAssetSize: security: 65433 securitySolution: 66738 serverlessObservability: 16582 + serverlessSecurity: 16556 sessionView: 77750 share: 71239 snapshotRestore: 79032 diff --git a/tsconfig.base.json b/tsconfig.base.json index 4e252683b2a94..db51be8727dbf 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1090,6 +1090,8 @@ "@kbn/server-route-repository/*": ["packages/kbn-server-route-repository/*"], "@kbn/serverless-observability": ["x-pack/plugins/serverless_observability"], "@kbn/serverless-observability/*": ["x-pack/plugins/serverless_observability/*"], + "@kbn/serverless-security": ["x-pack/plugins/serverless_security"], + "@kbn/serverless-security/*": ["x-pack/plugins/serverless_security/*"], "@kbn/session-notifications-plugin": ["test/plugin_functional/plugins/session_notifications"], "@kbn/session-notifications-plugin/*": ["test/plugin_functional/plugins/session_notifications/*"], "@kbn/session-view-plugin": ["x-pack/plugins/session_view"], diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index 616168b52cbba..87bd7e72223a4 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -235,6 +235,9 @@ export class Plugin implements IPlugin { + this.isSidebarEnabled$.next(enabled); + }, }; } @@ -299,12 +302,7 @@ export class Plugin implements IPlugin { - this.isSidebarEnabled$.next(enabled); - }, - }; + return {}; } public stop() { diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index 76349ec3c8db5..4cdbce5c2cf47 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -122,13 +122,12 @@ export type StartServices = CoreStart & export interface PluginSetup { resolver: () => Promise; -} - -export interface PluginStart { - isSidebarEnabled$: BehaviorSubject; setIsSidebarEnabled: (enabled: boolean) => void; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PluginStart {} + export interface AppObservableLibs { kibana: CoreStart; } diff --git a/x-pack/plugins/serverless_security/.gitignore b/x-pack/plugins/serverless_security/.gitignore new file mode 100644 index 0000000000000..c3dca1b96fcc2 --- /dev/null +++ b/x-pack/plugins/serverless_security/.gitignore @@ -0,0 +1,2 @@ +/build +/target diff --git a/x-pack/plugins/serverless_security/.i18nrc.json b/x-pack/plugins/serverless_security/.i18nrc.json new file mode 100644 index 0000000000000..e4519b9cdf9f5 --- /dev/null +++ b/x-pack/plugins/serverless_security/.i18nrc.json @@ -0,0 +1,9 @@ +{ + "prefix": "serverlessSecurity", + "paths": { + "serverlessSecurity": "." + }, + "translations": [ + "translations/ja-JP.json" + ] +} \ No newline at end of file diff --git a/x-pack/plugins/serverless_security/README.md b/x-pack/plugins/serverless_security/README.md new file mode 100755 index 0000000000000..33d229a31060d --- /dev/null +++ b/x-pack/plugins/serverless_security/README.md @@ -0,0 +1,3 @@ +# serverlessSecurity + +A witty, fitting description to come. \ No newline at end of file diff --git a/x-pack/plugins/serverless_security/common/index.ts b/x-pack/plugins/serverless_security/common/index.ts new file mode 100644 index 0000000000000..0dc5be6ddf9bb --- /dev/null +++ b/x-pack/plugins/serverless_security/common/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export const PLUGIN_ID = 'serverlessSecurity'; +export const PLUGIN_NAME = 'serverlessSecurity'; diff --git a/x-pack/plugins/serverless_security/kibana.jsonc b/x-pack/plugins/serverless_security/kibana.jsonc new file mode 100644 index 0000000000000..c94c93513209f --- /dev/null +++ b/x-pack/plugins/serverless_security/kibana.jsonc @@ -0,0 +1,22 @@ +{ + "type": "plugin", + "id": "@kbn/serverless-security", + "owner": "@elastic/appex-sharedux", + "description": "Serverless customizations for security.", + "plugin": { + "id": "serverlessSecurity", + "server": true, + "browser": true, + "configPath": [ + "xpack", + "serverless", + "security" + ], + "requiredPlugins": [ + "security", + "securitySolution" + ], + "optionalPlugins": [], + "requiredBundles": [] + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless_security/package.json b/x-pack/plugins/serverless_security/package.json new file mode 100644 index 0000000000000..0154207c22d6f --- /dev/null +++ b/x-pack/plugins/serverless_security/package.json @@ -0,0 +1,11 @@ +{ + "name": "@kbn/serverless-security", + "version": "1.0.0", + "license": "Elastic License 2.0", + "private": true, + "scripts": { + "build": "yarn plugin-helpers build", + "plugin-helpers": "node ../../../scripts/plugin_helpers", + "kbn": "node ../../../scripts/kbn" + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless_security/public/index.ts b/x-pack/plugins/serverless_security/public/index.ts new file mode 100644 index 0000000000000..ce7b6e989f4ca --- /dev/null +++ b/x-pack/plugins/serverless_security/public/index.ts @@ -0,0 +1,16 @@ +/* + * 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 { ServerlessSecurityPlugin } from './plugin'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. +export function plugin() { + return new ServerlessSecurityPlugin(); +} + +export type { ServerlessSecurityPluginSetup, ServerlessSecurityPluginStart } from './types'; diff --git a/x-pack/plugins/serverless_security/public/plugin.ts b/x-pack/plugins/serverless_security/public/plugin.ts new file mode 100644 index 0000000000000..4af166c8cf804 --- /dev/null +++ b/x-pack/plugins/serverless_security/public/plugin.ts @@ -0,0 +1,41 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { + ServerlessSecurityPluginSetup, + ServerlessSecurityPluginStart, + ServerlessSecurityPluginSetupDependencies, + ServerlessSecurityPluginStartDependencies, +} from './types'; + +export class ServerlessSecurityPlugin + implements + Plugin< + ServerlessSecurityPluginSetup, + ServerlessSecurityPluginStart, + ServerlessSecurityPluginSetupDependencies, + ServerlessSecurityPluginStartDependencies + > +{ + public setup( + _core: CoreSetup, + setupDeps: ServerlessSecurityPluginSetupDependencies + ): ServerlessSecurityPluginSetup { + setupDeps.securitySolution.setIsSidebarEnabled(false); + return {}; + } + + public start( + _core: CoreStart, + _startDeps: ServerlessSecurityPluginStartDependencies + ): ServerlessSecurityPluginStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_security/public/types.ts b/x-pack/plugins/serverless_security/public/types.ts new file mode 100644 index 0000000000000..58ac0b112abcf --- /dev/null +++ b/x-pack/plugins/serverless_security/public/types.ts @@ -0,0 +1,28 @@ +/* + * 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 { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public'; +import { + PluginSetup as SecuritySolutionPluginSetup, + PluginStart as SecuritySolutionPluginStart, +} from '@kbn/security-solution-plugin/public'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessSecurityPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessSecurityPluginStart {} + +export interface ServerlessSecurityPluginSetupDependencies { + security: SecurityPluginSetup; + securitySolution: SecuritySolutionPluginSetup; +} + +export interface ServerlessSecurityPluginStartDependencies { + security: SecurityPluginStart; + securitySolution: SecuritySolutionPluginStart; +} diff --git a/x-pack/plugins/serverless_security/server/config.ts b/x-pack/plugins/serverless_security/server/config.ts new file mode 100644 index 0000000000000..758b22de1514e --- /dev/null +++ b/x-pack/plugins/serverless_security/server/config.ts @@ -0,0 +1,23 @@ +/* + * 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 { schema, TypeOf } from '@kbn/config-schema'; +import { PluginConfigDescriptor } from '@kbn/core/server'; + +export * from './types'; + +const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +type ConfigType = TypeOf; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export type ServerlessSecurityConfig = TypeOf; diff --git a/x-pack/plugins/serverless_security/server/index.ts b/x-pack/plugins/serverless_security/server/index.ts new file mode 100644 index 0000000000000..b2b6c8564f788 --- /dev/null +++ b/x-pack/plugins/serverless_security/server/index.ts @@ -0,0 +1,20 @@ +/* + * 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 { PluginInitializerContext } from '@kbn/core/server'; + +import { ServerlessSecurityPlugin } from './plugin'; +export { config } from './config'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. + +export function plugin(initializerContext: PluginInitializerContext) { + return new ServerlessSecurityPlugin(initializerContext); +} + +export type { ServerlessSecurityPluginSetup, ServerlessSecurityPluginStart } from './types'; diff --git a/x-pack/plugins/serverless_security/server/plugin.ts b/x-pack/plugins/serverless_security/server/plugin.ts new file mode 100644 index 0000000000000..7dfbae3b64a67 --- /dev/null +++ b/x-pack/plugins/serverless_security/server/plugin.ts @@ -0,0 +1,37 @@ +/* + * 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 { PluginInitializerContext, Plugin } from '@kbn/core/server'; + +import { + ServerlessSecurityPluginSetup, + ServerlessSecurityPluginStart, + ServerlessSecurityPluginSetupDependencies, + ServerlessSecurityPluginStartDependencies, +} from './types'; + +export class ServerlessSecurityPlugin + implements + Plugin< + ServerlessSecurityPluginSetup, + ServerlessSecurityPluginStart, + ServerlessSecurityPluginSetupDependencies, + ServerlessSecurityPluginStartDependencies + > +{ + constructor(_initializerContext: PluginInitializerContext) {} + + public setup() { + return {}; + } + + public start() { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_security/server/types.ts b/x-pack/plugins/serverless_security/server/types.ts new file mode 100644 index 0000000000000..be7167d030315 --- /dev/null +++ b/x-pack/plugins/serverless_security/server/types.ts @@ -0,0 +1,27 @@ +/* + * 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 { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/server'; +import { + PluginSetup as SecuritySolutionPluginSetup, + PluginStart as SecuritySolutionPluginStart, +} from '@kbn/security-solution-plugin/server'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessSecurityPluginSetup {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessSecurityPluginStart {} + +export interface ServerlessSecurityPluginSetupDependencies { + security: SecurityPluginSetup; + securitySolution: SecuritySolutionPluginSetup; +} + +export interface ServerlessSecurityPluginStartDependencies { + security: SecurityPluginStart; + securitySolution: SecuritySolutionPluginStart; +} diff --git a/x-pack/plugins/serverless_security/tsconfig.json b/x-pack/plugins/serverless_security/tsconfig.json new file mode 100644 index 0000000000000..7937d55df3797 --- /dev/null +++ b/x-pack/plugins/serverless_security/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../../typings/**/*" + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/security-plugin", + "@kbn/security-solution-plugin", + "@kbn/config-schema", + ] +} diff --git a/yarn.lock b/yarn.lock index 1c0e10bfe2fd3..181e56313e85a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4917,6 +4917,10 @@ version "0.0.0" uid "" +"@kbn/serverless-security@link:x-pack/plugins/serverless_security": + version "0.0.0" + uid "" + "@kbn/session-notifications-plugin@link:test/plugin_functional/plugins/session_notifications": version "0.0.0" uid "" From 5d3a6af4b6fb75c3aab61cf0f409262eb7a79221 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Sun, 26 Feb 2023 00:17:54 -0500 Subject: [PATCH 6/9] Create 'solution' chrome style, add API to place solution navigation --- .../src/chrome_service.tsx | 114 +++++++++++++----- .../src/ui/index.ts | 1 + .../src/ui/solution/header.tsx | 111 +++++++++++++++++ .../src/ui/solution/index.ts | 9 ++ .../tsconfig.json | 3 +- .../src/chrome_service.mock.ts | 3 + .../core/chrome/core-chrome-browser/index.ts | 27 +++-- .../core-chrome-browser/src/contracts.ts | 6 +- .../chrome/core-chrome-browser/src/index.ts | 2 +- .../chrome/core-chrome-browser/src/types.ts | 3 + src/core/public/_variables.scss | 2 +- src/core/public/styles/rendering/_base.scss | 3 + 12 files changed, 236 insertions(+), 48 deletions(-) create mode 100644 packages/core/chrome/core-chrome-browser-internal/src/ui/solution/header.tsx create mode 100644 packages/core/chrome/core-chrome-browser-internal/src/ui/solution/index.ts diff --git a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx index 4e0762aee8620..07f27067f3883 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx @@ -26,6 +26,7 @@ import type { ChromeGlobalHelpExtensionMenuLink, ChromeHelpExtension, ChromeUserBanner, + ChromeStyle, } from '@kbn/core-chrome-browser'; import type { CustomBrandingStart } from '@kbn/core-custom-branding-browser'; import { KIBANA_ASK_ELASTIC_LINK } from './constants'; @@ -33,7 +34,7 @@ import { DocTitleService } from './doc_title'; import { NavControlsService } from './nav_controls'; import { NavLinksService } from './nav_links'; import { RecentlyAccessedService } from './recently_accessed'; -import { Header } from './ui'; +import { Header, SolutionHeader } from './ui'; import type { InternalChromeStart } from './types'; const IS_LOCKED_KEY = 'core.chrome.isLocked'; @@ -119,6 +120,8 @@ export class ChromeService { const customNavLink$ = new BehaviorSubject(undefined); const helpSupportUrl$ = new BehaviorSubject(KIBANA_ASK_ELASTIC_LINK); const isNavDrawerLocked$ = new BehaviorSubject(localStorage.getItem(IS_LOCKED_KEY) === 'true'); + const chromeStyle$ = new BehaviorSubject('classic'); + const solutionNavigation$ = new BehaviorSubject(undefined); const getKbnVersionClass = () => { // we assume that the version is valid and has the form 'X.X.X' @@ -135,6 +138,9 @@ export class ChromeService { map(([headerBanner, isVisible]) => { return [ 'kbnBody', + chromeStyle$.getValue() === 'classic' + ? 'kbnBody--classicLayout' + : 'kbnBody--projectLayout', headerBanner ? 'kbnBody--hasHeaderBanner' : 'kbnBody--noHeaderBanner', isVisible ? 'kbnBody--chromeVisible' : 'kbnBody--chromeHidden', getKbnVersionClass(), @@ -163,6 +169,16 @@ export class ChromeService { const getIsNavDrawerLocked$ = isNavDrawerLocked$.pipe(takeUntil(this.stop$)); + const setChromeStyle = (style: ChromeStyle) => { + chromeStyle$.next(style); + }; + + const setSolutionNavigation = (navigation: JSX.Element) => { + solutionNavigation$.next(navigation); + }; + + const getChromeStyle$ = chromeStyle$.pipe(takeUntil(this.stop$)); + const isIE = () => { const ua = window.navigator.userAgent; const msie = ua.indexOf('MSIE '); // IE 10 or older @@ -203,41 +219,74 @@ export class ChromeService { }); } + const getHeaderComponent = () => { + const Component = ({ + style$, + navigation$, + }: { + style$: typeof chromeStyle$; + navigation$: typeof solutionNavigation$; + }) => { + if (style$.getValue() === 'solution') { + const navigation = navigation$.getValue(); + if (navigation) { + return ( + + ); + } + } + + return ( +
+ ); + }; + return ; + }; + return { navControls, navLinks, recentlyAccessed, docTitle, - - getHeaderComponent: () => ( -
- ), + getHeaderComponent, getIsVisible$: () => this.isVisible$, @@ -302,6 +351,9 @@ export class ChromeService { }, getBodyClasses$: () => bodyClasses$.pipe(takeUntil(this.stop$)), + setChromeStyle, + getChromeStyle$: () => getChromeStyle$, + setSolutionNavigation, }; } diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/index.ts b/packages/core/chrome/core-chrome-browser-internal/src/ui/index.ts index 5afd3e0f587bb..0fd5240eac29d 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/ui/index.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/index.ts @@ -7,5 +7,6 @@ */ export { Header } from './header'; +export { SolutionHeader } from './solution'; export { LoadingIndicator } from './loading_indicator'; export type { NavType } from './header'; diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/header.tsx b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/header.tsx new file mode 100644 index 0000000000000..0aef9755994d8 --- /dev/null +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/header.tsx @@ -0,0 +1,111 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { + EuiButtonIcon, + EuiCollapsibleNav, + EuiHeader, + EuiHeaderLogo, + EuiHeaderSection, + EuiHeaderSectionItem, + EuiThemeProvider, + useEuiTheme, +} from '@elastic/eui'; +import { + ChromeBreadcrumb, + ChromeGlobalHelpExtensionMenuLink, + ChromeHelpExtension, +} from '@kbn/core-chrome-browser/src'; +import { Observable } from 'rxjs'; +import { MountPoint } from '@kbn/core-mount-utils-browser'; +import { InternalApplicationStart } from '@kbn/core-application-browser-internal'; +import { HeaderBreadcrumbs } from '../header/header_breadcrumbs'; +import { HeaderActionMenu } from '../header/header_action_menu'; +import { HeaderHelpMenu } from '../header/header_help_menu'; + +interface Props { + breadcrumbs$: Observable; + actionMenu$: Observable; + kibanaDocLink: string; + globalHelpExtensionMenuLinks$: Observable; + helpExtension$: Observable; + helpSupportUrl$: Observable; + kibanaVersion: string; + application: InternalApplicationStart; + navigation: JSX.Element; +} + +export const SolutionHeader = ({ + application, + kibanaDocLink, + kibanaVersion, + navigation, + ...observables +}: Props) => { + const { euiTheme, colorMode } = useEuiTheme(); + + const renderLogo = () => ( + e.preventDefault()} + aria-label="Go to home page" + /> + ); + + return ( + <> + + + {renderLogo()} + + + + + + + + + + + + + + + {}} + closeButtonProps={{ iconType: 'menuLeft' }} + showButtonIfDocked={true} + isDocked={true} + size={248} + hideCloseButton={false} + button={ + + + + } + > + {navigation} + + + + ); +}; diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/index.ts b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/index.ts new file mode 100644 index 0000000000000..5c116bc6b30c8 --- /dev/null +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution/index.ts @@ -0,0 +1,9 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { SolutionHeader } from './header'; diff --git a/packages/core/chrome/core-chrome-browser-internal/tsconfig.json b/packages/core/chrome/core-chrome-browser-internal/tsconfig.json index 4d4d6cad3bc21..019f15681b6c1 100644 --- a/packages/core/chrome/core-chrome-browser-internal/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser-internal/tsconfig.json @@ -5,7 +5,8 @@ "types": [ "jest", "node", - "react" + "react", + "@emotion/react/types/css-prop" ] }, "include": [ diff --git a/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts b/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts index 2f5c4deb1f38d..e33eca66322f8 100644 --- a/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts +++ b/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts @@ -61,6 +61,9 @@ const createStartContractMock = () => { setHeaderBanner: jest.fn(), hasHeaderBanner$: jest.fn(), getBodyClasses$: jest.fn(), + getChromeStyle$: jest.fn(), + setChromeStyle: jest.fn(), + setSolutionNavigation: jest.fn(), }; startContract.navLinks.getAll.mockReturnValue([]); startContract.getIsVisible$.mockReturnValue(new BehaviorSubject(false)); diff --git a/packages/core/chrome/core-chrome-browser/index.ts b/packages/core/chrome/core-chrome-browser/index.ts index 3fbef34126a4a..1d2dca4c957bc 100644 --- a/packages/core/chrome/core-chrome-browser/index.ts +++ b/packages/core/chrome/core-chrome-browser/index.ts @@ -7,25 +7,26 @@ */ export type { - ChromeUserBanner, + ChromeBadge, ChromeBreadcrumb, + ChromeBreadcrumbsAppendExtension, + ChromeDocTitle, + ChromeGlobalHelpExtensionMenuLink, ChromeHelpExtension, - ChromeHelpExtensionMenuLink, ChromeHelpExtensionLinkBase, + ChromeHelpExtensionMenuCustomLink, + ChromeHelpExtensionMenuDiscussLink, + ChromeHelpExtensionMenuDocumentationLink, + ChromeHelpExtensionMenuGitHubLink, + ChromeHelpExtensionMenuLink, ChromeHelpMenuActions, - ChromeNavLink, - ChromeBreadcrumbsAppendExtension, - ChromeNavLinks, ChromeNavControl, ChromeNavControls, - ChromeBadge, - ChromeHelpExtensionMenuGitHubLink, - ChromeHelpExtensionMenuDocumentationLink, - ChromeHelpExtensionMenuDiscussLink, - ChromeHelpExtensionMenuCustomLink, - ChromeGlobalHelpExtensionMenuLink, - ChromeDocTitle, - ChromeStart, + ChromeNavLink, + ChromeNavLinks, ChromeRecentlyAccessed, ChromeRecentlyAccessedHistoryItem, + ChromeStart, + ChromeStyle, + ChromeUserBanner, } from './src'; diff --git a/packages/core/chrome/core-chrome-browser/src/contracts.ts b/packages/core/chrome/core-chrome-browser/src/contracts.ts index a81d9c3c6338f..2a966e367d6e4 100644 --- a/packages/core/chrome/core-chrome-browser/src/contracts.ts +++ b/packages/core/chrome/core-chrome-browser/src/contracts.ts @@ -13,7 +13,7 @@ import type { ChromeDocTitle } from './doc_title'; import type { ChromeNavControls } from './nav_controls'; import type { ChromeHelpExtension } from './help_extension'; import type { ChromeBreadcrumb, ChromeBreadcrumbsAppendExtension } from './breadcrumb'; -import type { ChromeBadge, ChromeUserBanner } from './types'; +import type { ChromeBadge, ChromeStyle, ChromeUserBanner } from './types'; import { ChromeGlobalHelpExtensionMenuLink } from './help_extension'; /** @@ -150,4 +150,8 @@ export interface ChromeStart { * Get an observable of the current header banner presence state. */ hasHeaderBanner$(): Observable; + + setChromeStyle(style: ChromeStyle): void; + getChromeStyle$(): Observable; + setSolutionNavigation(solutionNavigation: JSX.Element): void; } diff --git a/packages/core/chrome/core-chrome-browser/src/index.ts b/packages/core/chrome/core-chrome-browser/src/index.ts index 716af097fded7..89ba12d616d0e 100644 --- a/packages/core/chrome/core-chrome-browser/src/index.ts +++ b/packages/core/chrome/core-chrome-browser/src/index.ts @@ -26,4 +26,4 @@ export type { ChromeRecentlyAccessed, ChromeRecentlyAccessedHistoryItem, } from './recently_accessed'; -export type { ChromeBadge, ChromeUserBanner } from './types'; +export type { ChromeBadge, ChromeUserBanner, ChromeStyle } from './types'; diff --git a/packages/core/chrome/core-chrome-browser/src/types.ts b/packages/core/chrome/core-chrome-browser/src/types.ts index 81b8c32a1a04c..40f29a073137d 100644 --- a/packages/core/chrome/core-chrome-browser/src/types.ts +++ b/packages/core/chrome/core-chrome-browser/src/types.ts @@ -20,3 +20,6 @@ export interface ChromeBadge { export interface ChromeUserBanner { content: MountPoint; } + +/** @public */ +export type ChromeStyle = 'classic' | 'solution'; diff --git a/src/core/public/_variables.scss b/src/core/public/_variables.scss index 6c21c9760be97..4b89cc0bdf1ad 100644 --- a/src/core/public/_variables.scss +++ b/src/core/public/_variables.scss @@ -1,7 +1,7 @@ @import '@elastic/eui/src/global_styling/variables/header'; // height of the header banner -$kbnHeaderBannerHeight: $euiSizeXL; // This value is also declared in `/x-pack/plugins/canvas/common/lib/constants.ts` +$kbnHeaderBannerHeight: $euiSizeXL; // This value is also declared in `/x-pack/plugins/canvas/common/lib/constants.ts` // total height of the header (when the banner is *not* present) $kbnHeaderOffset: $euiHeaderHeightCompensation * 2; // total height of the header when the banner is present diff --git a/src/core/public/styles/rendering/_base.scss b/src/core/public/styles/rendering/_base.scss index 9d4296ca3b4ef..a9ece9955e6ca 100644 --- a/src/core/public/styles/rendering/_base.scss +++ b/src/core/public/styles/rendering/_base.scss @@ -75,6 +75,9 @@ &.kbnBody--chromeHidden { @include kbnAffordForHeader(0); } + &.kbnBody--projectLayout { + @include kbnAffordForHeader($euiHeaderHeightCompensation); + } &.kbnBody--chromeHidden.kbnBody--hasHeaderBanner { @include kbnAffordForHeader($kbnHeaderBannerHeight); } From b51482aa5b3a0008e4414b2ac5215f8950c906e1 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Sun, 26 Feb 2023 00:56:06 -0500 Subject: [PATCH 7/9] Create Serverless plugin; alias core navigation to local API --- .github/CODEOWNERS | 1 + docs/developer/plugin-list.asciidoc | 4 +++ package.json | 1 + packages/kbn-optimizer/limits.yml | 1 + tsconfig.base.json | 2 ++ x-pack/plugins/serverless/.i18nrc.json | 7 ++++++ x-pack/plugins/serverless/README.md | 19 ++++++++++++++ x-pack/plugins/serverless/common/index.ts | 9 +++++++ x-pack/plugins/serverless/kibana.jsonc | 19 ++++++++++++++ x-pack/plugins/serverless/package.json | 11 ++++++++ x-pack/plugins/serverless/public/index.ts | 16 ++++++++++++ x-pack/plugins/serverless/public/plugin.ts | 25 +++++++++++++++++++ x-pack/plugins/serverless/public/types.ts | 13 ++++++++++ x-pack/plugins/serverless/server/config.ts | 23 +++++++++++++++++ x-pack/plugins/serverless/server/index.ts | 19 ++++++++++++++ x-pack/plugins/serverless/server/plugin.ts | 24 ++++++++++++++++++ x-pack/plugins/serverless/server/types.ts | 12 +++++++++ x-pack/plugins/serverless/tsconfig.json | 20 +++++++++++++++ .../plugins/serverless_security/tsconfig.json | 3 +-- yarn.lock | 4 +++ 20 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/serverless/.i18nrc.json create mode 100755 x-pack/plugins/serverless/README.md create mode 100644 x-pack/plugins/serverless/common/index.ts create mode 100644 x-pack/plugins/serverless/kibana.jsonc create mode 100644 x-pack/plugins/serverless/package.json create mode 100644 x-pack/plugins/serverless/public/index.ts create mode 100644 x-pack/plugins/serverless/public/plugin.ts create mode 100644 x-pack/plugins/serverless/public/types.ts create mode 100644 x-pack/plugins/serverless/server/config.ts create mode 100644 x-pack/plugins/serverless/server/index.ts create mode 100644 x-pack/plugins/serverless/server/plugin.ts create mode 100644 x-pack/plugins/serverless/server/types.ts create mode 100644 x-pack/plugins/serverless/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e84a4aaf463ce..c9f7999ce5327 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -547,6 +547,7 @@ packages/kbn-securitysolution-t-grid @elastic/security-solution-platform packages/kbn-securitysolution-utils @elastic/security-solution-platform packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/apm-ui +x-pack/plugins/serverless @elastic/appex-sharedux x-pack/plugins/serverless_observability @elastic/appex-sharedux x-pack/plugins/serverless_security @elastic/appex-sharedux test/plugin_functional/plugins/session_notifications @elastic/kibana-core diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 0502017da81a4..146300eb04bef 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -689,6 +689,10 @@ Kibana. |Welcome to the Kibana Security Solution plugin! This README will go over getting started with development and testing. +|{kib-repo}blob/{branch}/x-pack/plugins/serverless/README.md[serverless] +|A Kibana plugin + + |{kib-repo}blob/{branch}/x-pack/plugins/serverless_observability/README.md[serverlessObservability] |A witty, fitting description to come. diff --git a/package.json b/package.json index 44ce771c57a1a..5462bb7056554 100644 --- a/package.json +++ b/package.json @@ -549,6 +549,7 @@ "@kbn/securitysolution-utils": "link:packages/kbn-securitysolution-utils", "@kbn/server-http-tools": "link:packages/kbn-server-http-tools", "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", + "@kbn/serverless": "link:x-pack/plugins/serverless", "@kbn/serverless-observability": "link:x-pack/plugins/serverless_observability", "@kbn/serverless-security": "link:x-pack/plugins/serverless_security", "@kbn/session-notifications-plugin": "link:test/plugin_functional/plugins/session_notifications", diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 886ca3817fe0f..d979ab1ce679f 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -112,6 +112,7 @@ pageLoadAssetSize: searchprofiler: 67080 security: 65433 securitySolution: 66738 + serverless: 16573 serverlessObservability: 16582 serverlessSecurity: 16556 sessionView: 77750 diff --git a/tsconfig.base.json b/tsconfig.base.json index db51be8727dbf..21db47056353d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1088,6 +1088,8 @@ "@kbn/server-http-tools/*": ["packages/kbn-server-http-tools/*"], "@kbn/server-route-repository": ["packages/kbn-server-route-repository"], "@kbn/server-route-repository/*": ["packages/kbn-server-route-repository/*"], + "@kbn/serverless": ["x-pack/plugins/serverless"], + "@kbn/serverless/*": ["x-pack/plugins/serverless/*"], "@kbn/serverless-observability": ["x-pack/plugins/serverless_observability"], "@kbn/serverless-observability/*": ["x-pack/plugins/serverless_observability/*"], "@kbn/serverless-security": ["x-pack/plugins/serverless_security"], diff --git a/x-pack/plugins/serverless/.i18nrc.json b/x-pack/plugins/serverless/.i18nrc.json new file mode 100644 index 0000000000000..4e5106eb2cfca --- /dev/null +++ b/x-pack/plugins/serverless/.i18nrc.json @@ -0,0 +1,7 @@ +{ + "prefix": "serverless", + "paths": { + "serverless": "." + }, + "translations": ["translations/ja-JP.json"] +} diff --git a/x-pack/plugins/serverless/README.md b/x-pack/plugins/serverless/README.md new file mode 100755 index 0000000000000..4d279ec348054 --- /dev/null +++ b/x-pack/plugins/serverless/README.md @@ -0,0 +1,19 @@ +# serverless + +A Kibana plugin + +--- + +## Development + +See the [kibana contributing guide](https://github.com/elastic/kibana/blob/main/CONTRIBUTING.md) for instructions setting up your development environment. + +## Scripts + +
+
yarn kbn bootstrap
+
Execute this to install node_modules and setup the dependencies in your plugin and in Kibana
+ +
yarn plugin-helpers build
+
Execute this to create a distributable version of this plugin that can be installed in Kibana
+
diff --git a/x-pack/plugins/serverless/common/index.ts b/x-pack/plugins/serverless/common/index.ts new file mode 100644 index 0000000000000..f28f6aa0c3623 --- /dev/null +++ b/x-pack/plugins/serverless/common/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export const PLUGIN_ID = 'serverless'; +export const PLUGIN_NAME = 'serverless'; diff --git a/x-pack/plugins/serverless/kibana.jsonc b/x-pack/plugins/serverless/kibana.jsonc new file mode 100644 index 0000000000000..a952c98a0aba6 --- /dev/null +++ b/x-pack/plugins/serverless/kibana.jsonc @@ -0,0 +1,19 @@ +{ + "type": "plugin", + "id": "@kbn/serverless", + "owner": "@elastic/appex-sharedux", + "description": "The core Serverless plugin, providing APIs to Serverless Project plugins.", + "plugin": { + "id": "serverless", + "server": true, + "browser": true, + "configPath": [ + "xpack", + "serverless", + "plugin", + ], + "requiredPlugins": [], + "optionalPlugins": [], + "requiredBundles": [] + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless/package.json b/x-pack/plugins/serverless/package.json new file mode 100644 index 0000000000000..ec457f89fbcaa --- /dev/null +++ b/x-pack/plugins/serverless/package.json @@ -0,0 +1,11 @@ +{ + "name": "@kbn/serverless", + "version": "1.0.0", + "license": "Elastic License 2.0", + "private": true, + "scripts": { + "build": "yarn plugin-helpers build", + "plugin-helpers": "node ../../scripts/plugin_helpers", + "kbn": "node ../../scripts/kbn" + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless/public/index.ts b/x-pack/plugins/serverless/public/index.ts new file mode 100644 index 0000000000000..4e5b416edd87c --- /dev/null +++ b/x-pack/plugins/serverless/public/index.ts @@ -0,0 +1,16 @@ +/* + * 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 { ServerlessPlugin } from './plugin'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. +export function plugin() { + return new ServerlessPlugin(); +} + +export type { ServerlessPluginSetup, ServerlessPluginStart } from './types'; diff --git a/x-pack/plugins/serverless/public/plugin.ts b/x-pack/plugins/serverless/public/plugin.ts new file mode 100644 index 0000000000000..0c9816bd026ae --- /dev/null +++ b/x-pack/plugins/serverless/public/plugin.ts @@ -0,0 +1,25 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { ServerlessPluginSetup, ServerlessPluginStart } from './types'; + +export class ServerlessPlugin implements Plugin { + public setup(_core: CoreSetup): ServerlessPluginSetup { + return {}; + } + + public start(core: CoreStart): ServerlessPluginStart { + core.chrome.setChromeStyle('solution'); + return { + setServerlessNavigation: (navigation: JSX.Element) => + core.chrome.setSolutionNavigation(navigation), + }; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless/public/types.ts b/x-pack/plugins/serverless/public/types.ts new file mode 100644 index 0000000000000..4af0b062ede0c --- /dev/null +++ b/x-pack/plugins/serverless/public/types.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessPluginSetup {} + +export interface ServerlessPluginStart { + setServerlessNavigation: (navigation: JSX.Element) => void; +} diff --git a/x-pack/plugins/serverless/server/config.ts b/x-pack/plugins/serverless/server/config.ts new file mode 100644 index 0000000000000..dce4deda86049 --- /dev/null +++ b/x-pack/plugins/serverless/server/config.ts @@ -0,0 +1,23 @@ +/* + * 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 { schema, TypeOf } from '@kbn/config-schema'; +import { PluginConfigDescriptor } from '@kbn/core/server'; + +export * from './types'; + +const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +type ConfigType = TypeOf; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export type ServerlessConfig = TypeOf; diff --git a/x-pack/plugins/serverless/server/index.ts b/x-pack/plugins/serverless/server/index.ts new file mode 100644 index 0000000000000..ae805970e038e --- /dev/null +++ b/x-pack/plugins/serverless/server/index.ts @@ -0,0 +1,19 @@ +/* + * 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 { PluginInitializerContext } from '@kbn/core/server'; +import { ServerlessPlugin } from './plugin'; +export { config } from './config'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. + +export function plugin(initializerContext: PluginInitializerContext) { + return new ServerlessPlugin(initializerContext); +} + +export type { ServerlessPluginSetup, ServerlessPluginStart } from './types'; diff --git a/x-pack/plugins/serverless/server/plugin.ts b/x-pack/plugins/serverless/server/plugin.ts new file mode 100644 index 0000000000000..54bfb5c14dc4b --- /dev/null +++ b/x-pack/plugins/serverless/server/plugin.ts @@ -0,0 +1,24 @@ +/* + * 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 { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '@kbn/core/server'; + +import { ServerlessPluginSetup, ServerlessPluginStart } from './types'; + +export class ServerlessPlugin implements Plugin { + constructor(_initializerContext: PluginInitializerContext) {} + + public setup(_core: CoreSetup) { + return {}; + } + + public start(_core: CoreStart) { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless/server/types.ts b/x-pack/plugins/serverless/server/types.ts new file mode 100644 index 0000000000000..92a804b34a948 --- /dev/null +++ b/x-pack/plugins/serverless/server/types.ts @@ -0,0 +1,12 @@ +/* + * 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. + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessPluginStart {} diff --git a/x-pack/plugins/serverless/tsconfig.json b/x-pack/plugins/serverless/tsconfig.json new file mode 100644 index 0000000000000..ffdc7af796587 --- /dev/null +++ b/x-pack/plugins/serverless/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/config-schema", + ] +} diff --git a/x-pack/plugins/serverless_security/tsconfig.json b/x-pack/plugins/serverless_security/tsconfig.json index 7937d55df3797..86d85593b598f 100644 --- a/x-pack/plugins/serverless_security/tsconfig.json +++ b/x-pack/plugins/serverless_security/tsconfig.json @@ -7,7 +7,6 @@ "index.ts", "common/**/*.ts", "public/**/*.ts", - "public/**/*.tsx", "server/**/*.ts", "../../../typings/**/*" ], @@ -16,8 +15,8 @@ ], "kbn_references": [ "@kbn/core", + "@kbn/config-schema", "@kbn/security-plugin", "@kbn/security-solution-plugin", - "@kbn/config-schema", ] } diff --git a/yarn.lock b/yarn.lock index 181e56313e85a..31bcb2534defa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4921,6 +4921,10 @@ version "0.0.0" uid "" +"@kbn/serverless@link:x-pack/plugins/serverless": + version "0.0.0" + uid "" + "@kbn/session-notifications-plugin@link:test/plugin_functional/plugins/session_notifications": version "0.0.0" uid "" From 7a40d99c58d8963b27a876d17dd668ba39b338d8 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Sun, 26 Feb 2023 00:56:54 -0500 Subject: [PATCH 8/9] Add Serverless as dependency to existing plugins; wire up navigation replacement --- config/serverless.yml | 2 ++ .../plugins/serverless_observability/kibana.jsonc | 1 + .../public/{plugin.ts => plugin.tsx} | 12 +++++++++--- .../serverless_observability/public/types.ts | 15 +++++++++++---- .../serverless_observability/tsconfig.json | 1 + x-pack/plugins/serverless_security/kibana.jsonc | 1 + .../public/{plugin.ts => plugin.tsx} | 4 +++- .../plugins/serverless_security/public/types.ts | 3 +++ x-pack/plugins/serverless_security/tsconfig.json | 2 ++ 9 files changed, 33 insertions(+), 8 deletions(-) rename x-pack/plugins/serverless_observability/public/{plugin.ts => plugin.tsx} (66%) rename x-pack/plugins/serverless_security/public/{plugin.ts => plugin.tsx} (85%) diff --git a/config/serverless.yml b/config/serverless.yml index e69de29bb2d1d..a4dfeaea49267 100644 --- a/config/serverless.yml +++ b/config/serverless.yml @@ -0,0 +1,2 @@ + +xpack.serverless.plugin.enabled: true diff --git a/x-pack/plugins/serverless_observability/kibana.jsonc b/x-pack/plugins/serverless_observability/kibana.jsonc index 0f0e911e6807f..abce6cd9e8350 100644 --- a/x-pack/plugins/serverless_observability/kibana.jsonc +++ b/x-pack/plugins/serverless_observability/kibana.jsonc @@ -13,6 +13,7 @@ "observability" ], "requiredPlugins": [ + "serverless", "observability" ], "optionalPlugins": [], diff --git a/x-pack/plugins/serverless_observability/public/plugin.ts b/x-pack/plugins/serverless_observability/public/plugin.tsx similarity index 66% rename from x-pack/plugins/serverless_observability/public/plugin.ts rename to x-pack/plugins/serverless_observability/public/plugin.tsx index dd1c5bfbc39c7..e6438ee8feff6 100644 --- a/x-pack/plugins/serverless_observability/public/plugin.ts +++ b/x-pack/plugins/serverless_observability/public/plugin.tsx @@ -5,11 +5,13 @@ * 2.0. */ +import React from 'react'; import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; import { ServerlessObservabilityPluginSetup, ServerlessObservabilityPluginStart, - AppPluginSetupDependencies, + ServerlessObservabilityPluginSetupDependencies, + ServerlessObservabilityPluginStartDependencies, } from './types'; export class ServerlessObservabilityPlugin @@ -17,7 +19,7 @@ export class ServerlessObservabilityPlugin { public setup( _core: CoreSetup, - setupDeps: AppPluginSetupDependencies + setupDeps: ServerlessObservabilityPluginSetupDependencies ): ServerlessObservabilityPluginSetup { setupDeps.observability.navigation.setIsSidebarEnabled(false); @@ -25,7 +27,11 @@ export class ServerlessObservabilityPlugin return {}; } - public start(_core: CoreStart): ServerlessObservabilityPluginStart { + public start( + _core: CoreStart, + { serverless }: ServerlessObservabilityPluginStartDependencies + ): ServerlessObservabilityPluginStart { + serverless.setServerlessNavigation(

Observability

); return {}; } diff --git a/x-pack/plugins/serverless_observability/public/types.ts b/x-pack/plugins/serverless_observability/public/types.ts index 73ab40e9257f7..e0fca61302ad7 100644 --- a/x-pack/plugins/serverless_observability/public/types.ts +++ b/x-pack/plugins/serverless_observability/public/types.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { ObservabilityPublicSetup } from '@kbn/observability-plugin/public'; +import { ServerlessPluginSetup, ServerlessPluginStart } from '@kbn/serverless/public'; +import { + ObservabilityPublicSetup, + ObservabilityPublicStart, +} from '@kbn/observability-plugin/public'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServerlessObservabilityPluginSetup {} @@ -13,9 +17,12 @@ export interface ServerlessObservabilityPluginSetup {} // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServerlessObservabilityPluginStart {} -export interface AppPluginSetupDependencies { +export interface ServerlessObservabilityPluginSetupDependencies { observability: ObservabilityPublicSetup; + serverless: ServerlessPluginSetup; } -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface AppPluginStartDependencies {} +export interface ServerlessObservabilityPluginStartDependencies { + observability: ObservabilityPublicStart; + serverless: ServerlessPluginStart; +} diff --git a/x-pack/plugins/serverless_observability/tsconfig.json b/x-pack/plugins/serverless_observability/tsconfig.json index 4c9f7b818b430..8c9ec19e4736a 100644 --- a/x-pack/plugins/serverless_observability/tsconfig.json +++ b/x-pack/plugins/serverless_observability/tsconfig.json @@ -18,5 +18,6 @@ "@kbn/core", "@kbn/config-schema", "@kbn/observability-plugin", + "@kbn/serverless", ] } diff --git a/x-pack/plugins/serverless_security/kibana.jsonc b/x-pack/plugins/serverless_security/kibana.jsonc index c94c93513209f..71405b0e47707 100644 --- a/x-pack/plugins/serverless_security/kibana.jsonc +++ b/x-pack/plugins/serverless_security/kibana.jsonc @@ -13,6 +13,7 @@ "security" ], "requiredPlugins": [ + "serverless", "security", "securitySolution" ], diff --git a/x-pack/plugins/serverless_security/public/plugin.ts b/x-pack/plugins/serverless_security/public/plugin.tsx similarity index 85% rename from x-pack/plugins/serverless_security/public/plugin.ts rename to x-pack/plugins/serverless_security/public/plugin.tsx index 4af166c8cf804..f0f1fd2e0e9f0 100644 --- a/x-pack/plugins/serverless_security/public/plugin.ts +++ b/x-pack/plugins/serverless_security/public/plugin.tsx @@ -5,6 +5,7 @@ * 2.0. */ +import React from 'react'; import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; import { ServerlessSecurityPluginSetup, @@ -32,8 +33,9 @@ export class ServerlessSecurityPlugin public start( _core: CoreStart, - _startDeps: ServerlessSecurityPluginStartDependencies + startDeps: ServerlessSecurityPluginStartDependencies ): ServerlessSecurityPluginStart { + startDeps.serverless.setServerlessNavigation(

Security

); return {}; } diff --git a/x-pack/plugins/serverless_security/public/types.ts b/x-pack/plugins/serverless_security/public/types.ts index 58ac0b112abcf..1fc18893ce1fd 100644 --- a/x-pack/plugins/serverless_security/public/types.ts +++ b/x-pack/plugins/serverless_security/public/types.ts @@ -10,6 +10,7 @@ import { PluginSetup as SecuritySolutionPluginSetup, PluginStart as SecuritySolutionPluginStart, } from '@kbn/security-solution-plugin/public'; +import { ServerlessPluginSetup, ServerlessPluginStart } from '@kbn/serverless/public'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServerlessSecurityPluginSetup {} @@ -20,9 +21,11 @@ export interface ServerlessSecurityPluginStart {} export interface ServerlessSecurityPluginSetupDependencies { security: SecurityPluginSetup; securitySolution: SecuritySolutionPluginSetup; + serverless: ServerlessPluginSetup; } export interface ServerlessSecurityPluginStartDependencies { security: SecurityPluginStart; securitySolution: SecuritySolutionPluginStart; + serverless: ServerlessPluginStart; } diff --git a/x-pack/plugins/serverless_security/tsconfig.json b/x-pack/plugins/serverless_security/tsconfig.json index 86d85593b598f..ddf77b288e628 100644 --- a/x-pack/plugins/serverless_security/tsconfig.json +++ b/x-pack/plugins/serverless_security/tsconfig.json @@ -7,6 +7,7 @@ "index.ts", "common/**/*.ts", "public/**/*.ts", + "public/**/*.tsx", "server/**/*.ts", "../../../typings/**/*" ], @@ -18,5 +19,6 @@ "@kbn/config-schema", "@kbn/security-plugin", "@kbn/security-solution-plugin", + "@kbn/serverless", ] } From 27e1335d8b35fc1936441b645a2820a638ba1e9b Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Mon, 27 Feb 2023 00:09:17 -0500 Subject: [PATCH 9/9] Attempt to deploy using CI --- config/kibana.yml | 1 + src/cli/serve/serve.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/config/kibana.yml b/config/kibana.yml index 4233bf2882a29..63ed2cb58d668 100644 --- a/config/kibana.yml +++ b/config/kibana.yml @@ -164,3 +164,4 @@ # Maximum number of documents loaded by each shard to generate autocomplete suggestions. # This value must be a whole number greater than zero. Defaults to 100_000 #unifiedSearch.autocomplete.valueSuggestions.terminateAfter: 100000 + diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 4a875d6955428..fbbaa1e8c6235 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -194,6 +194,20 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { merge(extraCliOptions); merge(readKeystore()); + // Get around the config problem for serverless by setting the config + // values directly. This is a temporary solution until we can get + // serverless to include and use a different config. + set('xpack.apm.enabled', false); + set('xpack.canvas.enabled', false); + set('xpack.observability.enabled', false); + set('xpack.reporting.enabled', false); + set('xpack.uptime.enabled', false); + set('xpack.watcher.enabled', false); + + set('xpack.serverless.plugin.enabled', true); + set('xpack.serverless.security.enabled', true); + set('uiSettings.overrides.defaultRoute', '/app/security/get_started'); + return rawConfig; }