Skip to content

Commit b79f3f8

Browse files
committed
[Security Solution][Detections] Extend alerts schema to accommodate the list of assigned users (#7647)
1 parent 82306ea commit b79f3f8

21 files changed

Lines changed: 119 additions & 16 deletions

File tree

packages/kbn-alerts-as-data-utils/src/field_maps/alert_field_map.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
ALERT_TIME_RANGE,
3333
ALERT_URL,
3434
ALERT_UUID,
35+
ALERT_WORKFLOW_ASSIGNEES,
3536
ALERT_WORKFLOW_STATUS,
3637
ALERT_WORKFLOW_TAGS,
3738
SPACE_IDS,
@@ -182,6 +183,11 @@ export const alertFieldMap = {
182183
array: true,
183184
required: false,
184185
},
186+
[ALERT_WORKFLOW_ASSIGNEES]: {
187+
type: 'keyword',
188+
array: true,
189+
required: false,
190+
},
185191
[EVENT_ACTION]: {
186192
type: 'keyword',
187193
array: false,

packages/kbn-alerts-as-data-utils/src/schemas/generated/alert_schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const AlertOptional = rt.partial({
116116
start: schemaDate,
117117
time_range: schemaDateRange,
118118
url: schemaString,
119+
workflow_assignees: schemaStringArray,
119120
workflow_status: schemaString,
120121
workflow_tags: schemaStringArray,
121122
}),

packages/kbn-alerts-as-data-utils/src/schemas/generated/security_schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ const SecurityAlertOptional = rt.partial({
234234
}),
235235
time_range: schemaDateRange,
236236
url: schemaString,
237+
workflow_assignees: schemaStringArray,
237238
workflow_reason: schemaString,
238239
workflow_status: schemaString,
239240
workflow_tags: schemaStringArray,

packages/kbn-alerts-as-data-utils/src/search/security/fields.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ALERT_RISK_SCORE,
1212
ALERT_SEVERITY,
1313
ALERT_RULE_PARAMETERS,
14+
ALERT_WORKFLOW_ASSIGNEES,
1415
ALERT_WORKFLOW_TAGS,
1516
} from '@kbn/rule-data-utils';
1617

@@ -46,6 +47,7 @@ export const ALERT_EVENTS_FIELDS = [
4647
ALERT_RULE_CONSUMER,
4748
'@timestamp',
4849
'kibana.alert.ancestors.index',
50+
ALERT_WORKFLOW_ASSIGNEES,
4951
'kibana.alert.workflow_status',
5052
ALERT_WORKFLOW_TAGS,
5153
'kibana.alert.group.id',

packages/kbn-rule-data-utils/src/default_alerts_as_data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const ALERT_WORKFLOW_STATUS = `${ALERT_NAMESPACE}.workflow_status` as const;
7070
// kibana.alert.workflow_tags - user workflow alert tags
7171
const ALERT_WORKFLOW_TAGS = `${ALERT_NAMESPACE}.workflow_tags` as const;
7272

73+
// kibana.alert.workflow_assignees - user workflow alert assignees
74+
const ALERT_WORKFLOW_ASSIGNEES = `${ALERT_NAMESPACE}.workflow_assignees` as const;
75+
7376
// kibana.alert.rule.category - rule type name for rule that generated this alert
7477
const ALERT_RULE_CATEGORY = `${ALERT_RULE_NAMESPACE}.category` as const;
7578

@@ -135,6 +138,7 @@ const fields = {
135138
ALERT_TIME_RANGE,
136139
ALERT_URL,
137140
ALERT_UUID,
141+
ALERT_WORKFLOW_ASSIGNEES,
138142
ALERT_WORKFLOW_STATUS,
139143
ALERT_WORKFLOW_TAGS,
140144
SPACE_IDS,
@@ -174,6 +178,7 @@ export {
174178
ALERT_TIME_RANGE,
175179
ALERT_URL,
176180
ALERT_UUID,
181+
ALERT_WORKFLOW_ASSIGNEES,
177182
ALERT_WORKFLOW_STATUS,
178183
ALERT_WORKFLOW_TAGS,
179184
SPACE_IDS,

packages/kbn-rule-data-utils/src/technical_field_names.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
ALERT_STATUS,
3333
ALERT_TIME_RANGE,
3434
ALERT_UUID,
35+
ALERT_WORKFLOW_ASSIGNEES,
3536
ALERT_WORKFLOW_STATUS,
3637
ALERT_WORKFLOW_TAGS,
3738
SPACE_IDS,
@@ -168,6 +169,7 @@ const fields = {
168169
ALERT_STATUS,
169170
ALERT_SYSTEM_STATUS,
170171
ALERT_UUID,
172+
ALERT_WORKFLOW_ASSIGNEES,
171173
ALERT_WORKFLOW_REASON,
172174
ALERT_WORKFLOW_STATUS,
173175
ALERT_WORKFLOW_TAGS,

packages/kbn-securitysolution-ecs/src/signal/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type SignalEcsAAD = Exclude<SignalEcs, 'rule' | 'status'> & {
2424
building_block_type?: string[];
2525
workflow_status?: string[];
2626
workflow_tags?: string[];
27+
workflow_assignees?: string[];
2728
suppression?: {
2829
docs_count: string[];
2930
};

x-pack/plugins/alerting/common/alert_schema/field_maps/mapping_from_field_map.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ describe('mappingFromFieldMap', () => {
306306
workflow_tags: {
307307
type: 'keyword',
308308
},
309+
workflow_assignees: {
310+
type: 'keyword',
311+
},
309312
},
310313
},
311314
space_ids: {

x-pack/plugins/rule_registry/common/assets/field_maps/technical_rule_field_map.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ it('matches snapshot', () => {
286286
"required": true,
287287
"type": "keyword",
288288
},
289+
"kibana.alert.workflow_assignees": Object {
290+
"array": true,
291+
"required": false,
292+
"type": "keyword",
293+
},
289294
"kibana.alert.workflow_reason": Object {
290295
"array": false,
291296
"required": false,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { ALERT_WORKFLOW_ASSIGNEES } from '@kbn/rule-data-utils';
9+
import type { AlertWithCommonFields800 } from '@kbn/rule-registry-plugin/common/schemas/8.0.0';
10+
import type {
11+
Ancestor890,
12+
BaseFields890,
13+
EqlBuildingBlockFields890,
14+
EqlShellFields890,
15+
NewTermsFields890,
16+
} from '../8.9.0';
17+
18+
/* DO NOT MODIFY THIS SCHEMA TO ADD NEW FIELDS. These types represent the alerts that shipped in 8.11.0.
19+
Any changes to these types should be bug fixes so the types more accurately represent the alerts from 8.11.0.
20+
If you are adding new fields for a new release of Kibana, create a new sibling folder to this one
21+
for the version to be released and add the field(s) to the schema in that folder.
22+
Then, update `../index.ts` to import from the new folder that has the latest schemas, add the
23+
new schemas to the union of all alert schemas, and re-export the new schemas as the `*Latest` schemas.
24+
*/
25+
26+
export type { Ancestor890 as Ancestor8110 };
27+
28+
export interface BaseFields8110 extends BaseFields890 {
29+
[ALERT_WORKFLOW_ASSIGNEES]: string[];
30+
}
31+
32+
export interface WrappedFields8110<T extends BaseFields8110> {
33+
_id: string;
34+
_index: string;
35+
_source: T;
36+
}
37+
38+
export type GenericAlert8110 = AlertWithCommonFields800<BaseFields8110>;
39+
40+
export type EqlShellFields8110 = EqlShellFields890 & BaseFields8110;
41+
42+
export type EqlBuildingBlockFields8110 = EqlBuildingBlockFields890 & BaseFields8110;
43+
44+
export type NewTermsFields8110 = NewTermsFields890 & BaseFields8110;
45+
46+
export type NewTermsAlert8110 = NewTermsFields890 & BaseFields8110;
47+
48+
export type EqlBuildingBlockAlert8110 = AlertWithCommonFields800<EqlBuildingBlockFields890>;
49+
50+
export type EqlShellAlert8110 = AlertWithCommonFields800<EqlShellFields8110>;
51+
52+
export type DetectionAlert8110 =
53+
| GenericAlert8110
54+
| EqlShellAlert8110
55+
| EqlBuildingBlockAlert8110
56+
| NewTermsAlert8110;

0 commit comments

Comments
 (0)