| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright 2026 Red Hat |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = """ |
| 8 |
--- |
| 9 |
module: splunk_finding |
| 10 |
short_description: Manage Splunk Enterprise Security findings |
| 11 |
description: |
| 12 |
- This module allows for creation and update of Splunk Enterprise Security findings. |
| 13 |
- When C(ref_id) is not provided, a new finding is always created (no idempotency check). |
| 14 |
- When C(ref_id) is provided, the module will check if the finding exists and update it. |
| 15 |
- Update operations use a different API endpoint and only support updating C(owner), C(status), C(urgency), and C(disposition). |
| 16 |
- Tested against Splunk Enterprise Server with Splunk Enterprise Security installed. |
| 17 |
version_added: "5.1.0" |
| 18 |
options: |
| 19 |
ref_id: |
| 20 |
description: |
| 21 |
- Reference ID (finding ID / event_id) of an existing finding. |
| 22 |
- Format is typically C(uuid@@notable@@time{timestamp}) (e.g., C(2008e99d-af14-4fec-89da-b9b17a81820a@@notable@@time1768225865)). |
| 23 |
- If provided, the module will verify the finding exists and update it. |
| 24 |
- If not provided, a new finding is created. |
| 25 |
- When updating, only C(owner), C(status), C(urgency), and C(disposition) can be modified. |
| 26 |
type: str |
| 27 |
title: |
| 28 |
description: |
| 29 |
- Title of the finding. |
| 30 |
- Required when creating a new finding (without C(ref_id)). |
| 31 |
type: str |
| 32 |
description: |
| 33 |
description: |
| 34 |
- Description of the finding. |
| 35 |
- Required when creating a new finding. |
| 36 |
type: str |
| 37 |
security_domain: |
| 38 |
description: |
| 39 |
- Security domain for the finding. |
| 40 |
- Required when creating a new finding. |
| 41 |
type: str |
| 42 |
choices: |
| 43 |
- access |
| 44 |
- endpoint |
| 45 |
- network |
| 46 |
- threat |
| 47 |
- identity |
| 48 |
- audit |
| 49 |
entity: |
| 50 |
description: |
| 51 |
- The risk object (entity) associated with the finding. |
| 52 |
- Required when creating a new finding. |
| 53 |
type: str |
| 54 |
entity_type: |
| 55 |
description: |
| 56 |
- The type of the risk object (entity). |
| 57 |
- Required when creating a new finding. |
| 58 |
type: str |
| 59 |
choices: |
| 60 |
- user |
| 61 |
- system |
| 62 |
finding_score: |
| 63 |
description: |
| 64 |
- The risk score for the finding. |
| 65 |
- Required when creating a new finding. |
| 66 |
type: int |
| 67 |
owner: |
| 68 |
description: |
| 69 |
- Owner of the finding. |
| 70 |
- Use C(admin) for the administrator user. |
| 71 |
- Use C(unassigned) to leave the finding unassigned. |
| 72 |
- Can be updated on existing findings. |
| 73 |
type: str |
| 74 |
status: |
| 75 |
description: |
| 76 |
- Status of the finding. |
| 77 |
- Can be updated on existing findings. |
| 78 |
type: str |
| 79 |
choices: |
| 80 |
- unassigned |
| 81 |
- new |
| 82 |
- in_progress |
| 83 |
- pending |
| 84 |
- resolved |
| 85 |
- closed |
| 86 |
urgency: |
| 87 |
description: |
| 88 |
- Urgency level of the finding. |
| 89 |
- Can be updated on existing findings. |
| 90 |
type: str |
| 91 |
choices: |
| 92 |
- informational |
| 93 |
- low |
| 94 |
- medium |
| 95 |
- high |
| 96 |
- critical |
| 97 |
disposition: |
| 98 |
description: |
| 99 |
- Disposition of the finding. |
| 100 |
- Can be updated on existing findings. |
| 101 |
type: str |
| 102 |
choices: |
| 103 |
- unassigned |
| 104 |
- true_positive |
| 105 |
- benign_positive |
| 106 |
- false_positive |
| 107 |
- false_positive_inaccurate_data |
| 108 |
- other |
| 109 |
- undetermined |
| 110 |
fields: |
| 111 |
description: |
| 112 |
- List of custom fields to add to the finding. |
| 113 |
- Only used when creating new findings. |
| 114 |
type: list |
| 115 |
elements: dict |
| 116 |
suboptions: |
| 117 |
name: |
| 118 |
description: |
| 119 |
- Name of the custom field. |
| 120 |
type: str |
| 121 |
required: true |
| 122 |
value: |
| 123 |
description: |
| 124 |
- Value of the custom field. |
| 125 |
type: str |
| 126 |
required: true |
| 127 |
api_namespace: |
| 128 |
description: |
| 129 |
- The namespace portion of the Splunk API path. |
| 130 |
- Override this if your environment uses a different namespace. |
| 131 |
type: str |
| 132 |
default: servicesNS |
| 133 |
api_user: |
| 134 |
description: |
| 135 |
- The user portion of the Splunk API path. |
| 136 |
- Override this if your environment requires a different user context. |
| 137 |
type: str |
| 138 |
default: nobody |
| 139 |
api_app: |
| 140 |
description: |
| 141 |
- The app portion of the Splunk API path for the findings endpoint. |
| 142 |
- Override this if your environment uses a different app name. |
| 143 |
type: str |
| 144 |
default: SplunkEnterpriseSecuritySuite |
| 145 |
|
| 146 |
author: Ron Gershburg (@rgershbu) |
| 147 |
""" |
| 148 |
|
| 149 |
EXAMPLES = """ |
| 150 |
# Create a new finding (no ref_id - always creates new) |
| 151 |
- name: Create a finding |
| 152 |
splunk.es.splunk_finding: |
| 153 |
title: "Suspicious Login Activity" |
| 154 |
description: "Multiple failed login attempts detected" |
| 155 |
security_domain: access |
| 156 |
entity: "testuser" |
| 157 |
entity_type: user |
| 158 |
finding_score: 50 |
| 159 |
owner: admin |
| 160 |
status: new |
| 161 |
urgency: high |
| 162 |
disposition: undetermined |
| 163 |
|
| 164 |
# Create a finding with custom fields |
| 165 |
- name: Create a finding with custom fields |
| 166 |
splunk.es.splunk_finding: |
| 167 |
title: "Malware Detection" |
| 168 |
description: "Potential malware detected on endpoint" |
| 169 |
security_domain: endpoint |
| 170 |
entity: "server01" |
| 171 |
entity_type: system |
| 172 |
finding_score: 80 |
| 173 |
owner: admin |
| 174 |
status: new |
| 175 |
urgency: critical |
| 176 |
disposition: true_positive |
| 177 |
fields: |
| 178 |
- name: custom_col_a |
| 179 |
value: "value1" |
| 180 |
- name: custom_col_b |
| 181 |
value: "value2" |
| 182 |
|
| 183 |
# Update an existing finding by ref_id (only owner, status, urgency, disposition can be updated) |
| 184 |
- name: Update finding status |
| 185 |
splunk.es.splunk_finding: |
| 186 |
ref_id: "2008e99d-af14-4fec-89da-b9b17a81820a@@notable@@time1768225865" |
| 187 |
status: resolved |
| 188 |
disposition: true_positive |
| 189 |
|
| 190 |
# Update finding owner |
| 191 |
- name: Assign finding to admin |
| 192 |
splunk.es.splunk_finding: |
| 193 |
ref_id: "2008e99d-af14-4fec-89da-b9b17a81820a@@notable@@time1768225865" |
| 194 |
owner: admin |
| 195 |
|
| 196 |
# Create a finding with custom API path (for non-standard environments) |
| 197 |
- name: Create a finding with custom API path |
| 198 |
splunk.es.splunk_finding: |
| 199 |
title: "Custom Environment Finding" |
| 200 |
description: "Finding created with custom API path" |
| 201 |
security_domain: network |
| 202 |
entity: "firewall01" |
| 203 |
entity_type: system |
| 204 |
finding_score: 60 |
| 205 |
api_namespace: "{{ es_namespace | default('servicesNS') }}" |
| 206 |
api_user: "{{ es_user | default('nobody') }}" |
| 207 |
api_app: "{{ es_app | default('SplunkEnterpriseSecuritySuite') }}" |
| 208 |
""" |
| 209 |
|
| 210 |
RETURN = """ |
| 211 |
finding: |
| 212 |
description: The finding result containing before/after states. |
| 213 |
returned: always |
| 214 |
type: dict |
| 215 |
contains: |
| 216 |
before: |
| 217 |
description: The finding state before module execution (if existed). |
| 218 |
type: dict |
| 219 |
returned: when finding existed |
| 220 |
after: |
| 221 |
description: The finding state after module execution. |
| 222 |
type: dict |
| 223 |
returned: always |
| 224 |
sample: |
| 225 |
before: null |
| 226 |
after: |
| 227 |
title: "Suspicious Login Activity" |
| 228 |
description: "Multiple failed login attempts detected" |
| 229 |
security_domain: "access" |
| 230 |
entity: "testuser" |
| 231 |
entity_type: "user" |
| 232 |
finding_score: 50 |
| 233 |
owner: "admin" |
| 234 |
status: "new" |
| 235 |
urgency: "high" |
| 236 |
disposition: "undetermined" |
| 237 |
changed: |
| 238 |
description: Whether any changes were made. |
| 239 |
returned: always |
| 240 |
type: bool |
| 241 |
sample: true |
| 242 |
msg: |
| 243 |
description: Message describing the result. |
| 244 |
returned: always |
| 245 |
type: str |
| 246 |
sample: "Finding created/updated successfully" |
| 247 |
""" |