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

Commit

Permalink
Modify unknown isp in geomodel plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnbus committed Aug 17, 2018
1 parent 15f6036 commit 905ce5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions alerts/plugins/dashboard_geomodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ def onMessage(self, message):
country = message['details']['locality_details']['country']
source_ip = message['details']['source_ip']

source_ip_whois = ""
new_ip_info = ""
try:
whois = IPWhois(source_ip).lookup_whois()
whois_str = whois['nets'][0]['description']
source_ip_whois = whois_str.replace('\n', ' ').replace('\r', '')
source_ip_isp = whois_str.replace('\n', ', ').replace('\r', '')
new_ip_info = u'{} ({})'.format(source_ip, source_ip_isp)
except Exception:
source_ip_whois = "Unknown"
new_ip_info = u'{}'.format(source_ip)

new_location_str = u""
if city.lower() == 'unknown':
Expand Down Expand Up @@ -122,7 +123,7 @@ def onMessage(self, message):
'details': {
'Timestamp': event_timestamp.strftime('%A, %B %d %Y %H:%M UTC'),
'New Location': new_location_str,
'New IP': u'{} ({})'.format(source_ip, source_ip_whois),
'New IP': new_ip_info,
'Previous Location': previous_location_str
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/alerts/plugins/test_dashboard_geomodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_written_details(self):
assert self.test_result_record is not None
result_db_entry = self.test_result_record
assert result_db_entry['details'] == {
'New IP': u'1.2.3.4 (APNIC Debogon Project APNIC Pty Ltd)',
'New IP': u'1.2.3.4 (APNIC Debogon Project, APNIC Pty Ltd)',
'New Location': u'Diamond Bar, United States',
'Previous Location': u'Oakland, United States',
'Timestamp': 'Wednesday, August 08 2018 02:11 UTC'
Expand Down

0 comments on commit 905ce5f

Please sign in to comment.