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)
|
||||
Reference in New Issue
Block a user