Skip to content

Commit 996462a

Browse files
nkhristininkibanamachineelasticmachine
authored andcommitted
Bulk operations support gap_range (elastic#221078)
## Bulk operations support `gap_range` [issue](elastic#220772) ### Bug If a user has 100 rules in total and 20 of them have gaps: - They click "Show only with gaps" — the UI shows just those 20. - They hit "Select all" — it says 20 rules are selected. - But when they perform a bulk action, it ends up applying to **all 100 rules**, not just the 20 with gaps. This happens because the bulk action uses a query that doesn't include gap info, so it ends up targeting everything. ### Fix We now support passing `gaps_range_start` and `gaps_range_end` along with the bulk action. On the API side: - If a query is sent, we use the gap range to find the actual list of rule IDs with gaps. - Then we apply the bulk action only to those rules. --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent ca1b312 commit 996462a

File tree

15 files changed

+490
-31
lines changed

15 files changed

+490
-31
lines changed

oas_docs/output/kibana.serverless.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61483,6 +61483,12 @@ components:
6148361483
enum:
6148461484
- delete
6148561485
type: string
61486+
gaps_range_end:
61487+
description: Gaps range end, valid only when query is provided
61488+
type: string
61489+
gaps_range_start:
61490+
description: Gaps range start, valid only when query is provided
61491+
type: string
6148661492
ids:
6148761493
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6148861494
items:
@@ -61501,6 +61507,12 @@ components:
6150161507
enum:
6150261508
- disable
6150361509
type: string
61510+
gaps_range_end:
61511+
description: Gaps range end, valid only when query is provided
61512+
type: string
61513+
gaps_range_start:
61514+
description: Gaps range start, valid only when query is provided
61515+
type: string
6150461516
ids:
6150561517
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6150661518
items:
@@ -61532,6 +61544,12 @@ components:
6153261544
required:
6153361545
- include_exceptions
6153461546
- include_expired_exceptions
61547+
gaps_range_end:
61548+
description: Gaps range end, valid only when query is provided
61549+
type: string
61550+
gaps_range_start:
61551+
description: Gaps range start, valid only when query is provided
61552+
type: string
6153561553
ids:
6153661554
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6153761555
items:
@@ -61624,6 +61642,12 @@ components:
6162461642
$ref: '#/components/schemas/Security_Detections_API_BulkActionEditPayload'
6162561643
minItems: 1
6162661644
type: array
61645+
gaps_range_end:
61646+
description: Gaps range end, valid only when query is provided
61647+
type: string
61648+
gaps_range_start:
61649+
description: Gaps range start, valid only when query is provided
61650+
type: string
6162761651
ids:
6162861652
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6162961653
items:
@@ -61647,6 +61671,12 @@ components:
6164761671
enum:
6164861672
- enable
6164961673
type: string
61674+
gaps_range_end:
61675+
description: Gaps range end, valid only when query is provided
61676+
type: string
61677+
gaps_range_start:
61678+
description: Gaps range start, valid only when query is provided
61679+
type: string
6165061680
ids:
6165161681
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6165261682
items:
@@ -61667,6 +61697,12 @@ components:
6166761697
enum:
6166861698
- export
6166961699
type: string
61700+
gaps_range_end:
61701+
description: Gaps range end, valid only when query is provided
61702+
type: string
61703+
gaps_range_start:
61704+
description: Gaps range start, valid only when query is provided
61705+
type: string
6167061706
ids:
6167161707
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6167261708
items:
@@ -61685,6 +61721,12 @@ components:
6168561721
enum:
6168661722
- run
6168761723
type: string
61724+
gaps_range_end:
61725+
description: Gaps range end, valid only when query is provided
61726+
type: string
61727+
gaps_range_start:
61728+
description: Gaps range start, valid only when query is provided
61729+
type: string
6168861730
ids:
6168961731
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
6169061732
items:

oas_docs/output/kibana.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70856,6 +70856,12 @@ components:
7085670856
enum:
7085770857
- delete
7085870858
type: string
70859+
gaps_range_end:
70860+
description: Gaps range end, valid only when query is provided
70861+
type: string
70862+
gaps_range_start:
70863+
description: Gaps range start, valid only when query is provided
70864+
type: string
7085970865
ids:
7086070866
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7086170867
items:
@@ -70874,6 +70880,12 @@ components:
7087470880
enum:
7087570881
- disable
7087670882
type: string
70883+
gaps_range_end:
70884+
description: Gaps range end, valid only when query is provided
70885+
type: string
70886+
gaps_range_start:
70887+
description: Gaps range start, valid only when query is provided
70888+
type: string
7087770889
ids:
7087870890
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7087970891
items:
@@ -70905,6 +70917,12 @@ components:
7090570917
required:
7090670918
- include_exceptions
7090770919
- include_expired_exceptions
70920+
gaps_range_end:
70921+
description: Gaps range end, valid only when query is provided
70922+
type: string
70923+
gaps_range_start:
70924+
description: Gaps range start, valid only when query is provided
70925+
type: string
7090870926
ids:
7090970927
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7091070928
items:
@@ -70997,6 +71015,12 @@ components:
7099771015
$ref: '#/components/schemas/Security_Detections_API_BulkActionEditPayload'
7099871016
minItems: 1
7099971017
type: array
71018+
gaps_range_end:
71019+
description: Gaps range end, valid only when query is provided
71020+
type: string
71021+
gaps_range_start:
71022+
description: Gaps range start, valid only when query is provided
71023+
type: string
7100071024
ids:
7100171025
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7100271026
items:
@@ -71020,6 +71044,12 @@ components:
7102071044
enum:
7102171045
- enable
7102271046
type: string
71047+
gaps_range_end:
71048+
description: Gaps range end, valid only when query is provided
71049+
type: string
71050+
gaps_range_start:
71051+
description: Gaps range start, valid only when query is provided
71052+
type: string
7102371053
ids:
7102471054
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7102571055
items:
@@ -71040,6 +71070,12 @@ components:
7104071070
enum:
7104171071
- export
7104271072
type: string
71073+
gaps_range_end:
71074+
description: Gaps range end, valid only when query is provided
71075+
type: string
71076+
gaps_range_start:
71077+
description: Gaps range start, valid only when query is provided
71078+
type: string
7104371079
ids:
7104471080
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7104571081
items:
@@ -71058,6 +71094,12 @@ components:
7105871094
enum:
7105971095
- run
7106071096
type: string
71097+
gaps_range_end:
71098+
description: Gaps range end, valid only when query is provided
71099+
type: string
71100+
gaps_range_start:
71101+
description: Gaps range start, valid only when query is provided
71102+
type: string
7106171103
ids:
7106271104
description: Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
7106371105
items:

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ export const BulkActionBase = z.object({
113113
* Array of rule IDs. Array of rule IDs to which a bulk action will be applied. Only valid when query property is undefined.
114114
*/
115115
ids: z.array(z.string()).min(1).optional(),
116+
/**
117+
* Gaps range start, valid only when query is provided
118+
*/
119+
gaps_range_start: z.string().optional(),
120+
/**
121+
* Gaps range end, valid only when query is provided
122+
*/
123+
gaps_range_end: z.string().optional(),
116124
});
117125

118126
export type BulkDeleteRules = z.infer<typeof BulkDeleteRules>;

x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,12 @@ components:
11461146
minItems: 1
11471147
items:
11481148
type: string
1149+
gaps_range_start:
1150+
description: Gaps range start, valid only when query is provided
1151+
type: string
1152+
gaps_range_end:
1153+
description: Gaps range end, valid only when query is provided
1154+
type: string
11491155

11501156
BulkDeleteRules:
11511157
allOf:

x-pack/solutions/security/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4696,6 +4696,12 @@ components:
46964696
enum:
46974697
- delete
46984698
type: string
4699+
gaps_range_end:
4700+
description: Gaps range end, valid only when query is provided
4701+
type: string
4702+
gaps_range_start:
4703+
description: Gaps range start, valid only when query is provided
4704+
type: string
46994705
ids:
47004706
description: >-
47014707
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4716,6 +4722,12 @@ components:
47164722
enum:
47174723
- disable
47184724
type: string
4725+
gaps_range_end:
4726+
description: Gaps range end, valid only when query is provided
4727+
type: string
4728+
gaps_range_start:
4729+
description: Gaps range start, valid only when query is provided
4730+
type: string
47194731
ids:
47204732
description: >-
47214733
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4749,6 +4761,12 @@ components:
47494761
required:
47504762
- include_exceptions
47514763
- include_expired_exceptions
4764+
gaps_range_end:
4765+
description: Gaps range end, valid only when query is provided
4766+
type: string
4767+
gaps_range_start:
4768+
description: Gaps range start, valid only when query is provided
4769+
type: string
47524770
ids:
47534771
description: >-
47544772
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4849,6 +4867,12 @@ components:
48494867
$ref: '#/components/schemas/BulkActionEditPayload'
48504868
minItems: 1
48514869
type: array
4870+
gaps_range_end:
4871+
description: Gaps range end, valid only when query is provided
4872+
type: string
4873+
gaps_range_start:
4874+
description: Gaps range start, valid only when query is provided
4875+
type: string
48524876
ids:
48534877
description: >-
48544878
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4874,6 +4898,12 @@ components:
48744898
enum:
48754899
- enable
48764900
type: string
4901+
gaps_range_end:
4902+
description: Gaps range end, valid only when query is provided
4903+
type: string
4904+
gaps_range_start:
4905+
description: Gaps range start, valid only when query is provided
4906+
type: string
48774907
ids:
48784908
description: >-
48794909
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4896,6 +4926,12 @@ components:
48964926
enum:
48974927
- export
48984928
type: string
4929+
gaps_range_end:
4930+
description: Gaps range end, valid only when query is provided
4931+
type: string
4932+
gaps_range_start:
4933+
description: Gaps range start, valid only when query is provided
4934+
type: string
48994935
ids:
49004936
description: >-
49014937
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4916,6 +4952,12 @@ components:
49164952
enum:
49174953
- run
49184954
type: string
4955+
gaps_range_end:
4956+
description: Gaps range end, valid only when query is provided
4957+
type: string
4958+
gaps_range_start:
4959+
description: Gaps range start, valid only when query is provided
4960+
type: string
49194961
ids:
49204962
description: >-
49214963
Array of rule IDs. Array of rule IDs to which a bulk action will be

x-pack/solutions/security/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,6 +4026,12 @@ components:
40264026
enum:
40274027
- delete
40284028
type: string
4029+
gaps_range_end:
4030+
description: Gaps range end, valid only when query is provided
4031+
type: string
4032+
gaps_range_start:
4033+
description: Gaps range start, valid only when query is provided
4034+
type: string
40294035
ids:
40304036
description: >-
40314037
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4046,6 +4052,12 @@ components:
40464052
enum:
40474053
- disable
40484054
type: string
4055+
gaps_range_end:
4056+
description: Gaps range end, valid only when query is provided
4057+
type: string
4058+
gaps_range_start:
4059+
description: Gaps range start, valid only when query is provided
4060+
type: string
40494061
ids:
40504062
description: >-
40514063
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4079,6 +4091,12 @@ components:
40794091
required:
40804092
- include_exceptions
40814093
- include_expired_exceptions
4094+
gaps_range_end:
4095+
description: Gaps range end, valid only when query is provided
4096+
type: string
4097+
gaps_range_start:
4098+
description: Gaps range start, valid only when query is provided
4099+
type: string
40824100
ids:
40834101
description: >-
40844102
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4179,6 +4197,12 @@ components:
41794197
$ref: '#/components/schemas/BulkActionEditPayload'
41804198
minItems: 1
41814199
type: array
4200+
gaps_range_end:
4201+
description: Gaps range end, valid only when query is provided
4202+
type: string
4203+
gaps_range_start:
4204+
description: Gaps range start, valid only when query is provided
4205+
type: string
41824206
ids:
41834207
description: >-
41844208
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4204,6 +4228,12 @@ components:
42044228
enum:
42054229
- enable
42064230
type: string
4231+
gaps_range_end:
4232+
description: Gaps range end, valid only when query is provided
4233+
type: string
4234+
gaps_range_start:
4235+
description: Gaps range start, valid only when query is provided
4236+
type: string
42074237
ids:
42084238
description: >-
42094239
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4226,6 +4256,12 @@ components:
42264256
enum:
42274257
- export
42284258
type: string
4259+
gaps_range_end:
4260+
description: Gaps range end, valid only when query is provided
4261+
type: string
4262+
gaps_range_start:
4263+
description: Gaps range start, valid only when query is provided
4264+
type: string
42294265
ids:
42304266
description: >-
42314267
Array of rule IDs. Array of rule IDs to which a bulk action will be
@@ -4246,6 +4282,12 @@ components:
42464282
enum:
42474283
- run
42484284
type: string
4285+
gaps_range_end:
4286+
description: Gaps range end, valid only when query is provided
4287+
type: string
4288+
gaps_range_start:
4289+
description: Gaps range start, valid only when query is provided
4290+
type: string
42494291
ids:
42504292
description: >-
42514293
Array of rule IDs. Array of rule IDs to which a bulk action will be

0 commit comments

Comments
 (0)