From fdde5bdee3fab007460c9f16c70ec516ba502106 Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Fri, 13 Mar 2026 11:26:52 +0700 Subject: [PATCH] feat: Disable unknown JSON key and query parameter validation by commenting out respective checks. --- src/middleware.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/middleware.py b/src/middleware.py index 3854e53..19de161 100644 --- a/src/middleware.py +++ b/src/middleware.py @@ -189,9 +189,9 @@ def inspect_json(obj, path="body", check_whitelist=True): log.warning(f"Security violation: Forbidden JSON key detected: {path}.{key}") raise HTTPException(status_code=422, detail="Invalid request parameters") - if check_whitelist and key not in ALLOWED_DATA_PARAMS: - log.warning(f"Security violation: Unknown JSON key detected: {path}.{key}") - raise HTTPException(status_code=422, detail="Invalid request parameters") + # if check_whitelist and key not in ALLOWED_DATA_PARAMS: + # log.warning(f"Security violation: Unknown JSON key detected: {path}.{key}") + # raise HTTPException(status_code=422, detail="Invalid request parameters") # Recurse. If the key is a dynamic container, we stop whitelist checking for children. should_check_subkeys = check_whitelist and (key not in DYNAMIC_KEYS) @@ -251,10 +251,10 @@ class RequestValidationMiddleware(BaseHTTPMiddleware): raise HTTPException(status_code=422, detail="Invalid request parameters") # Check for unknown query parameters - unknown_params = [key for key, _ in params if key not in ALLOWED_DATA_PARAMS] - if unknown_params: - log.warning(f"Security violation: Unknown query parameters detected: {unknown_params}") - raise HTTPException(status_code=422, detail="Invalid request parameters") + # unknown_params = [key for key, _ in params if key not in ALLOWED_DATA_PARAMS] + # if unknown_params: + # log.warning(f"Security violation: Unknown query parameters detected: {unknown_params}") + # raise HTTPException(status_code=422, detail="Invalid request parameters") # ------------------------- # 2. Duplicate parameters