Skip to content

Commit

Permalink
Add sentinelOneConnectorOn experimental flag (elastic#169922)
Browse files Browse the repository at this point in the history
## Summary

Adds experimental flag used for the development of SentinelOne connector

Add this to the `kibana.yml` config
```
xpack.stack_connectors.enableExperimental: [sentinelOneConnectorOn]
```

Before:
<img width="1881" alt="Zrzut ekranu 2023-10-26 o 12 45 22"
src="https://github.com/elastic/kibana/assets/5188868/c47bf713-8da9-4bca-89be-d8cfa0ac7e61">

After:
<img width="1882" alt="Zrzut ekranu 2023-10-26 o 12 44 10"
src="https://github.com/elastic/kibana/assets/5188868/a28d1281-f5b3-41f5-bb9d-8381c8a11291">
  • Loading branch information
patrykkopycinski authored Nov 3, 2023
1 parent 4538046 commit d89631e
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 28 deletions.
10 changes: 4 additions & 6 deletions x-pack/plugins/stack_connectors/common/experimental_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,28 @@ export type ExperimentalFeatures = typeof allowedExperimentalValues;
*/
export const allowedExperimentalValues = Object.freeze({
isMustacheAutocompleteOn: false,
sentinelOneConnectorOn: false,
});

type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
type Mutable<T> = { -readonly [P in keyof T]: T[P] };

const InvalidExperimentalValue = class extends Error {};
const allowedKeys = Object.keys(allowedExperimentalValues) as Readonly<ExperimentalConfigKeys>;

/**
* Parses the string value used in `xpack.stack_connectors.enableExperimental` kibana configuration,
* which should be a string of values delimited by a comma (`,`)
*
* @param configValue
* @throws InvalidExperimentalValue
*/
export const parseExperimentalConfigValue = (configValue: string[]): ExperimentalFeatures => {
const enabledFeatures: Mutable<Partial<ExperimentalFeatures>> = {};

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActionTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(ACTION_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,6 +47,7 @@ beforeEach(() => {
});

beforeAll(() => {
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
const connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>();
registerConnectorTypes({ connectorTypeRegistry, services: RegistrationServices });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
Expand Down Expand Up @@ -66,4 +68,8 @@ export function registerConnectorTypes({
connectorTypeRegistry.register(getTorqConnectorType());
connectorTypeRegistry.register(getTinesConnectorType());
connectorTypeRegistry.register(getD3SecurityConnectorType());

if (ExperimentalFeaturesService.get().sentinelOneConnectorOn) {
connectorTypeRegistry.register(getSentinelOneConnectorType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActionTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(ACTION_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(OpsgenieConnectorTypeId);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>;

beforeAll(() => {
connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>;

beforeAll(() => {
connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>;

beforeAll(() => {
connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(SLACK_API_CONNECTOR_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(CONNECTOR_TYPE_ID);
if (getResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -35,6 +36,7 @@ const defaultValidationErrors = {

beforeAll(() => {
const connectorTypeRegistry = new TypeRegistry<ConnectorTypeModel>();
ExperimentalFeaturesService.init({ experimentalFeatures: experimentalFeaturesMock });
registerConnectorTypes({ connectorTypeRegistry, services: registrationServicesMock });
const getResult = connectorTypeRegistry.get(TINES_CONNECTOR_ID);
if (getResult !== null) {
Expand Down
Loading

0 comments on commit d89631e

Please sign in to comment.