Contents
Playbook algorithm
Kaspersky Next XDR Expert allows you to respond to alerts and incidents manually or automatically by using playbooks. Responding to alerts or incidents may consist not of a single action, but of a whole set of steps and parameters. These steps depend on the specified conditions, the alert or incident data, and the results of previous response actions.
The playbook algorithm allows you to specify the sequence of response actions, the necessary conditions and the required impact on the target objects in the JSON format. The playbook algorithm steps are performed sequentially, one step after another. You can specify the playbook algorithm when creating or editing a playbook.
After launch, the playbook obtains all the alert or incident data and places them in global data. The playbook uses the following data:
- Global data.
Global data is readable at any step of the playbook. Global data contains information about the alert or incident for which the playbook was launched.
You cannot edit global data by using a playbook, or by changing alert or incident data. Global data remains unchanged for the entire lifetime of the playbook instance.
- Operational data.
Operational data is transferred between the steps of the playbook. You can manage operational data by using jq expressions, which are specified in the
input
andoutput
parameters. - Local data.
Local data is limited to a specific step. You can manage local data by using the
input
(local data generation) andoutput
(generation of operational data from local data) parameters.
How to write an algorithm
The playbook algorithm is written in JSON format and consists of two main parts:
- General information on playbook:
- Name (
name
) - Description (
description
) - Scope (
inputType
) - Transformation of the input data of the playbook (
input
) - Transformation of the output data of the playbook (
output
) - Playbook execution timeout (
playbookRunTimeout
) - Timeout policies that can be applied at specific steps (
timeouts
) - Playbook version (
version
) - DSL schema version (
dslSpecVersion
) - Response action schema version (
responseActionsSpecVersion
)
- Name (
- Playbook execution steps (
executionFlow
).
The following parameters are required when writing the algorithm:
name
inputType
dslSpecVersion
. The required value: 1.0.0.responseActionsSpecVersion
version
executionFlow
(at least one execution step)Each execution step has its own required fields.
If you try to save a playbook without filling in the required fields, an error will appear.
The playbook algorithm is case sensitive. To use the asset data of the alert, you need to capitalize the Assets
parameter. For example: alert.Assets[]
. However, to use asset data in the input data when manually launching the playbook for target objects, do not capitalize the assets
parameter. For example: .input.assets[]
.
Depending on the scope you selected when creating or editing a playbook, you can use alert data model or incident data model in the algorithm. To do that, write expressions in the jq language with an alert
or incident
value (do not use dot ".
" at the beginning of the value). For example:
"${[ alert.Assets[] | select(.Type == \"user\" and .IsAttacker) | .ID]}"
You can use alert or incident data in a jq expression at any execution step. The alert or incident data is only available in read mode. This data does not change during the operation of the playbook. If alert or incident data has changed after launching the playbook, it will not affect the playbook execution.
You also can use the jq expressions when use the playbook data in the algorithm. For more information about jq expressions, refer to jq Manual.
If you use quotation marks in the jq expression, you need to escape these marks with backslashes. For example: "${[ alert.Assets[] | select(.Type == \"user\" and .IsAttacker) | .ID]}"
.
Backslashes that are not used to escape quotation marks must also be escaped by other backslashes. For example: ${\"add_firewall_rule --ip_address=\" + ([.input.observables[] | select(.type == \"ip\") | select(.value | test(\"^(10\\\\.|172\\\\.(1[6-9]|2[0-9]|3[01])\\\\.|192\\\\.168\\\\.|127\\\\.).*\") | not) | .value] | join(\",\"))}.
If you want to launch the playbook for the specific object (observables or assets), use the .input
parameter in the algorithm. These objects will be the input to the playbook when it is launched. For example:
"assets": "${ [.input.assets[] | select(.Type == \"host\") | .ID] }"
For details, refer to Launching playbooks for objects specified by users.
How to call hints
If you need a hint on the available fields when writing the algorithm, use quotation marks (""
). A list of available fields appears.
To display hints on the alert or incident data, write alert
or incident
in the jq expression with a dot ".
" at the end.
The correct hint appears if there are no errors in the above expressions. Otherwise, the list of available fields may be incorrect.
Example of the playbook algorithm
Playbook parameters
Parameter ID |
Description |
|
Playbook name. Specified by the system when creating or updating a playbook. If the value is set in the algorithm, it will be replaced by the system. |
|
Playbook description. Specified by the system when creating or updating a playbook. If the value is set in the algorithm, it will be replaced by the system. |
|
Playbook version. The minimum length is 1. This parameter is required. |
|
DSL schema version. The minimum length is 1. This parameter is required. |
|
Response actions schema version. The minimum length is 1. This parameter is required. |
|
The maximum execution time of the playbook, including waiting in the queue. The maximum value is 48 hours ( By default, the value is |
|
Inbound object type. The possible values: |
|
A jq expression that could be used to transform or filter incoming data before executing a playbook. |
|
A jq expression that could be used to modify the output of the playbook before execution. |
|
Timeout definitions. |
|
Steps of the playbook execution. This parameter is required. |
Execution step parameters
The array of execution step elements describes a playbook's logic. The execution steps are performed in the order described in the playbook. There are several types of execution steps:
- ResponseAction
- Split
- Scatter-gather
- Switch
- UpdateData
ResponseAction parameters
The Response action parameters call the response function.
Parameter ID |
Description |
|
An object that defines a response action. For more information, refer to ResponseFunction parameters. |
|
This parameter allows you to filter components to perform a response action. When requested, the component plug-ins are filtered by allowed and restricted components. For example, the parameter can be specified as follows: "filterProduct": {
"allowed": ["PRODUCT_NAME"]
}
|
|
This parameter allows you to edit the value returned by the response action, by using a jq expression and placing it in the playbook data (local or operational). |
|
This parameter allows you to set timeouts for calling the response function. You can specify the name of the timeout policy set in the playbook or set timeout values manually. If the value is not specified, the default timeout is applied. |
|
This parameter allows you to configure a manual approval of a response action. Possible values:
|
|
This parameter defines the behavior when an error occurs during the execution of a response action. Possible values:
By default, the value is Note that, if a system error occurs, the playbook execution completes with an error regardless of the specified value of the |
Timeout policy
The timeout policy of execution steps. The system automatically determines the default timeout policy.
The default timeout policy can be reconfigured by using the default policy name. In this case, the new policy will be automatically applied to all execution steps.
Parameter ID |
Description |
|
Timeout policy name. |
|
The maximum execution time, including waiting in the queue and retries. The parameter is specified in the Go string format. If the value is not specified or 0, the value from the |
Output
The output parameter generates operational data at the end of a step, which will then be transferred to the next step. Specify the output
parameter if you want to use the results of the current step of the playbook in the next step.
To avoid overloading the system, it is recommended to limit the data placed in the playbook data (local or operational).
Parameter ID |
Description |
|
This parameter defines whether the playbook data (local or operational) will be overwritten or merged. Possible values:
|
|
This parameter defines the jq expression for processing output data. |
Manual approve
Parameter ID |
Description |
|
The timeout for manual approval in minutes. The minimum value is 10 minutes ( By default, the value is 60 minutes ( |
|
This parameter allows you to configure the sending of email notifications. |
Email notification settings
Parameter ID |
Description |
|
Flag for enabling email notifications. |
|
This parameter defines the delay before sending the email notification. The value is specified in minutes. The minimum value is 5 minutes ( By default, the value is 10 minutes ( |
Split
Before specifying the split
parameter, make sure that the aggregate
parameter is also specified in the playbook algorithm.
The split parameters are used to split the array of incoming data by elements and to perform various actions on the elements.
Parameter ID |
Description |
|
A jq expression for composing an array or referencing an array. |
|
This parameter allows you to configure aggregation rules by using a jq expression. |
|
Configuring how to apply the output data to the current playbook data. Possible values:
|
|
Split operation mode. Possible values:
By default, the value is |
|
This parameter allows you to specify the number of array elements that will be processed in one loop or one parallel thread. You can use this parameter if the plug-in function limits the number of input elements. For example, if a plug-in function can handle no more than 10 elements in one loop, you can specify the following parameter value: By default, the value is |
|
This parameter defines the behavior when an error occurs in one of the branches. Possible values:
By default, the value is |
|
Array of execution steps. |
Scatter-gather
Before specifying the scatter-gather
parameter, make sure that the aggregate
parameter is also specified in the playbook algorithm.
The Scatter-gather parameters are used to perform several actions on the data at the same time. Unlike Split, Scatter-gather transmits the same input data to different execution branches.
Parameter ID |
Description |
|
A jq expression for composing an array. |
|
This parameter allows you to configure aggregation rules by using a jq expression. |
|
Configuring how to apply the output data to the current playbook data. Possible values:
|
|
This parameter defines the behavior when an error occurs in one of the branches. Possible values:
By default, the value is |
|
Execution branches. |
Branch
Parameter ID |
Description |
|
The name of the branch that is unique within Scatter-gather. |
|
Array of execution steps. |
Switch
An execution step that allows you to perform a step or set of steps according to a condition. Note that only the first verified condition will be executed.
Parameter ID |
Description |
|
Array of conditions. |
Condition
Parameter ID |
Description |
|
A jq expression that contains execution conditions. |
|
Execution steps for the current branch. |
UpdateData
The UpdateData parameter can be described either as a jq script with state change logic, or as an Output
object.
ResponseFunction parameters
Parameter ID |
Description |
|
Response action name. |
|
The parameter allows you to describe the parameters of a response action you want to launch. You can specify the parameter as a jq expression or as an object. Parameters of the response actions are described in the table below. |
|
The parameter allows you to use a jq expression or string array to specify a list of assets for which you want to launch a response action. The |
Response action parameters
Response action name |
Parameters |
|
Update databases response action. Possible parameters:
To launch this response action, you need to specify the |
|
Run malware scan response action. Possible parameters:
To launch this response action, you need to specify the |
|
Move to group response action. Possible parameters:
To launch this response action, you need to specify the |
|
Move to quarantine response action. Possible parameters:
You can specify the response action parameters in one of the following ways:
To launch this response action, you need to specify the |
|
Terminate process response action. Possible parameters:
To launch this response action, you need to specify the |
|
Change authorization status response action. Possible parameter:
To launch this response action, you need to specify the |
|
Enable network isolation response action. Possible parameters:
|
|
Disable network isolation response action. To launch this response action, you need to specify the |
|
Run executable file response action. Possible parameters:
To launch this response action, you need to specify the |
|
Add prevention rule response action. Possible parameters:
To launch this response action, you need to specify the |
|
Delete prevention rule response action. Possible parameters:
To launch this response action, you need to specify the |
|
Delete all prevention rules. To launch this response action, you need to specify the |
|
Assign KASAP group response action. Possible parameters:
To launch this response action, you need to specify the |
|
Add user to security group response action. Possible parameters:
To launch this response action, you need to specify the |
|
Delete user from security group response action. Possible parameters:
To launch this response action, you need to specify the |
|
Lock account response action. To launch this response action, you need to specify the |
|
Reset password response action. To launch this response action, you need to specify the |
|
Execution of custom scripts. Possible parameters:
|
|
Data enrichment. Possible parameters:
|