Splunk Search Jobs Executor¶
Category: SIEM and SOAR
Script: splunk.py
Integration: REST API
Faraday Plugin: Raw JSON
Website: https://www.splunk.com
Description¶
Runs an SPL search on a Splunk Enterprise or Splunk Cloud instance and imports the results into Faraday. Each result row becomes one Faraday vulnerability, prefixed with [SIEM], grouped under a single host that represents the Splunk instance.
Prerequisites¶
- Access to the Splunk management REST API (usually port
8089) - A Splunk authentication token (Settings > Tokens), or a username and password
- A Splunk role allowed to run searches on the indexes your query uses
- The Python
requestspackage in the agent environment
Configuration¶
Environment Variables (Setup)¶
| Variable | Required | Description |
|---|---|---|
SPLUNK_HOST |
Yes | Splunk management URL (e.g., https://splunk.example.com:8089 or https://<stack>.splunkcloud.com:8089) |
SPLUNK_USER |
No* | Splunk username for basic authentication |
SPLUNK_PASSWORD |
No* | Password of SPLUNK_USER |
SPLUNK_TOKEN |
No* | Splunk authentication token. Used instead of the username and password when set. |
* You must set SPLUNK_TOKEN, or both SPLUNK_USER and SPLUNK_PASSWORD.
These variables are also accepted as execution arguments, so a single run can override them.
Execution Arguments¶
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
SPLUNK_SEARCH_QUERY |
string | Yes | SPL query to run (e.g., index=notable severity=high or \| tstats count from datamodel=Network_Traffic). search is prepended when the query does not start with search or \|. |
SPLUNK_EARLIEST |
string | No | Earliest time of the search, as a Splunk time modifier (e.g., -24h, -7d@d, an epoch or an ISO timestamp). Default: Splunk's default time range. |
SPLUNK_LATEST |
string | No | Latest time of the search (e.g., now, @d). Default: Splunk's default time range. |
SPLUNK_MIN_SEVERITY |
string | No | Minimum severity to import: info, low, medium, high or critical (default: info). Splunk synonyms such as informational or warning, and numbers 1–5, are also accepted. |
YAML Configuration Example¶
executors:
splunk:
repo_executor: splunk.py
max_size: 65536
varenvs:
SPLUNK_HOST: "https://splunk.example.com:8089"
SPLUNK_TOKEN: "<splunk_token>"
params:
SPLUNK_SEARCH_QUERY:
mandatory: true
type: string
base: string
SPLUNK_EARLIEST:
mandatory: false
type: string
base: string
SPLUNK_LATEST:
mandatory: false
type: string
base: string
SPLUNK_MIN_SEVERITY:
mandatory: false
type: string
base: string
How It Works¶
- Authenticates with
Authorization: Bearer <SPLUNK_TOKEN>, or with HTTP basic authentication when no token is set - Creates a search job with
POST {SPLUNK_HOST}/services/search/jobs, using the query and time range - Polls
GET /services/search/jobs/{sid}every 2 seconds until the job is done, for up to about 5 minutes - Reads the results from
GET /services/search/jobs/{sid}/results, 100 rows per page - Maps each row to a Faraday vulnerability:
- Name:
[SIEM]plus the row's rule name, signature, title or first line of the message - Severity: the row's
severityfield, or the numericurgency/severity_id/priority(1–5), or a 0–10 score (severity_score,cvss) - Status: the row's
status,event_status,dispositionorstatefield (e.g.,newandin_progressbecome open,resolvedandclosedbecome closed,false_positiveandsuppressedbecome risk-accepted). Rows without status are open. - Description: the row's description or message, key fields (source, destination, user, index, times) and the first 2,000 characters of
_raw - References: CVEs found in the row, the event ID, rule, saved search, index, source and host
- Name:
Notes¶
- The executor creates a single host per run. Its IP is
0.0.0.0and its hostname is the host name ofSPLUNK_HOST, because search results are not tied to an asset. The search, time range and job ID are written in the host description. - Imports at most 20,000 rows (200 pages of 100). Keep the query scoped to the indexes and sourcetypes you need.
- If the job cannot be created, fails or does not finish in about 5 minutes, the run ends with an empty host and the reason is written to the agent log. A
401response stops the run. - Time modifiers that contain newlines or tabs are ignored.
- The shared agent parameters (
AGENT_CONFIG_*tags and severity filters) are not applied by this executor. UseSPLUNK_MIN_SEVERITYto filter by severity.