diff --git a/backend/core/conf.py b/backend/core/conf.py index 6ac893e3..c6669984 100644 --- a/backend/core/conf.py +++ b/backend/core/conf.py @@ -244,6 +244,7 @@ class Settings(BaseSettings): 'old_password', 'new_password', 'confirm_password', + 'secret', ] OPERA_LOG_QUEUE_MAXSIZE: int = 100000 OPERA_LOG_QUEUE_BATCH_CONSUME_SIZE: int = 100 diff --git a/backend/middleware/opera_log_middleware.py b/backend/middleware/opera_log_middleware.py index d75202ed..e4203d83 100644 --- a/backend/middleware/opera_log_middleware.py +++ b/backend/middleware/opera_log_middleware.py @@ -133,6 +133,12 @@ class OperaLogMiddleware(BaseHTTPMiddleware): :return: """ args = {} + # 用于 ai-buddy 插件,避免交互输入、聊天和图像生成请求中的敏感内容写入操作日志 + if '/input-requests/' in request.url.path or request.url.path.endswith(( + '/chat/completions', + '/images/generations', + )): + return {'body': '[REDACTED]'} # 查询参数 query_params = dict(request.query_params)