Filter and transform data
Filter and transform data in Cortex XSOAR 8.10 On-prem playbooks.
In Cortex XSOAR, data is extracted and collected from various sources, such as playbook tasks, command results, and fetched incidents, and presented in JSON format. The data can be manipulated by using filters and transformers.
Filters
Filters enable you to extract relevant data which you can use elsewhere in Cortex XSOAR. For example, if an incident has several files with varying file types and extensions, you can filter the files by file extension or file type, and use the filtered files in a detonation playbook. You can filter as many objects as required. Cortex XSOAR automatically calculates the context root to which to filter. You can change the context root as necessary.
Caution
You can change the context data root to filter, but it is not recommended to select a different root, as it affects the filter results. The drop-down list displays the filter root for backward compatibility.
Transformers
Transformers modify or format data to make it suitable for further processing or presentation. For example, you can convert a date in non-Unix format to Unix format. Another example is applying the count transformer, which renders the number of elements. When you have more than one transformer, they apply in the order that they appear. You can reorder them using click-and-drag.
Add filters and transformers in a playbook task
Create or edit a playbook task.
In the field you want to add a filter or transformer (for example, inputs or outputs), click the curly brackets and then select Filters and Transformers.
In the Get field, type or select data you want to filter or transform. For example,
EWS.Items.Name.(Optional) To filter the data, do the following.
In the Filter section, click Add filter.
When adding a filter, the context root to filter is automatically populated.
Select the filter operators.
Add the value.
Click the checkbox to save the filter.
(Optional) To apply transformers to the field, click Add transformer.
Click the transformer and select the relevant transformer.
By default, the transformer is set to
To upper case(String). Click it to pick a different transformer, for example to change the date format for when incidents occurred.Select the transformer operators.
Click the tick box to save.
(Optional) To test the filter or transformation click Test and select the investigation or add it manually.
Create custom filters and transformers
If you require a filter or transformer that is not provided out-of-the-box, you can create your own by creating a script and then adding to the operators window.
Select Incident Response → Automation → Scripts → New Automation.
Type a meaningful name for the script, and click Save.
To create a filter operator script, do the following:
In the Tags field, add the
filtertag.If you want a custom transformer that operates on an entire array rather than on each individual item, you need to add the
entirelisttag.In the Arguments section, add the following arguments:
ArgumentDescriptionleft
Mark as mandatory. This argument defines the left-side value of the transformer operation. In this example, this is the value being checked if it falls within the range specified in the right-side value.
right
Mark as mandatory. This argument defines the right-side value of the transformer operation. In this example, this is the range to check if the left-side value is in.
Add the script syntax and save.
To create a transformer operator script do the following:
In the Tags field, add the
transformertag.In the Arguments section, add the following arguments:
ArgumentDescriptionvalue
Mark as mandatory. The value to transform. In this example, this is the UNIX epoch timestamp to convert to ISO format.
Add the script syntax and save.
Go to the filters and transformers window and select the operator.
Filter considerations, categories, and built-in filters
You can use built-in filters to define your filter, they are grouped by category. Before defining a filter, consider the following.
Filter considerations
Filters try to cast the transformed value and arguments to the appropriate type. The task fails if casting fails. For example, “a” Equals {“some”: “object”} => Error
If the filter's left-side value expects a single item but receives a list, the filter passes if at least one item meets the requirements. For example, [“a”, “b”, “c”] Equals “b” => true.
If the filter's left-side value expects a list but receives a single item, it converts it to a list with a single item. For example, “a” Contains “a” => True.
Some custom filters are implemented as scripts with the
filtertag. You can find examples in the playbook automation task description.Filters in conditional tasks do not iterate the items of the root. Instead, they fetch the left-side value and the right-side value and compare them.
Filter categories and built-in filters
When adding a filter, clicking the default Equals (String) field opens a search window showing the available built-in filters. They are defined by category as follows:
Transformer considerations, categories, and built-in transformers
You can use built-in transformers to define your transformer, they are grouped by category. Before defining a transformer, consider the following.
Transformer considerations
Transformers try to cast the transformed value (and arguments) to the necessary type. Tasks will fail if casting has failed, for example
{“some”: “object”}To upper case =>Error.Some transformers are applied on each item of the result. For example,
a, b, cTo upper case =>A, B, C.Some transformers operate on the entire list. For example,
a, b, ccount =>3.Some custom transformers are implemented as scripts with the
transformertag. You can find examples in the playbook automation task description.
Transformer categories and built-in transformers
When adding a transformer, clicking the default To upper case (String) field opens a search window showing the available built-in transformers. They are defined by category as follows.
General
Generic transformers
FIXME_ACCORDION_PLACEHOLDER
String
String transformers
FIXME_ACCORDION_PLACEHOLDER
Number
Number transformers
FIXME_ACCORDION_PLACEHOLDER
Date
Date transformers
FIXME_ACCORDION_PLACEHOLDERFIXME_ACCORDION_PLACEHOLDER
Last updated
Was this helpful?







