From d89631e7d37bad57266d73c31cb05839e25e9e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Kopyci=C5=84ski?= Date: Fri, 3 Nov 2023 12:54:21 +0000 Subject: [PATCH] Add sentinelOneConnectorOn experimental flag (#169922) ## Summary Adds experimental flag used for the development of SentinelOne connector Add this to the `kibana.yml` config ``` xpack.stack_connectors.enableExperimental: [sentinelOneConnectorOn] ``` Before: Zrzut ekranu 2023-10-26 o 12 45 22 After: Zrzut ekranu 2023-10-26 o 12 44 10 --- .../stack_connectors/common/experimental_features.ts | 10 ++++------ .../public/connector_types/bedrock/bedrock.test.tsx | 4 +++- .../connector_types/cases_webhook/webhook.test.tsx | 4 +++- .../connector_types/d3security/d3security.test.tsx | 4 +++- .../public/connector_types/email/email.test.tsx | 3 +++ .../public/connector_types/es_index/es_index.test.tsx | 4 +++- .../stack_connectors/public/connector_types/index.ts | 6 ++++++ .../public/connector_types/jira/jira.test.tsx | 4 +++- .../public/connector_types/openai/openai.test.tsx | 4 +++- .../public/connector_types/opsgenie/model.test.tsx | 4 +++- .../connector_types/pagerduty/pagerduty.test.tsx | 4 +++- .../connector_types/resilient/resilient.test.tsx | 4 +++- .../connector_types/server_log/server_log.test.tsx | 4 +++- .../servicenow_itom/servicenow_itom.test.tsx | 4 +++- .../servicenow_itsm/servicenow_itsm.test.tsx | 4 +++- .../servicenow_sir/servicenow_sir.test.tsx | 4 +++- .../public/connector_types/slack/slack.test.tsx | 4 +++- .../connector_types/slack_api/slack_api.test.tsx | 4 +++- .../public/connector_types/swimlane/swimlane.test.tsx | 4 +++- .../public/connector_types/teams/teams.test.tsx | 4 +++- .../public/connector_types/tines/tines.test.ts | 4 +++- .../public/connector_types/torq/torq.test.tsx | 4 +++- .../public/connector_types/webhook/webhook.test.tsx | 4 +++- .../public/connector_types/xmatters/xmatters.test.tsx | 4 +++- x-pack/plugins/stack_connectors/public/mocks.ts | 3 +++ x-pack/plugins/stack_connectors/public/plugin.ts | 2 +- .../server/connector_types/index.test.ts | 2 ++ .../stack_connectors/server/connector_types/index.ts | 8 ++++++++ x-pack/plugins/stack_connectors/server/plugin.ts | 10 ++++++++++ 29 files changed, 100 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/stack_connectors/common/experimental_features.ts b/x-pack/plugins/stack_connectors/common/experimental_features.ts index 61b63cff732a6..4ac02dd9f06db 100644 --- a/x-pack/plugins/stack_connectors/common/experimental_features.ts +++ b/x-pack/plugins/stack_connectors/common/experimental_features.ts @@ -13,12 +13,12 @@ export type ExperimentalFeatures = typeof allowedExperimentalValues; */ export const allowedExperimentalValues = Object.freeze({ isMustacheAutocompleteOn: false, + sentinelOneConnectorOn: false, }); type ExperimentalConfigKeys = Array; type Mutable = { -readonly [P in keyof T]: T[P] }; -const InvalidExperimentalValue = class extends Error {}; const allowedKeys = Object.keys(allowedExperimentalValues) as Readonly; /** @@ -26,17 +26,15 @@ const allowedKeys = Object.keys(allowedExperimentalValues) as Readonly { const enabledFeatures: Mutable> = {}; for (const value of configValue) { - if (!isValidExperimentalValue(value)) { - throw new InvalidExperimentalValue(`[${value}] is not valid.`); + if (isValidExperimentalValue(value)) { + // @ts-expect-error ts upgrade v4.7.4 + enabledFeatures[value as keyof ExperimentalFeatures] = true; } - // @ts-expect-error ts upgrade v4.7.4 - enabledFeatures[value as keyof ExperimentalFeatures] = true; } return { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/bedrock/bedrock.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/bedrock/bedrock.test.tsx index a37762487a822..311c731df76df 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/bedrock/bedrock.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/bedrock/bedrock.test.tsx @@ -8,14 +8,16 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { SUB_ACTION } from '../../../common/bedrock/constants'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const ACTION_TYPE_ID = '.bedrock'; let actionTypeModel: ActionTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(ACTION_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook.test.tsx index df76aef8f9001..2e53fd28248c0 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/cases_webhook/webhook.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.cases-webhook'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/d3security/d3security.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/d3security/d3security.test.tsx index 09ee10aa29254..8e384bddbcafe 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/d3security/d3security.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/d3security/d3security.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { SUB_ACTION } from '../../../common/d3security/constants'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.d3security'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/email/email.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/email/email.test.tsx index 85921dbb6deef..34b141296b315 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/email/email.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/email/email.test.tsx @@ -15,6 +15,8 @@ import { ValidateEmailAddressesOptions, MustacheInEmailRegExp, } from '@kbn/actions-plugin/common'; +import { experimentalFeaturesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.email'; let connectorTypeModel: ConnectorTypeModel; @@ -45,6 +47,7 @@ beforeEach(() => { }); beforeAll(() => { + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); const connectorTypeRegistry = new TypeRegistry(); registerConnectorTypes({ connectorTypeRegistry, services: RegistrationServices }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index.test.tsx index f85f4e540e372..2f22adf45da44 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.index'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/index.ts b/x-pack/plugins/stack_connectors/public/connector_types/index.ts index 0c024870133dc..a2297dac9d6bf 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/index.ts +++ b/x-pack/plugins/stack_connectors/public/connector_types/index.ts @@ -29,6 +29,8 @@ import { getTorqConnectorType } from './torq'; import { getWebhookConnectorType } from './webhook'; import { getXmattersConnectorType } from './xmatters'; import { getD3SecurityConnectorType } from './d3security'; +import { ExperimentalFeaturesService } from '../common/experimental_features_service'; +import { getSentinelOneConnectorType } from './sentinelone'; export interface RegistrationServices { validateEmailAddresses: ( @@ -66,4 +68,8 @@ export function registerConnectorTypes({ connectorTypeRegistry.register(getTorqConnectorType()); connectorTypeRegistry.register(getTinesConnectorType()); connectorTypeRegistry.register(getD3SecurityConnectorType()); + + if (ExperimentalFeaturesService.get().sentinelOneConnectorOn) { + connectorTypeRegistry.register(getSentinelOneConnectorType()); + } } diff --git a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira.test.tsx index 83401d691b3b3..ee01f2e21c26c 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.jira'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/openai/openai.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/openai/openai.test.tsx index 89a53c3327c28..1cb30b5a6505e 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/openai/openai.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/openai/openai.test.tsx @@ -8,14 +8,16 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { SUB_ACTION } from '../../../common/openai/constants'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const ACTION_TYPE_ID = '.gen-ai'; let actionTypeModel: ActionTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(ACTION_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/model.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/model.test.tsx index 4dc91b501c36c..5bc13a0eb3a02 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/model.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/model.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { OpsgenieConnectorTypeId, OpsgenieSubActions } from '../../../common'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(OpsgenieConnectorTypeId); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/pagerduty/pagerduty.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/pagerduty/pagerduty.test.tsx index 0464e37e78c3b..311d4bfac8679 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/pagerduty/pagerduty.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/pagerduty/pagerduty.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.pagerduty'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient.test.tsx index f4aef9e8dc020..a462ad6dc2a53 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.resilient'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/server_log/server_log.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/server_log/server_log.test.tsx index 505079a858102..a8a775bebdafa 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/server_log/server_log.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/server_log/server_log.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.server-log'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom.test.tsx index 2ebffea39da25..7673f4caf588e 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const SERVICENOW_ITOM_CONNECTOR_TYPE_ID = '.servicenow-itom'; let connectorTypeRegistry: TypeRegistry; beforeAll(() => { connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); }); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm.test.tsx index 1a2db4a4142f1..ea7497bde2837 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const SERVICENOW_ITSM_CONNECTOR_TYPE_ID = '.servicenow'; let connectorTypeRegistry: TypeRegistry; beforeAll(() => { connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); }); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir.test.tsx index 60ddf15b62dee..b2cfd79447ff8 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const SERVICENOW_SIR_CONNECTOR_TYPE_ID = '.servicenow-sir'; let connectorTypeRegistry: TypeRegistry; beforeAll(() => { connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); }); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/slack/slack.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/slack/slack.test.tsx index 40ff4a6240ba3..0dc0bad57b4b5 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/slack/slack.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/slack/slack.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.slack'; let connectorTypeModel: ConnectorTypeModel; beforeAll(async () => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_api.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_api.test.tsx index d8c49ef12d9b5..33fad281654e8 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_api.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/slack_api/slack_api.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; import { registerConnectorTypes } from '..'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { SLACK_API_CONNECTOR_ID } from '../../../common/slack_api/constants'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; let connectorTypeModel: ConnectorTypeModel; beforeAll(async () => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(SLACK_API_CONNECTOR_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane.test.tsx index 18da58e6b9bf0..5b0cad26c394f 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.swimlane'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/teams/teams.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/teams/teams.test.tsx index d7ceabda2be02..f3ce70b74f6ef 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/teams/teams.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/teams/teams.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.teams'; let connectorTypeModel: ConnectorTypeModel; beforeAll(async () => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/tines/tines.test.ts b/x-pack/plugins/stack_connectors/public/connector_types/tines/tines.test.ts index 0306967176012..be647b3f4a704 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/tines/tines.test.ts +++ b/x-pack/plugins/stack_connectors/public/connector_types/tines/tines.test.ts @@ -8,9 +8,10 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; import { TinesExecuteActionParams } from './types'; import { SUB_ACTION, TINES_CONNECTOR_ID, TINES_TITLE } from '../../../common/tines/constants'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; let actionTypeModel: ConnectorTypeModel; @@ -35,6 +36,7 @@ const defaultValidationErrors = { beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(TINES_CONNECTOR_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/torq/torq.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/torq/torq.test.tsx index 09bb5a210a333..2ce9f48ae1731 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/torq/torq.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/torq/torq.test.tsx @@ -8,13 +8,15 @@ import { ActionTypeModel } from '@kbn/triggers-actions-ui-plugin/public'; import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const ACTION_TYPE_ID = '.torq'; let actionTypeModel: ActionTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(ACTION_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/webhook/webhook.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/webhook/webhook.test.tsx index 2f345031b25c7..62052bb56171f 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/webhook/webhook.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/webhook/webhook.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.webhook'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/xmatters/xmatters.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/xmatters/xmatters.test.tsx index e2e03465d57b2..a38ea1d8eb41c 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/xmatters/xmatters.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/xmatters/xmatters.test.tsx @@ -8,13 +8,15 @@ import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { registerConnectorTypes } from '..'; import type { ActionTypeModel as ConnectorTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; -import { registrationServicesMock } from '../../mocks'; +import { experimentalFeaturesMock, registrationServicesMock } from '../../mocks'; +import { ExperimentalFeaturesService } from '../../common/experimental_features_service'; const CONNECTOR_TYPE_ID = '.xmatters'; let connectorTypeModel: ConnectorTypeModel; beforeAll(() => { const connectorTypeRegistry = new TypeRegistry(); + ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock }); registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock }); const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID); if (getResult !== null) { diff --git a/x-pack/plugins/stack_connectors/public/mocks.ts b/x-pack/plugins/stack_connectors/public/mocks.ts index 9e087c3cee6eb..93a81d93730d9 100644 --- a/x-pack/plugins/stack_connectors/public/mocks.ts +++ b/x-pack/plugins/stack_connectors/public/mocks.ts @@ -7,9 +7,12 @@ import { ValidatedEmail } from '@kbn/actions-plugin/common'; import { RegistrationServices } from './connector_types'; +import { allowedExperimentalValues, ExperimentalFeatures } from '../common/experimental_features'; function validateEmailAddresses(addresses: string[]): ValidatedEmail[] { return addresses.map((address) => ({ address, valid: true })); } export const registrationServicesMock: RegistrationServices = { validateEmailAddresses }; + +export const experimentalFeaturesMock: ExperimentalFeatures = allowedExperimentalValues; diff --git a/x-pack/plugins/stack_connectors/public/plugin.ts b/x-pack/plugins/stack_connectors/public/plugin.ts index 3c153d0de2573..4946268506fdf 100644 --- a/x-pack/plugins/stack_connectors/public/plugin.ts +++ b/x-pack/plugins/stack_connectors/public/plugin.ts @@ -35,13 +35,13 @@ export class StackConnectorsPublicPlugin this.experimentalFeatures = parseExperimentalConfigValue(this.config.enableExperimental || []); } public setup(core: CoreSetup, { triggersActionsUi, actions }: StackConnectorsPublicSetupDeps) { + ExperimentalFeaturesService.init({ experimentalFeatures: this.experimentalFeatures }); registerConnectorTypes({ connectorTypeRegistry: triggersActionsUi.actionTypeRegistry, services: { validateEmailAddresses: actions.validateEmailAddresses, }, }); - ExperimentalFeaturesService.init({ experimentalFeatures: this.experimentalFeatures }); } public start() {} diff --git a/x-pack/plugins/stack_connectors/server/connector_types/index.test.ts b/x-pack/plugins/stack_connectors/server/connector_types/index.test.ts index c2aaf7c7ea5d8..428e4a4c92835 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/index.test.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/index.test.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { allowedExperimentalValues } from '../../common/experimental_features'; import { registerConnectorTypes } from '.'; import { actionsMock } from '@kbn/actions-plugin/server/mocks'; @@ -31,6 +32,7 @@ describe('registers connectors', () => { test('calls registerType with expected connector types', () => { registerConnectorTypes({ actions: mockedActions, + experimentalFeatures: allowedExperimentalValues, }); ACTION_TYPE_IDS.forEach((id) => expect(mockedActions.registerType).toHaveBeenCalledWith( diff --git a/x-pack/plugins/stack_connectors/server/connector_types/index.ts b/x-pack/plugins/stack_connectors/server/connector_types/index.ts index 0117a9d1a7a2a..540f2746516b5 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/index.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/index.ts @@ -31,6 +31,8 @@ import { getConnectorType as getD3SecurityConnectorType } from './d3security'; import { getOpsgenieConnectorType } from './opsgenie'; import type { ActionParamsType as ServiceNowITSMActionParams } from './servicenow_itsm'; import type { ActionParamsType as ServiceNowSIRActionParams } from './servicenow_sir'; +import { getSentinelOneConnectorType } from './sentinelone'; +import { ExperimentalFeatures } from '../../common/experimental_features'; export { ConnectorTypeId as CasesWebhookConnectorTypeId } from './cases_webhook'; export type { ActionParamsType as CasesWebhookActionParams } from './cases_webhook'; @@ -77,9 +79,11 @@ export { getConnectorType as getSwimlaneConnectorType } from './swimlane'; export function registerConnectorTypes({ actions, publicBaseUrl, + experimentalFeatures, }: { actions: ActionsPluginSetupContract; publicBaseUrl?: string; + experimentalFeatures: ExperimentalFeatures; }) { actions.registerType(getEmailConnectorType({ publicBaseUrl })); actions.registerType(getIndexConnectorType()); @@ -104,4 +108,8 @@ export function registerConnectorTypes({ actions.registerSubActionConnectorType(getOpenAIConnectorType()); actions.registerSubActionConnectorType(getBedrockConnectorType()); actions.registerSubActionConnectorType(getD3SecurityConnectorType()); + + if (experimentalFeatures.sentinelOneConnectorOn) { + actions.registerSubActionConnectorType(getSentinelOneConnectorType()); + } } diff --git a/x-pack/plugins/stack_connectors/server/plugin.ts b/x-pack/plugins/stack_connectors/server/plugin.ts index 8e74b3c88395c..aee84d963043d 100644 --- a/x-pack/plugins/stack_connectors/server/plugin.ts +++ b/x-pack/plugins/stack_connectors/server/plugin.ts @@ -9,6 +9,11 @@ import { PluginInitializerContext, Plugin, CoreSetup, Logger } from '@kbn/core/s import { PluginSetupContract as ActionsPluginSetupContract } from '@kbn/actions-plugin/server'; import { registerConnectorTypes } from './connector_types'; import { validSlackApiChannelsRoute, getWellKnownEmailServiceRoute } from './routes'; +import { + ExperimentalFeatures, + parseExperimentalConfigValue, +} from '../common/experimental_features'; +import { StackConnectorsConfigType } from '../common/types'; export interface ConnectorsPluginsSetup { actions: ActionsPluginSetupContract; } @@ -19,9 +24,13 @@ export interface ConnectorsPluginsStart { export class StackConnectorsPlugin implements Plugin { private readonly logger: Logger; + private config: StackConnectorsConfigType; + readonly experimentalFeatures: ExperimentalFeatures; constructor(context: PluginInitializerContext) { this.logger = context.logger.get(); + this.config = context.config.get(); + this.experimentalFeatures = parseExperimentalConfigValue(this.config.enableExperimental || []); } public setup(core: CoreSetup, plugins: ConnectorsPluginsSetup) { @@ -34,6 +43,7 @@ export class StackConnectorsPlugin implements Plugin { registerConnectorTypes({ actions, publicBaseUrl: core.http.basePath.publicBaseUrl, + experimentalFeatures: this.experimentalFeatures, }); }