Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Detections]Adds dry_run mode description to _bulk_action API #2210

Merged
merged 28 commits into from
Aug 2, 2022
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
97f2dce
initial commit
vitaliidm Jul 20, 2022
69195ab
add dry_run example
vitaliidm Jul 20, 2022
275431d
change wording
vitaliidm Jul 20, 2022
dca2da2
change wording
vitaliidm Jul 20, 2022
479742f
wording
vitaliidm Jul 20, 2022
2a66070
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
fba91f9
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
e914eaf
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
da18a4a
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
85119dd
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
8eba79e
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
6be88f7
fix wording
vitaliidm Jul 27, 2022
b689dc1
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
a279400
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
565b387
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
ca8fe77
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 27, 2022
7cddabe
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 28, 2022
0092e1d
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 28, 2022
bc75693
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 28, 2022
592ff23
wording
vitaliidm Jul 28, 2022
8dd02c6
more wroding
vitaliidm Jul 28, 2022
4ccd462
wording changeds
vitaliidm Jul 28, 2022
0a610d2
400 error
vitaliidm Jul 28, 2022
6c2c4e1
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 29, 2022
e6d1a69
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 29, 2022
528a072
Merge branch 'main' into bulk_action_dry_run
vitaliidm Jul 29, 2022
2bee3f4
Update docs/detections/api/rules/rules-api-bulk-actions.asciidoc
vitaliidm Jul 29, 2022
90f4235
Merge branch 'main' into bulk_action_dry_run
vitaliidm Aug 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions docs/detections/api/rules/rules-api-bulk-actions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ Applies a bulk action to multiple rules. The bulk action is applied to all rules

`POST <kibana host>:<port>/api/detection_engine/rules/_bulk_action`

[discrete]
===== URL query parameters

[width="100%",options="header"]
|==============================================
|Name |Type |Description |Required

|`dry_run` |Boolean | Enables <<bulk-actions-rules-api-dry-run, dry run mode>> for the request call.
|No
|==============================================

[discrete]
===== Request body

Expand Down Expand Up @@ -265,6 +276,15 @@ to apply.
Yes, if action is `edit`.
|==============================================

[[bulk-actions-rules-api-dry-run]]
[discrete]
==== Dry run mode
Enable dry run mode to verify that bulk actions can be applied to specified rules. Certain rules, such as prebuilt Elastic rules, can't be edited and will return errors in the request response. Error details will contain an explanation, the rule name and/or ID, and additional troubleshooting information.

To enable dry run mode on a request, add the query parameter `dry_run=true` to the end of the request URL. Rules specified in the request will be temporarily updated. These updates won't be written to {es}.


IMPORTANT: Dry run mode is not supported for the `export` bulk action. A `400` error will be returned in the request response.

[[bulk-edit-object-schema]]
[discrete]
Expand Down Expand Up @@ -581,3 +601,84 @@ If processing of any rule fails, a partial error outputs the ID and/or name of t
--------------------------------------------------

<1> dev:[] `execution_summary` is under development and its schema may change.

*Example 3, Dry run*

The following request will validate that the `add_index_patterns` bulk action can be successfully applied to three rules. Each rule (specified by its rule ID) is different: one is a prebuilt Elastic rule, another is a custom machine learning rule, and another is a custom query rule. Because dry run mode is enabled, changes to these rules will not be permanent or saved to {es}.


[source,console]
--------------------------------------------------
POST api/detection_engine/rules/_bulk_action?dry_run=true
{
"action": "edit",
"edit": [
{
"value": [
"test-*"
],
"type": "add_index_patterns"
}
],
"ids": ["81aa0480-06af-11ed-94fb-dd1a0597d8d2", "dc015d10-0831-11ed-ac8b-05a222bd8d4a", "de8f5af0-0831-11ed-ac8b-05a222bd8d4a"]
}
--------------------------------------------------

[discrete]
===== Response code

`500`::
Indicates a partial bulk action failure.

[discrete]
===== Response payload

The `attributes.errors` section of the response shows that two rules failed to update and one succeeded. The same results would be returned if you ran the request without dry run mode enabled.
Notice that there are no arrays in `attributes.results`. In dry run mode, rule updates are not applied and saved to {es}, so the endpoint wouldn't return results for rules that have been `updated`, `created`, or `deleted`.

[discrete]
===== Response body

[source,json]
--------------------------------------------------
{
"message": "Bulk edit partially failed",
"status_code": 500,
"attributes": {
"errors": [
{
"message": "Elastic rule can't be edited",
"status_code": 500,
"err_code": "IMMUTABLE",
"rules": [
{
"id": "81aa0480-06af-11ed-94fb-dd1a0597d8d2",
"name": "Unusual AWS Command for a User"
}
]
},
{
"message": "Machine learning rule doesn't have index patterns",
"status_code": 500,
"err_code": "MACHINE_LEARNING_INDEX_PATTERN",
"rules": [
{
"id": "dc015d10-0831-11ed-ac8b-05a222bd8d4a",
"name": "Suspicious Powershell Script [Duplicate]"
}
]
}
],
"results": {
"updated": [],
"created": [],
"deleted": []
},
"summary": {
"failed": 2,
"succeeded": 1,
"total": 3
}
}
}
--------------------------------------------------