Have a third-party application that sends webhook notifications and want to connect it to TheHive without the hassle of developing, maintaining and hosting a custom “glue-code” script? Then the Functions feature is exactly what you’re looking for!
Functions let you integrate external applications directly into TheHive’s processing.
Security teams usually rely on feeders to integrate data from external applications into their case management platform (i.e., TheHive).
A feeder is essentially a script that runs periodically, needs to be hosted somewhere and must be maintained over time, which can quickly become cumbersome. Feeders typically work in three steps:
- Pull data from a source (such as a SIEM, EDR or ITSM).
- Translate the data from the source format into TheHive format.
- Push the translated data to TheHive’s API.
Let’s see how Functions can free you from these old-fashioned workflows.
Teaching TheHive a new data format
The data source you want to connect to TheHive probably uses its own object format, which often doesn’t match TheHive’s objects.
Let’s take an example with an Elastic alert:
- In the next code section, you can see an extract of an alert in Elastic’s original format, as it’s sent by their webhook.
- After it, you can see the same alert reformatted to match the structure required by TheHive’s API to create an alert from this payload.
"kibana.alert.rule.name": [
"Tor Activity to the Internet"
],
"kibana.alert.rule.threat.technique.reference": [
"https://attack.mitre.org/techniques/T1090/"
],
"host.name": [
"host-29-tokyo-prod-01"
],
"signal.rule.created_at": [
"2024-05-27T10:45:45.060Z"
],
"kibana.alert.workflow_status": [
"open"
],
"kibana.alert.reason": [
"network event with process java, source 192.168.1.201:42202,:9001, by on host-29-tokyo-prod-01 created medium alert Tor Activity to the Internet."
],
"signal.rule.threat.tactic.id": [
"TA0011"
],
"signal.rule.severity": [
"medium"
],...
{
"type": "EDR",
"source": "Elastic",
"sourceRef": "siem-signals-default-000022",
"title": "Tor Activity to the Internet",
"description": "network event with process java, source 192.168.1.201:42202,:9001, by on host-29-tokyo-prod-01 created medium alert Tor Activity to the Internet.",
"severity": 2,
"date": 1721163862000,
"tags": ["TOR"]
"observables": [
{"dataType": "hostname", "data": "host-29-tokyo-prod-01"},
{"dataType": "ip", "data": "192.168.1.201", "description": "source ip"}
]
...
}
Instead of using TheHive’s traditional API routes (which expect data in TheHive’s native format), Functions let you create your own custom API endpoint and map data from any source format (like Elastic) to what TheHive can process. It works just like a translator!
Within TheHive’s Functions, you can write JavaScript code that interprets the incoming payload and calls TheHive’s APIs directly.
To help you create and monitor your Function, TheHive provides several useful modes and options:
- Dry run: Execute the Function without affecting any data in TheHive. It will return a text summary of the actions it would have performed in normal mode.
- Test Function: Provide input directly from TheHive’s GUI to test your Function (in either dry or normal mode). The result is displayed right in the web interface.
- Last success/Last error: Monitor your Function’s activity and identify potential issues for troubleshooting.
Want to learn more about TheHive's Functions?