fix(frontend,backend): all stories panel groups by peer again, missing trashed file answers 404, access log hides the token
This commit is contained in:
1 parent
897421e7c4
commit
09c5f78061
5 files changed
+28
-16
No files matched your search
@@ -1,19 +1,23 @@
|
||||
import logging
|
||||
import re
|
||||
|
||||
QUERYLESS_PREFIXES = ("/mcp",)
|
||||
_PATH_ARG = 2
|
||||
_TOKEN = re.compile(r"(?<=[?&]token=)[^&]+")
|
||||
|
||||
|
||||
class DropQueryFilter(logging.Filter):
|
||||
class ScrubQueryFilter(logging.Filter):
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
args = record.args
|
||||
if isinstance(args, tuple) and len(args) > _PATH_ARG:
|
||||
path = str(args[_PATH_ARG])
|
||||
if path.startswith(QUERYLESS_PREFIXES):
|
||||
bare = path.partition("?")[0]
|
||||
record.args = (*args[:_PATH_ARG], bare, *args[_PATH_ARG + 1 :])
|
||||
path = path.partition("?")[0]
|
||||
else:
|
||||
path = _TOKEN.sub("***", path)
|
||||
record.args = (*args[:_PATH_ARG], path, *args[_PATH_ARG + 1 :])
|
||||
return True
|
||||
|
||||
|
||||
def hide_mcp_query() -> None:
|
||||
logging.getLogger("uvicorn.access").addFilter(DropQueryFilter())
|
||||
def scrub_access_log() -> None:
|
||||
logging.getLogger("uvicorn.access").addFilter(ScrubQueryFilter())
|
||||
Reference in new issue
Block a user