Improve error reporting

This commit is contained in:
Ian Renton
2026-07-25 13:42:21 +01:00
parent ba08555a30
commit e7253c0916
19 changed files with 41 additions and 16 deletions
+16
View File
@@ -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)
+1 -1
View File
@@ -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,