Child Workflows
Learn how to combine smaller workflows into a single workflow.
Tracecat comes with unlimited workflows. Whenever possible, we recommend creating smaller, reusable workflows. Each workflow should contain a single, cohesive piece of logic.
Then use a “parent” workflow to orchestrate the execution of multiple child workflows. This design is inspired by AWS Step Functions and AWS Lambda.
Goals
By the end of this tutorial, you will learn:
- When to use child workflows
- How to use the
Execute Child Workflow
action - How to use the
Reshape
action andfilter
function to select items from a list - How to use the
Reshape
action andflatten
function to turn a list of lists into a single list - How to use loop-iteration to execute child workflows in parallel
This tutorial does not implement the full playbook discussed in the scenario. This is left as an exercise to the reader.
Prerequisites
- Completed the Control Flow tutorial
- Completed the Actions Registry tutorial
Tutorial
Scenario: end-to-end alert response
Let’s say you want to automate a playbook that will:
- Receive an alert from your SIEM
- Check if alert is high-severity
- Extract all the URLs from the alert
- Check if each URL is malicious
- Block the IPs that are associated with the malicious URLs
You might be tempted to create a single workflow that contains all of these steps. However, each of these steps is a single, cohesive piece of logic. We recommend creating a child workflow for each step.
Create a orchestrator workflow
Create a new workflow called SIEM alert incident response
.
Filter alerts
Let’s assume that this workflow recieves a list of alerts (JSON objects) from Elastic Security via webhook. We want to filter out any alerts that are not high-severity.
This is easily done using the Reshape
action along with the filter
function.
Rename the Reshape
action to Select high-severity alerts
, then configure the action with the following inputs:
We’re assuming you’ve configured the Elastic Security webhook connectorto send alerts as ndjson with the MIME content-type set as application/x-ndjson
.
Trigger child workflow
Add the Execute Child Workflow
action to the workflow.
Rename the action to Trigger VirusTotal workflow
.
Copy the workflow ID from the VirusTotal workflow created in the Quickstart tutorial and paste it into the action inputs.
Configure child workflow to run once per alert
Every action in Tracecat can be configured with one or more loop-iteration expressions. This allows you to iterate through a list of data and run the same action once per item in the list.
In this case, under the Control Flow tab for the Trigger VirusTotal workflow
action, we can set the loop-iteration config with the following: