Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1599 from mozilla/fixup_uptycs_stacktrace
Browse files Browse the repository at this point in the history
Update uptycs cron script to throw stack trace if response is not ok
  • Loading branch information
Phrozyn committed Apr 9, 2020
2 parents 692ac35 + cc0b55e commit d6fd6cb
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cron/uptycs_alertpull.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from datetime import datetime, timedelta

from mozdef_util.utilities.toUTC import toUTC
from mozdef_util.utilities.logger import logger
from configlib import getConfig, OptionParser
import json
import mozdef_client as mozdef
Expand Down Expand Up @@ -59,15 +58,13 @@ def auth_headers(self):
def get(self, path, params={}):
final_url = ("%s/public/api/customers/%s%s" %
(self.url, self.customer_id, path))
try:
response = requests.get(url=final_url,
headers=self.auth_headers(),
verify=self.verify_ssl)
if (response and response.status_code in
[requests.codes.ok, requests.codes.bad]):
return response.json()
except requests.exceptions.RequestException as e:
logger.exception(e)
response = requests.get(url=final_url,
headers=self.auth_headers(),
verify=self.verify_ssl)
if response.ok:
return response.json()
else:
raise Exception("Received bad response from uptycs: {0} - {1}".format(response.status_code, response.reason))

def alerts(self, uptycs_filter, sort='alertTime:desc&limit'):
path = '/alerts?filters=' + uptycs_filter.filter_string() + "&sort=" + sort
Expand Down

0 comments on commit d6fd6cb

Please sign in to comment.