Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit ae24646

Browse files
committed
add timeout to requests.post calls to avoid hanging process
1 parent 71d7ec7 commit ae24646

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

loggers/elasticsearch/honeypy_elasticsearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def post_elasticsearch(useragent, url, date, time, date_time, millisecond, sessi
4242
}
4343

4444
try:
45-
r = requests.post(url, headers=headers, json=data)
45+
r = requests.post(url, headers=headers, json=data, timeout=3)
4646
page = r.text
4747

4848
log.msg('Post event to elasticsearch, response: %s' % (str(page).strip()))

loggers/slack/honeypy_slack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def post_slack(honeypycfg, service, clientip):
1515
data = '{"text": "' + honeypycfg.get('honeypy', 'nodename') + ': Possible *' + service + '* attack from ' + clientip + ' <https://riskdiscovery.com/honeydb/#host/' + clientip + '>"}'
1616

1717
url = honeypycfg.get('slack', 'webhook_url')
18-
r = requests.post(url, headers=headers, data=data)
18+
r = requests.post(url, headers=headers, data=data, timeout=3)
1919

2020
if r.status_code != requests.codes.ok:
2121
log.msg('Error posting to Slack: %s' % str(r.status_code))

loggers/splunk/honeypy_splunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def post_splunk(username, password, useragent, url, date, time, date_time, milli
3939
}
4040

4141
try:
42-
r = requests.post(url, headers=headers, data=data, auth=(username, password), verify=False)
42+
r = requests.post(url, headers=headers, data=data, auth=(username, password), verify=False, timeout=3)
4343
page = r.text
4444

4545
log.msg('Post event to splunk, response: %s' % (str(page).strip()))

0 commit comments

Comments
 (0)