Skip to content

Commit 13c7e27

Browse files
authored
update replay script error handling and coldfusion log entry (#1149)
1 parent 66cfe42 commit 13c7e27

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

bin/replay.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,50 @@ def send_data_to_splunk(file_path, splunk_host, hec_token, event_host_uuid,
109109
headers=headers,
110110
verify=False,
111111
)
112-
res.raise_for_status()
113-
print(f":white_check_mark: Sent {file_path} to Splunk HEC")
112+
if res.ok:
113+
print(f":white_check_mark: Sent {file_path} to Splunk HEC")
114+
return
115+
116+
print(
117+
f":x: Error sending {file_path} to Splunk HEC: "
118+
f"HTTP {res.status_code}"
119+
)
120+
121+
try:
122+
response_data = res.json()
123+
hec_code = response_data.get("code")
124+
hec_text = response_data.get("text")
125+
print(f" Splunk HEC response: code={hec_code}, text={hec_text}")
126+
127+
if hec_code == 7:
128+
print(
129+
" Hint: incorrect index. "
130+
"Use --index-override <existing_index> or create attack_data index."
131+
)
132+
elif hec_code == 4:
133+
print(
134+
" Hint: invalid HEC token. "
135+
"Verify SPLUNK_HEC_TOKEN and token status in Splunk."
136+
)
137+
elif hec_code == 6:
138+
print(
139+
" Hint: invalid data format. "
140+
"Check sourcetype/source values and file content."
141+
)
142+
elif hec_code == 10:
143+
print(
144+
" Hint: data channel missing/invalid. "
145+
"Check HEC indexer acknowledgment settings."
146+
)
147+
except ValueError:
148+
print(f" Splunk HEC raw response: {res.text.strip()}")
149+
150+
print(f" URL: {res.url}")
151+
print(
152+
" Metadata: "
153+
f"index={index}, source={source}, sourcetype={sourcetype}, "
154+
f"host={event_host_uuid}"
155+
)
114156
except Exception as e:
115157
print(f":x: Error sending {file_path} to Splunk HEC: {e}")
116158

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d34969d4c57f0b8e5aca752000ecde9a8d58d32c04dee8362f64ac85f0642410
3-
size 349225
2+
oid sha256:421d300cd9e7ef923752e23f0487de20f2280da9fc7a56d3ffc43ece1698a886
3+
size 349743

0 commit comments

Comments
 (0)