Missing parens on IP resolver lookup

Also adds a generic catch in case this happens again; we should *never* fail
This commit is contained in:
Joseph Schorr 2018-05-04 02:11:16 +03:00
parent bf943e7713
commit 942f526016

View file

@ -78,13 +78,15 @@ class IPResolver(IPResolverInterface):
logger.debug('Got non-200 response for IP %s: %s', ip_address, r.status_code)
return False
logger.debug('Got IP data for IP %s: %s => %s', ip_address, r.status_code, r.json)
threat_data = r.json.get('threat', {})
logger.debug('Got IP data for IP %s: %s => %s', ip_address, r.status_code, r.json())
threat_data = r.json().get('threat', {})
return threat_data.get('is_threat', False) or threat_data.get('is_bogon', False)
except requests.RequestException:
logger.exception('Got exception when trying to lookup IP Address')
except ValueError:
logger.exception('Got exception when trying to lookup IP Address')
except Exception:
logger.exception('Got exception when trying to lookup IP Address')
return False