diff --git a/alertproviders/http_alert_provider.py b/alertproviders/http_alert_provider.py index b7c83de..3e8dcf6 100644 --- a/alertproviders/http_alert_provider.py +++ b/alertproviders/http_alert_provider.py @@ -4,6 +4,7 @@ from threading import Thread, Event import pytz import requests +from requests.exceptions import ConnectionError from alertproviders.alert_provider import AlertProvider from core.constants import HTTP_HEADERS diff --git a/core/lookup_helper.py b/core/lookup_helper.py index ed9aa22..598972e 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -11,6 +11,7 @@ from pyhamtools import LookupLib, Callinfo, callinfo from pyhamtools.exceptions import APIKeyMissingError from pyhamtools.frequency import freq_to_band from pyhamtools.locator import latlong_to_locator +from requests.exceptions import ConnectionError from requests_cache import CachedSession from core.cache_utils import SEMI_STATIC_URL_DATA_CACHE diff --git a/core/sig_utils.py b/core/sig_utils.py index 60f5f96..2dec186 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -2,6 +2,7 @@ import csv import logging from pyhamtools.locator import latlong_to_locator, locator_to_latlong +from requests.exceptions import ConnectionError from core.cache_utils import SEMI_STATIC_URL_DATA_CACHE from core.constants import SIGS, HTTP_HEADERS diff --git a/server/handlers/quietstaticfilehandler.py b/server/handlers/quietstaticfilehandler.py new file mode 100644 index 0000000..4ba2d4d --- /dev/null +++ b/server/handlers/quietstaticfilehandler.py @@ -0,0 +1,16 @@ +import logging + +from tornado.web import StaticFileHandler, HTTPError + + +class QuietStaticFileHandler(StaticFileHandler): + """Minor override of logging in StaticFileHandler to log HTTP errors at debug level instead of their usual + warning level. Without this, attacks on Spothole which try to do path traversal attacks would log exceptions + from inside Tornado, and the server logs would contain a lot of this type of content. This effectively changes + the log level of these exceptions to DEBUG so they are only logged if DEBUG level logging is enabled.""" + + def log_exception(self, typ, value, tb): + if isinstance(value, HTTPError): + logging.debug(value) + return + super().log_exception(typ, value, tb) \ No newline at end of file diff --git a/server/webserver.py b/server/webserver.py index 4ae9ea3..d28139d 100644 --- a/server/webserver.py +++ b/server/webserver.py @@ -103,7 +103,7 @@ class WebServer: misc_routes = [ (r"/apidocs", PageTemplateHandler, {"template_name": "apidocs", **handler_opts}), (r"/metrics", PrometheusMetricsHandler), - (r"/(.*)", StaticFileHandler, {"path": os.path.join(_HERE, "../webassets")}) + (r"/(.*)", QuietStaticFileHandler, {"path": os.path.join(_HERE, "../webassets")}) ] app = tornado.web.Application(api_routes + ui_routes + misc_routes, diff --git a/solarconditionsproviders/giroionosonde.py b/solarconditionsproviders/giroionosonde.py index 380bd7e..56a7ebe 100644 --- a/solarconditionsproviders/giroionosonde.py +++ b/solarconditionsproviders/giroionosonde.py @@ -5,6 +5,7 @@ from threading import Thread, Event import pytz import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from solarconditionsproviders.ionosonde_utils import compute_band_states diff --git a/solarconditionsproviders/http_solar_conditions_provider.py b/solarconditionsproviders/http_solar_conditions_provider.py index fbf87fd..b08d7b9 100644 --- a/solarconditionsproviders/http_solar_conditions_provider.py +++ b/solarconditionsproviders/http_solar_conditions_provider.py @@ -4,6 +4,7 @@ from threading import Thread, Event import pytz import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from solarconditionsproviders.solar_conditions_provider import SolarConditionsProvider diff --git a/solarconditionsproviders/kc2gprop.py b/solarconditionsproviders/kc2gprop.py index a33a0f9..5fa581b 100644 --- a/solarconditionsproviders/kc2gprop.py +++ b/solarconditionsproviders/kc2gprop.py @@ -4,6 +4,7 @@ from threading import Thread, Event import pytz import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from solarconditionsproviders.ionosonde_utils import compute_band_states diff --git a/spotproviders/hema.py b/spotproviders/hema.py index e796f4f..07f593e 100644 --- a/spotproviders/hema.py +++ b/spotproviders/hema.py @@ -4,6 +4,7 @@ from datetime import datetime import pytz import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from data.sig_ref import SIGRef diff --git a/spotproviders/http_spot_provider.py b/spotproviders/http_spot_provider.py index 9885940..17b748c 100644 --- a/spotproviders/http_spot_provider.py +++ b/spotproviders/http_spot_provider.py @@ -4,6 +4,7 @@ from threading import Thread, Event import pytz import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from spotproviders.spot_provider import SpotProvider diff --git a/spotproviders/sota.py b/spotproviders/sota.py index fee0ef2..fa0fc80 100644 --- a/spotproviders/sota.py +++ b/spotproviders/sota.py @@ -2,6 +2,7 @@ import logging from datetime import datetime import requests +from requests.exceptions import ConnectionError from core.constants import HTTP_HEADERS from data.sig_ref import SIGRef diff --git a/templates/add_spot.html b/templates/add_spot.html index 2abe093..4c86461 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 249dc23..740753e 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -75,7 +75,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 544782a..5f5d97e 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -75,8 +75,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index d1e8097..27c27a5 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -10,10 +10,10 @@ - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index dd07614..91e321c 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index d9b9dc0..8197b89 100644 --- a/templates/map.html +++ b/templates/map.html @@ -95,8 +95,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index 96501e3..88310c9 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -116,8 +116,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 2d14a8b..a7cd84c 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,7 +59,7 @@ - +