herrfeder / AI_Cybersecurity_IDS_PoC

Winning Contribution of Michael Schwabe and David Lassig to BWI Data Analytics Hackathon 2020 in the Category Cyber Security. Proof of Concept Intrusion Detection using Zeek with selfmade MachineLearning in a nice WebApp.
8 stars 5 forks source link

Monitor Tab will not load because of error related to IP to Geo Location issue #3

Closed herrfeder closed 3 years ago

herrfeder commented 3 years ago

This error occurs when the Monitor Tab will try to reload:

Exception on /aicspoc/_dash-update-component [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/dash/dash.py", line 1031, in dispatch
    response.set_data(func(*args, outputs_list=outputs_list))
  File "/usr/local/lib/python3.8/site-packages/dash/dash.py", line 966, in add_context
    output_value = func(*args, **kwargs)  # %% callback invoked %%
  File "/home/datascientist/AI_Cybersecurity_IDS_PoC/app/app.py", line 442, in update_monitor_table
    return_world("conn", timespan=monitor_time_interval))
  File "/home/datascientist/AI_Cybersecurity_IDS_PoC/app/app.py", line 205, in return_world
    data_dict = dh.get_longitude_latitude(file_type, timespan)
  File "/home/datascientist/AI_Cybersecurity_IDS_PoC/app/data_helper.py", line 312, in get_longitude_latitude
    lon_lat_list.append(self.get_lonlat_from_ip(ip))
  File "/home/datascientist/AI_Cybersecurity_IDS_PoC/app/data_helper.py", line 278, in get_lonlat_from_ip
    lon = details.longitude.strip("_")
AttributeError: 'NoneType' object has no attribute 'strip'

This is because the project was developed in an cloud environment (with only public IPs) and running the instructions in a local network will trigger this error as private IPs won't be resolved to an Geo Location.

herrfeder commented 3 years ago

For now, I added an additional check in this commit https://github.com/herrfeder/AI_Cybersecurity_IDS_PoC/commit/9317582707b37e00605ec1601cddc40d1c229153 that will give unresolvable IPs an lon/lat pair of (0,0).

Not good, but not terrible xD