Skip to content

Commit cdacea7

Browse files
## [Attack discovery] Optionally update the kibana.alert.workflow_status of alerts associated with Attack discoveries
This PR introduces a new UI to optionally update the `kibana.alert.workflow_status` of alerts associated with Attack discoveries, as illustrated by the animated gif below: ![update_attack_discovery_alerts](https://github.com/user-attachments/assets/5974fc4e-50b4-43e9-9939-885f9577c153) Users may (optionally) update all alerts for a single attack discovery, or just update the discovery itself: ![update_one_attack_discovery](https://github.com/user-attachments/assets/fd774ae7-976d-4649-a97d-b9bae8d359ad) When multiple attack discoveries are selected, users may also (optionally) update the status of all their related alerts via the bulk action menu: ![update_multiple_discoveries](https://github.com/user-attachments/assets/71463945-f201-4810-9798-2646751dc919) ### Alert document enhancements Attack discoveries generated via the Attack discovery page, and scheduled Attack discoveries (generated via the alerting framework), are persisted as alert documents. To support the new UI, this PR populates Attack discovery alert documents with two additional (existing, but unused by Attack discovery) alert document fields: 1) `kibana.alert.start` - timestamp when Attack discoveries are created 2) `kibana.alert.workflow_status_updated_at` - timestamp when the `kibana.alert.workflow_status` was last updated This PR introduces three new alert document fields to capture metadata about when alerts are updated. Attack discovery is the first implementation to use these new fields, however any consumer of the alerting framework may utilize them in the future: 1) `kibana.alert.updated_at` - timestamp when the alert was last updated 2) `kibana.alert.updated_by.user.id` - user id of the user that last updated the alert 3) `kibana.alert.updated_by.user.name` - user name of the user that last updated the alert The three new alert fields above are updated when Attack discovery users update: - The `kibana.alert.workflow_status` status of Attack discoveries - The visibility (sharing) status of Attack discoveries (`kibana.alert.attack_discovery.users`) The three new fields above were added to the [alert_field_map](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-alerts-as-data-utils/src/field_maps/alert_field_map.ts) and [alert_schema](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-alerts-as-data-utils/src/schemas/generated/alert_schema.ts). Using the `default` space as an example, the fields above may be observed in the `.adhoc.alerts-security.attack.discovery.alerts-default` data stream for Attack discoveries generated on the Attack discovery page, and scheduled discoveries for the same space are found in the `.alerts-security.attack.discovery.alerts-default` data stream. ### @timestamp updated when sharing status changes To ensure newly-shared Attack discoveries are bumped to the top of search results, the `@timestamp` field is updated when the visibility (sharing) status of Attack discoveries (`kibana.alert.attack_discovery.users`) is updated. (The original time an Attack discovery was generated is represented by the `kibana.alert.start` field, which is not mutated.) ### Visibility menu changes This PR disables the visibility menu items for shared Attack discoveries, as illustrated by the screenshot below: ![visibility_menu_disabled](https://github.com/user-attachments/assets/168db75c-de8f-4bf1-9490-7e3995faed9d) The disabled menu has a tooltip that reads: ``` The visibility of shared discoveries cannot be changed ``` Note: The internal Attack discovery bulk API still (intentionally) allows changes to the visibility of shared attack discoveries. ### `kibana.alert.workflow_status` added to default `Alerts` tab columns The `kibana.alert.workflow_status` field was added to default `Alerts` tab columns, as illustrated by the screenshot below: ![alerts_tab_workflow_status](https://github.com/user-attachments/assets/264647d0-5782-444f-ad0e-c5485fae1e96) ### Feature flags The _required_ feature flag below is necessary to desk test with Ad hoc attack discoveries. The _recommended_ feature flag below enables testing with scheduled Attack discoveries. ### required: `securitySolution.attackDiscoveryAlertsEnabled` Enable the required `securitySolution.attackDiscoveryAlertsEnabled` feature flag in `config/kibana.dev.yml`: ```yaml feature_flags.overrides: securitySolution.attackDiscoveryAlertsEnabled: true ``` ### recommended: `securitySolution.assistantAttackDiscoverySchedulingEnabled: true` Also enable the recommended `assistantAttackDiscoverySchedulingEnabled` feature flag in `config/kibana.dev.yml`: ```yaml feature_flags.overrides: securitySolution.attackDiscoveryAlertsEnabled: true securitySolution.assistantAttackDiscoverySchedulingEnabled: true ```
1 parent 6907186 commit cdacea7

36 files changed

Lines changed: 2296 additions & 318 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ import {
3737
ALERT_START,
3838
ALERT_STATUS,
3939
ALERT_TIME_RANGE,
40+
ALERT_UPDATED_AT,
41+
ALERT_UPDATED_BY_USER_ID,
42+
ALERT_UPDATED_BY_USER_NAME,
4043
ALERT_URL,
4144
ALERT_UUID,
4245
ALERT_WORKFLOW_ASSIGNEE_IDS,
@@ -213,6 +216,21 @@ export const alertFieldMap = {
213216
array: false,
214217
required: false,
215218
},
219+
[ALERT_UPDATED_AT]: {
220+
type: 'date',
221+
array: false,
222+
required: false,
223+
},
224+
[ALERT_UPDATED_BY_USER_ID]: {
225+
type: 'keyword',
226+
array: false,
227+
required: false,
228+
},
229+
[ALERT_UPDATED_BY_USER_NAME]: {
230+
type: 'keyword',
231+
array: false,
232+
required: false,
233+
},
216234
[ALERT_URL]: {
217235
type: 'keyword',
218236
array: false,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ const AlertOptional = rt.partial({
107107
'kibana.alert.severity_improving': schemaBoolean,
108108
'kibana.alert.start': schemaDate,
109109
'kibana.alert.time_range': schemaDateRange,
110+
'kibana.alert.updated_at': schemaDate,
111+
'kibana.alert.updated_by.user.id': schemaString,
112+
'kibana.alert.updated_by.user.name': schemaString,
110113
'kibana.alert.url': schemaString,
111114
'kibana.alert.workflow_assignee_ids': schemaStringArray,
112115
'kibana.alert.workflow_status': schemaString,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ const SecurityAlertOptional = rt.partial({
207207
})
208208
),
209209
'kibana.alert.time_range': schemaDateRange,
210+
'kibana.alert.updated_at': schemaDate,
211+
'kibana.alert.updated_by.user.id': schemaString,
212+
'kibana.alert.updated_by.user.name': schemaString,
210213
'kibana.alert.url': schemaString,
211214
'kibana.alert.user.criticality_level': schemaString,
212215
'kibana.alert.workflow_assignee_ids': schemaStringArray,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ const ALERT_REASON = `${ALERT_NAMESPACE}.reason` as const;
7171
// kibana.alert.start - timestamp when the alert is first active
7272
const ALERT_START = `${ALERT_NAMESPACE}.start` as const;
7373

74+
// kibana.alert.updated_at - timestamp when the alert was last updated
75+
const ALERT_UPDATED_AT = `${ALERT_NAMESPACE}.updated_at` as const;
76+
77+
// kibana.alert.updated_by.user.id - user id of the user that last updated the alert
78+
const ALERT_UPDATED_BY_USER_ID = `${ALERT_NAMESPACE}.updated_by.user.id` as const;
79+
80+
// kibana.alert.updated_by.user.name - user name of the user that last updated the alert
81+
const ALERT_UPDATED_BY_USER_NAME = `${ALERT_NAMESPACE}.updated_by.user.name` as const;
82+
7483
// kibana.alert.status - active/recovered status of alert
7584
const ALERT_STATUS = `${ALERT_NAMESPACE}.status` as const;
7685

@@ -163,6 +172,9 @@ export const fields = {
163172
ALERT_RULE_UUID,
164173
ALERT_SEVERITY_IMPROVING,
165174
ALERT_START,
175+
ALERT_UPDATED_AT,
176+
ALERT_UPDATED_BY_USER_ID,
177+
ALERT_UPDATED_BY_USER_NAME,
166178
ALERT_STATUS,
167179
ALERT_TIME_RANGE,
168180
ALERT_URL,
@@ -210,6 +222,9 @@ export {
210222
ALERT_RULE_UUID,
211223
ALERT_SEVERITY_IMPROVING,
212224
ALERT_START,
225+
ALERT_UPDATED_AT,
226+
ALERT_UPDATED_BY_USER_ID,
227+
ALERT_UPDATED_BY_USER_NAME,
213228
ALERT_STATUS,
214229
ALERT_TIME_RANGE,
215230
ALERT_URL,

x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/attack_discovery/attack_discovery_alert.gen.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ export const AttackDiscoveryAlert = z.object({
4444
* The (human readable) name of the connector that generated the attack discovery
4545
*/
4646
connectorName: z.string(),
47+
/**
48+
* The optional time the attack discovery alert was created
49+
*/
50+
alertStart: z.string().optional(),
51+
/**
52+
* The optional time the attack discovery alert was last updated
53+
*/
54+
alertUpdatedAt: z.string().optional(),
55+
/**
56+
* The optional id of the user who last updated the attack discovery alert
57+
*/
58+
alertUpdatedByUserId: z.string().optional(),
59+
/**
60+
* The optional username of the user who updated the attack discovery alert
61+
*/
62+
alertUpdatedByUserName: z.string().optional(),
63+
/**
64+
* The optional time the attack discovery alert workflow status was last updated
65+
*/
66+
alertWorkflowStatusUpdatedAt: z.string().optional(),
4767
/**
4868
* Details of the attack with bulleted markdown that always uses special syntax for field names and values from the source data.
4969
*/

x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/attack_discovery/attack_discovery_alert.schema.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ components:
3737
connectorName:
3838
description: The (human readable) name of the connector that generated the attack discovery
3939
type: string
40+
alertStart:
41+
description: The optional time the attack discovery alert was created
42+
type: string
43+
alertUpdatedAt:
44+
description: The optional time the attack discovery alert was last updated
45+
type: string
46+
alertUpdatedByUserId:
47+
description: The optional id of the user who last updated the attack discovery alert
48+
type: string
49+
alertUpdatedByUserName:
50+
description: The optional username of the user who updated the attack discovery alert
51+
type: string
52+
alertWorkflowStatusUpdatedAt:
53+
description: The optional time the attack discovery alert workflow status was last updated
54+
type: string
4055
detailsMarkdown:
4156
description: Details of the attack with bulleted markdown that always uses special syntax for field names and values from the source data.
4257
type: string

0 commit comments

Comments
 (0)