mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Improve error reporting
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user