mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Improve log messages
Log failed login attempts with remote host as warning (closes #1104) Add component UID to log message about invalid recurrence rules (reference #602) Use "forwarded for" instead of "forwarded by" for remote host
This commit is contained in:
parent
ca27156605
commit
d48bacc8e3
9 changed files with 16 additions and 15 deletions
|
@ -167,8 +167,8 @@ class Application(
|
|||
elif environ.get("REMOTE_ADDR"):
|
||||
remote_host = environ["REMOTE_ADDR"]
|
||||
if environ.get("HTTP_X_FORWARDED_FOR"):
|
||||
remote_host = "%r (forwarded by %s)" % (
|
||||
environ["HTTP_X_FORWARDED_FOR"], remote_host)
|
||||
remote_host = "%s (forwarded for %r)" % (
|
||||
remote_host, environ["HTTP_X_FORWARDED_FOR"])
|
||||
remote_useragent = ""
|
||||
if environ.get("HTTP_USER_AGENT"):
|
||||
remote_useragent = " using %r" % environ["HTTP_USER_AGENT"]
|
||||
|
@ -230,7 +230,8 @@ class Application(
|
|||
elif user:
|
||||
logger.info("Successful login: %r -> %r", login, user)
|
||||
elif login:
|
||||
logger.info("Failed login attempt: %r", login)
|
||||
logger.warning("Failed login attempt from %s: %r",
|
||||
remote_host, login)
|
||||
# Random delay to avoid timing oracles and bruteforce attacks
|
||||
delay = self.configuration.get("auth", "delay")
|
||||
if delay > 0:
|
||||
|
|
|
@ -39,7 +39,7 @@ class ApplicationMkcalendarMixin:
|
|||
"Bad MKCALENDAR request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
# Prepare before locking
|
||||
props = xmlutils.props_from_request(xml_content)
|
||||
|
|
|
@ -40,7 +40,7 @@ class ApplicationMkcolMixin:
|
|||
"Bad MKCOL request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
# Prepare before locking
|
||||
props = xmlutils.props_from_request(xml_content)
|
||||
|
|
|
@ -357,7 +357,7 @@ class ApplicationPropfindMixin:
|
|||
"Bad PROPFIND request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
with self._storage.acquire_lock("r", user):
|
||||
items = self._storage.discover(
|
||||
|
|
|
@ -76,7 +76,7 @@ class ApplicationProppatchMixin:
|
|||
"Bad PROPPATCH request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
with self._storage.acquire_lock("w", user):
|
||||
item = next(self._storage.discover(path), None)
|
||||
|
|
|
@ -123,7 +123,7 @@ class ApplicationPutMixin:
|
|||
logger.warning("Bad PUT request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
# Prepare before locking
|
||||
content_type = environ.get("CONTENT_TYPE", "").split(";")[0]
|
||||
|
|
|
@ -181,7 +181,7 @@ def xml_report(base_prefix, path, xml_request, collection, encoding,
|
|||
radicale_filter.prop_match(item.vobject_item, f, "CR")
|
||||
for f in filter_)
|
||||
raise ValueError("Unsupported filter test: %r" % test)
|
||||
raise ValueError("unsupported filter %r for %r" % (filter_.tag, tag))
|
||||
raise ValueError("Unsupported filter %r for %r" % (filter_.tag, tag))
|
||||
|
||||
while retrieved_items:
|
||||
# ``item.vobject_item`` might be accessed during filtering.
|
||||
|
@ -268,7 +268,7 @@ class ApplicationReportMixin:
|
|||
"Bad REPORT request on %r: %s", path, e, exc_info=True)
|
||||
return httputils.BAD_REQUEST
|
||||
except socket.timeout:
|
||||
logger.debug("client timed out", exc_info=True)
|
||||
logger.debug("Client timed out", exc_info=True)
|
||||
return httputils.REQUEST_TIMEOUT
|
||||
with contextlib.ExitStack() as lock_stack:
|
||||
lock_stack.enter_context(self._storage.acquire_lock("r", user))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue