From 8a519c1d472de053ae76f7900090acabd2cb831a Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Mon, 19 Oct 2026 13:40:12 -0400 Subject: [PATCH 1/2] fetchers: Add request timeouts Prevent get requests from running forever by adding a naive timeout of 5 seconds. --- checks/utils/fetchers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/checks/utils/fetchers.py b/checks/utils/fetchers.py index ca3ad65..fe13e58 100644 --- a/checks/utils/fetchers.py +++ b/checks/utils/fetchers.py @@ -15,7 +15,7 @@ def matchGist(url): def getGist(inputUrl): API_URL = "https://api.github.com" gistId = inputUrl - return requests.get('{0}/gists/{1}'.format(API_URL, gistId)).json() + return requests.get('{0}/gists/{1}'.format(API_URL, gistId), timeout=5).json() def getLinesGist(gistObject): @@ -41,7 +41,7 @@ def matchHaste(url): def getHaste(hasteId): API_URL = "https://hastebin.com" - return requests.get('{0}/documents/{1}'.format(API_URL, hasteId)).json() + return requests.get('{0}/documents/{1}'.format(API_URL, hasteId), timeout=5).json() def getLinesHaste(hasteObject): @@ -63,7 +63,7 @@ def matchObs(url): def getObslog(obsURL, obslogId): - return requests.get('{0}/{1}'.format(obsURL, obslogId)).text + return requests.get('{0}/{1}'.format(obsURL, obslogId), timeout=5).text def getLinesObslog(obslogText): @@ -81,7 +81,7 @@ def matchPastebin(url): def getRawPaste(obslogId): API_URL = "https://pastebin.com/raw" - return requests.get('{0}/{1}'.format(API_URL, obslogId)).text + return requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5).text def getLinesPaste(obslogText): @@ -99,7 +99,7 @@ def matchDiscord(url): def getRawDiscord(obslogId): API_URL = "https://cdn.discordapp.com/attachments" - resp = requests.get('{0}/{1}'.format(API_URL, obslogId)) + resp = requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5) if resp.status_code == 200: return resp.text return "" From c19a38fc6f5c0da9a98fc02fb98d07d2351c70b8 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Mon, 19 Oct 2026 13:57:56 -0400 Subject: [PATCH 2/2] fetchers: Disable redirects when fetching logs Additionally, remove the www. portion of the base URL if it exists to avoid redirects even if they are valid. --- checks/utils/fetchers.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/checks/utils/fetchers.py b/checks/utils/fetchers.py index fe13e58..5bcab0c 100644 --- a/checks/utils/fetchers.py +++ b/checks/utils/fetchers.py @@ -15,7 +15,7 @@ def matchGist(url): def getGist(inputUrl): API_URL = "https://api.github.com" gistId = inputUrl - return requests.get('{0}/gists/{1}'.format(API_URL, gistId), timeout=5).json() + return requests.get('{0}/gists/{1}'.format(API_URL, gistId), timeout=5, allow_redirects=False).json() def getLinesGist(gistObject): @@ -41,7 +41,7 @@ def matchHaste(url): def getHaste(hasteId): API_URL = "https://hastebin.com" - return requests.get('{0}/documents/{1}'.format(API_URL, hasteId), timeout=5).json() + return requests.get('{0}/documents/{1}'.format(API_URL, hasteId), timeout=5, allow_redirects=False).json() def getLinesHaste(hasteObject): @@ -63,7 +63,8 @@ def matchObs(url): def getObslog(obsURL, obslogId): - return requests.get('{0}/{1}'.format(obsURL, obslogId), timeout=5).text + obsURL = obsURL.replace("www.", "") + return requests.get('{0}/{1}'.format(obsURL, obslogId), timeout=5, allow_redirects=False).text def getLinesObslog(obslogText): @@ -81,7 +82,7 @@ def matchPastebin(url): def getRawPaste(obslogId): API_URL = "https://pastebin.com/raw" - return requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5).text + return requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5, allow_redirects=False).text def getLinesPaste(obslogText): @@ -99,7 +100,7 @@ def matchDiscord(url): def getRawDiscord(obslogId): API_URL = "https://cdn.discordapp.com/attachments" - resp = requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5) + resp = requests.get('{0}/{1}'.format(API_URL, obslogId), timeout=5, allow_redirects=False) if resp.status_code == 200: return resp.text return ""