Skip to content

Commit

Permalink
Merge branch 'main' into ml-aiops-technical-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Jul 22, 2022
2 parents 42e58af + c0ad0f9 commit f5d1feb
Show file tree
Hide file tree
Showing 391 changed files with 3,657 additions and 13,317 deletions.
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
trustedApps: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/trusted-apps-ov.html`,
eventFilters: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/event-filters.html`,
blocklist: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/blocklist.html`,
threatIntelInt: `${SECURITY_SOLUTION_DOCS}es-threat-intel-integrations.html`,
policyResponseTroubleshooting: {
full_disk_access: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/deploy-elastic-endpoint.html#enable-fda-endpoint`,
macos_system_ext: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/deploy-elastic-endpoint.html#system-extension-endpoint`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,38 @@ All user changed UI Settings are automatically collected.

After adding a new setting you will be required to do the following steps:

1. Update the [schema](./schema.ts) to include the setting name and schema type.
```
export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'MY_UI_SETTING': { type: 'keyword' },
}
```
1. Update the [UsageStats interface](./types.ts) with the setting name and typescript type.

```typescript
export interface UsageStats {
'MY_UI_SETTING': string;
}
```

2. Update the [schema](./schema.ts) to include the setting name and schema type.

```typescript
export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'MY_UI_SETTING': {
type: 'keyword',
_meta: { description: 'Non-default value of setting.' }
},
}
```

2. Update the [UsageStats interface](./types.ts) with the setting name and typescript type.
```
export interface UsageStats {
'MY_UI_SETTING': string;
}
```
3. Run the telemetry checker with `--fix` flag to automatically fix the mappings

```
node scripts/telemetry_check --fix
```
```bash
node scripts/telemetry_check --fix
```

If you forget any of the steps our telemetry tools and tests will help you through the process!

## Sensitive fields

If the configured UI setting might contain user sensitive information simply add the property `sensitive: true` to the ui setting registration config.

```
```typescript
uiSettings.register({
[NEWS_FEED_URL_SETTING]: {
name: i18n.translate('xpack.securitySolution.uiSettings.newsFeedUrl', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,60 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'discover:rowHeightOption': {
type: 'integer',
_meta: { description: 'Non-default value of setting.' },
},
hideAnnouncements: {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
isDefaultIndexMigrated: {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'lens:useFieldExistenceSampling': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'metrics:allowCheckingForFailedShards': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmDefaultServiceEnvironment': {
type: 'keyword',
_meta: { description: 'Default value of the setting was changed.' },
},
'observability:apmOperationsTab': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmProgressiveLoading': {
type: 'keyword',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmServiceGroupMaxNumberOfServices': {
type: 'long',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmServiceInventoryOptimizedSorting': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:apmTraceExplorerTab': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'securitySolution:enableGroupedNav': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'securitySolution:showRelatedIntegrations': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'visualization:visualize:legacyGaugeChartsLibrary': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface UsageStats {
'xpackDashboardMode:roles': string;
'securitySolution:ipReputationLinks': string;
'banners:textContent': string;
'observability:apmDefaultServiceEnvironment': string;
/**
* non-sensitive settings
*/
Expand Down Expand Up @@ -131,4 +132,17 @@ export interface UsageStats {
'labs:dashboard:enable_ui': boolean;
'labs:dashboard:deferBelowFold': boolean;
'labs:dashboard:dashboardControls': boolean;
'discover:rowHeightOption': number;
hideAnnouncements: boolean;
isDefaultIndexMigrated: boolean;
'lens:useFieldExistenceSampling': boolean;
'metrics:allowCheckingForFailedShards': boolean;
'observability:apmOperationsTab': boolean;
'observability:apmProgressiveLoading': string;
'observability:apmServiceGroupMaxNumberOfServices': number;
'observability:apmServiceInventoryOptimizedSorting': boolean;
'observability:apmTraceExplorerTab': boolean;
'securitySolution:enableGroupedNav': boolean;
'securitySolution:showRelatedIntegrations': boolean;
'visualization:visualize:legacyGaugeChartsLibrary': boolean;
}
84 changes: 84 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8496,6 +8496,90 @@
"_meta": {
"description": "Non-default value of setting."
}
},
"discover:rowHeightOption": {
"type": "integer",
"_meta": {
"description": "Non-default value of setting."
}
},
"hideAnnouncements": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"isDefaultIndexMigrated": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"lens:useFieldExistenceSampling": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"metrics:allowCheckingForFailedShards": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:apmDefaultServiceEnvironment": {
"type": "keyword",
"_meta": {
"description": "Default value of the setting was changed."
}
},
"observability:apmOperationsTab": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:apmProgressiveLoading": {
"type": "keyword",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:apmServiceGroupMaxNumberOfServices": {
"type": "long",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:apmServiceInventoryOptimizedSorting": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:apmTraceExplorerTab": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"securitySolution:enableGroupedNav": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"securitySolution:showRelatedIntegrations": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"visualization:visualize:legacyGaugeChartsLibrary": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
}
}
},
Expand Down
41 changes: 25 additions & 16 deletions x-pack/plugins/actions/server/sub_action_framework/case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TestCaseConnector } from './mocks';
import { ActionsConfigurationUtilities } from '../actions_config';

