Skip to content

Commit 8df4ac8

Browse files
committed
fix: Ingestion failure with double quot in host/source/sourcetype
1 parent c656266 commit 8df4ac8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pytest_splunk_addon/standard_lib/requirement_tests/test_generator.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,15 @@ def generate_cim_req_params(self):
136136
"hec_event",
137137
):
138138
host, source, sourcetype = self.extract_params(event_tag)
139+
host, source, sourcetype = self.escape_host_src_srctype(
140+
host, source, sourcetype
141+
)
139142
modinput_params = {
140143
"host": host,
141144
"source": source,
142145
"sourcetype": sourcetype,
143146
}
147+
144148
else:
145149
# todo: non syslog/modinput events are skipped currently until we support it
146150
continue
@@ -243,6 +247,12 @@ def extract_params(self, event):
243247
source_type = transport.get("sourcetype")
244248
return host, source, source_type
245249

250+
def escape_host_src_srctype(self, host, source, sourcetype):
251+
escaped_host = host.replace('"', '\\"')
252+
escaped_source = source.replace('"', '\\"')
253+
escaped_sourcetype = sourcetype.replace('"', '\\"')
254+
return escaped_host, escaped_source, escaped_sourcetype
255+
246256
def escape_char_event(self, event):
247257
"""
248258
Input: Event getting parsed
@@ -259,7 +269,6 @@ def escape_char_event(self, event):
259269
"%",
260270
"^",
261271
"&",
262-
"*",
263272
"(",
264273
")",
265274
"-",

tests/requirement_test_modinput/sample_requirement_test_modinput.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<version id="13.21" />
66
<event code="" name="EventID_19_WmiEvent_(WmiEventFilter_activity_detected)_Change_All_Changes" format="">
77
<version id="" />
8-
<transport type="modinput" host="sample_host=test" source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" sourcetype="xmlwineventlog"/>
8+
<transport type="modinput" host="sample&quot;test&quot;_host=test" source="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" sourcetype="xmlwineventlog"/>
99
<source>
1010
<jira id="ADDON-35818 , ADDON-35825" />
1111
<comment />

0 commit comments

Comments
 (0)