Debian Codegraph @

ansible_collections/splunk/es/plugins/modules/splunk_finding_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright 2026 Red Hat Inc.
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7
8 DOCUMENTATION = """
9 ---
10 module: splunk_finding_info
11 short_description: Gather information about Splunk Enterprise Security Findings
12 description:
13 - This module allows for querying information about Splunk Enterprise Security Findings.
14 - Use this module to retrieve finding configurations without making changes.
15 - Query by C(ref_id) to fetch a specific finding. Without C(earliest) and C(latest).
16 - Query by C(title) to filter findings by exact title match.
17 - Use C(earliest) and C(latest) to control the time range of returned findings.
18 - By default, if C(earliest) and C(latest) are not specified, findings from the last 24 hours are returned.
19 - This default time (24 hours) range applies when querying by C(title) or all findings (not by C(ref_id)).
20 - This module uses the httpapi connection plugin and does not require local Splunk SDK.
21 version_added: "5.1.0"
22 options:
23 ref_id:
24 description:
25 - Reference ID (finding ID) to query a specific finding.
26 - If specified, returns only the finding with this ID.
27 - Takes precedence over C(title) if both are provided.
28 - The time is automatically extracted from the ref_id (format uuid@@notable@@time{timestamp}).
29 - When querying by ref_id, the C(earliest) and C(latest) parameters are ignored.
30 required: false
31 type: str
32 title:
33 description:
34 - Title name to filter findings.
35 - Returns all findings with an exact title match.
36 - Ignored if C(ref_id) is provided.
37 - The C(earliest) and C(latest) time filters still apply when querying by title.
38 required: false
39 type: str
40 earliest:
41 description:
42 - The earliest time for findings to return.
43 - All findings returned have a _time greater than or equal to this value.
44 - Accepts relative time (e.g. C(-30m), C(-7d), C(-1w)), epoch time, or ISO 8601 time.
45 - If not provided, defaults to the last 24 hours (C(-24h)).
46 - Ignored when querying by C(ref_id) (time is extracted from ref_id automatically).
47 - Applies when querying by C(title) or all findings.
48 required: false
49 type: str
50 latest:
51 description:
52 - The latest time for findings to return.
53 - All findings returned have a _time less than or equal to this value.
54 - Accepts relative time (e.g. C(-30m), C(now)), epoch time, or ISO 8601 time.
55 - If not provided, defaults to the current time (C(now)).
56 - Ignored when querying by C(ref_id) (time is extracted from ref_id automatically).
57 - Applies when querying by C(title) or all findings.
58 required: false
59 type: str
60 limit:
61 description:
62 - Maximum number of findings to return.
63 - If not specified, all matching findings are returned.
64 - Use this to limit large result sets.
65 required: false
66 type: int
67 api_namespace:
68 description:
69 - The namespace portion of the Splunk API path.
70 - Override this if your environment uses a different namespace.
71 type: str
72 default: servicesNS
73 api_user:
74 description:
75 - The user portion of the Splunk API path.
76 - Override this if your environment requires a different user context.
77 type: str
78 default: nobody
79 api_app:
80 description:
81 - The app portion of the Splunk API path for the findings endpoint.
82 - Override this if your environment uses a different app name.
83 type: str
84 default: SplunkEnterpriseSecuritySuite
85
86 author: Ron Gershburg (@rgershbu)
87 """
88
89 EXAMPLES = """
90 - name: Query specific finding by ref_id (time extracted automatically from ref_id)
91 splunk.es.splunk_finding_info:
92 ref_id: "abc-123-def-456@@notable@@time1234567890"
93 register: result
94
95 - name: Display the finding info
96 debug:
97 var: result.findings
98
99 - name: Query findings by title (from last 24 hours by default)
100 splunk.es.splunk_finding_info:
101 title: "Suspicious Login Activity"
102 register: result
103
104 - name: Query findings by title from the last 7 days
105 splunk.es.splunk_finding_info:
106 title: "Suspicious Login Activity"
107 earliest: "-7d"
108 register: result
109
110 - name: Display findings with matching title
111 debug:
112 var: result.findings
113
114 - name: Query all findings (from last 24 hours by default)
115 splunk.es.splunk_finding_info:
116 register: all_findings
117
118 - name: Display all findings
119 debug:
120 var: all_findings.findings
121
122 - name: Query all findings from the last 7 days
123 splunk.es.splunk_finding_info:
124 earliest: "-7d"
125 latest: "now"
126 register: all_findings
127
128 - name: Query all findings from the last 30 days
129 splunk.es.splunk_finding_info:
130 earliest: "-30d"
131 register: all_findings
132
133 - name: Query findings with a limit on results
134 splunk.es.splunk_finding_info:
135 earliest: "-7d"
136 limit: 100
137 register: limited_findings
138
139 - name: Query findings from a specific time range (ISO 8601)
140 splunk.es.splunk_finding_info:
141 earliest: "2026-01-01T00:00:00"
142 latest: "2026-01-07T23:59:59"
143 register: all_findings
144
145 - name: Filter findings by status using Jinja2
146 splunk.es.splunk_finding_info:
147 earliest: "-7d"
148 register: all_findings
149
150 # Query findings with custom API path (for non-standard environments)
151 - name: Query findings with custom API path
152 splunk.es.splunk_finding_info:
153 earliest: "-7d"
154 api_namespace: "{{ es_namespace | default('servicesNS') }}"
155 api_user: "{{ es_user | default('nobody') }}"
156 api_app: "{{ es_app | default('SplunkEnterpriseSecuritySuite') }}"
157 register: custom_findings
158 """
159
160 RETURN = """
161 findings:
162 description: List of findings matching the query
163 returned: always
164 type: list
165 elements: dict
166 contains:
167 ref_id:
168 description: The unique reference ID of the finding
169 type: str
170 title:
171 description: Title of the finding
172 type: str
173 description:
174 description: Description of the finding
175 type: str
176 security_domain:
177 description: Security domain of the finding
178 type: str
179 entity:
180 description: The risk object (entity) associated with the finding
181 type: str
182 entity_type:
183 description: Type of the risk object (user or system)
184 type: str
185 finding_score:
186 description: Risk score of the finding
187 type: int
188 owner:
189 description: Owner of the finding
190 type: str
191 status:
192 description: Status of the finding
193 type: str
194 urgency:
195 description: Urgency level of the finding
196 type: str
197 disposition:
198 description: Disposition of the finding
199 type: str
200 sample:
201 - ref_id: "abc-123-def-456"
202 title: "Suspicious Login Activity"
203 description: "Multiple failed login attempts detected"
204 security_domain: "access"
205 entity: "testuser"
206 entity_type: "user"
207 finding_score: 50
208 owner: "admin"
209 status: "new"
210 urgency: "high"
211 disposition: "undetermined"
212 """