describe('CaseConnector', () => {
const pushToServiceParams = { externalId: null, comments: [] };
const pushToServiceParams = { incident: { externalId: null }, comments: [] };
let logger: MockedLogger;
let services: ReturnType<typeof actionsMock.createServices>;
let mockedActionsConfig: jest.Mocked<ActionsConfigurationUtilities>;
Expand Down Expand Up @@ -57,19 +57,19 @@ describe('CaseConnector', () => {
const subAction = subActions.get('pushToService');
expect(
subAction?.schema?.validate({
externalId: 'test',
incident: { externalId: 'test' },
comments: [{ comment: 'comment', commentId: 'comment-id' }],
})
).toEqual({
externalId: 'test',
incident: { externalId: 'test' },
comments: [{ comment: 'comment', commentId: 'comment-id' }],
});
});

it('should accept null for externalId', async () => {
const subActions = service.getSubActions();
const subAction = subActions.get('pushToService');
expect(subAction?.schema?.validate({ externalId: null, comments: [] }));
expect(subAction?.schema?.validate({ incident: { externalId: null }, comments: [] }));
});

it.each([[undefined], [1], [false], [{ test: 'hello' }], [['test']], [{ test: 'hello' }]])(
Expand All @@ -84,7 +84,7 @@ describe('CaseConnector', () => {
it('should accept null for comments', async () => {
const subActions = service.getSubActions();
const subAction = subActions.get('pushToService');
expect(subAction?.schema?.validate({ externalId: 'test', comments: null }));
expect(subAction?.schema?.validate({ incident: { externalId: 'test' }, comments: null }));
});

it.each([
Expand All @@ -98,30 +98,35 @@ describe('CaseConnector', () => {
])('should throw if comments %p', async (comments) => {
const subActions = service.getSubActions();
const subAction = subActions.get('pushToService');
expect(() => subAction?.schema?.validate({ externalId: 'test', comments }));
expect(() => subAction?.schema?.validate({ incident: { externalId: 'test' }, comments }));
});

it('should allow any field in the params', async () => {
const subActions = service.getSubActions();
const subAction = subActions.get('pushToService');

expect(
subAction?.schema?.validate({
externalId: 'test',
incident: {
externalId: 'test',
foo: 'foo',
bar: 1,
baz: [{ test: 'hello' }, 1, 'test', false],
isValid: false,
val: null,
},
comments: [{ comment: 'comment', commentId: 'comment-id' }],
})
).toEqual({
incident: {
externalId: 'test',
foo: 'foo',
bar: 1,
baz: [{ test: 'hello' }, 1, 'test', false],
isValid: false,
val: null,
})
).toEqual({
externalId: 'test',
},
comments: [{ comment: 'comment', commentId: 'comment-id' }],
foo: 'foo',
bar: 1,
baz: [{ test: 'hello' }, 1, 'test', false],
isValid: false,
val: null,
});
});
});
Expand All @@ -138,7 +143,11 @@ describe('CaseConnector', () => {
});

it('should update an incident if externalId is not null', async () => {
const res = await service.pushToService({ ...pushToServiceParams, externalId: 'test-id' });
const res = await service.pushToService({
...pushToServiceParams,
incident: { externalId: 'test-id' },
});

expect(res).toEqual({
id: 'update-incident',
title: 'Test incident',
Expand Down
31 changes: 16 additions & 15 deletions x-pack/plugins/actions/server/sub_action_framework/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ export abstract class CaseConnector<Config, Secrets>
this.registerSubAction({
name: 'pushToService',
method: 'pushToService',
schema: schema.object(
{
externalId: schema.nullable(schema.string()),
comments: schema.nullable(
schema.arrayOf(
schema.object({
comment: schema.string(),
commentId: schema.string(),
})
)
),
},
{ unknowns: 'allow' }
),
schema: schema.object({
incident: schema.object(
{ externalId: schema.nullable(schema.string()) },
{ unknowns: 'allow' }
),
comments: schema.nullable(
schema.arrayOf(
schema.object({
comment: schema.string(),
commentId: schema.string(),
})
)
),
}),
});
}

Expand All @@ -82,7 +82,8 @@ export abstract class CaseConnector<Config, Secrets>
public abstract getIncident({ id }: { id: string }): Promise<ExternalServiceIncidentResponse>;

public async pushToService(params: PushToServiceParams) {
const { externalId, comments, ...rest } = params;
const { incident, comments } = params;
const { externalId, ...rest } = incident;

let res: PushToServiceResponse;

Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/actions/server/sub_action_framework/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ export interface SubAction {
}

export interface PushToServiceParams {
externalId: string | null;
incident: {
externalId: string | null;
[x: string]: unknown;
};
comments: Array<{ commentId: string; comment: string }>;
[x: string]: unknown;
}

export interface ExternalServiceIncidentResponse {
Expand Down
Loading

0 comments on commit f5d1feb

Please sign in to comment.