fix: whitelist mode/polygon_stand — защита от мусора в cookie (v1.2.42)
Результат код-ревью #3: mode/polygon_stand принимали любые значения из формы. Добавлена валидация в main.py (set_mode) и auth.py (get_mode, get_polygon_stand): mode ∈ {polygon, cloud}, stand ∈ {dev, test, prod}.
This commit is contained in:
+8
-2
@@ -55,14 +55,20 @@ def get_mode():
|
||||
Иначе — из cookie, по умолчанию эмуляция."""
|
||||
if not current_app.config.get("POLYGON_ENDPOINT", ""):
|
||||
return "cloud"
|
||||
return request.cookies.get("mode", "polygon")
|
||||
mode = request.cookies.get("mode", "polygon")
|
||||
if mode not in ("polygon", "cloud"):
|
||||
mode = "polygon"
|
||||
return mode
|
||||
|
||||
|
||||
def get_polygon_stand():
|
||||
"""Стенд полигона: 'test' (по умолчанию), 'dev', 'prod'.
|
||||
|
||||
Используется ТОЛЬКО в режиме эмуляции — для построения URL и load_service_ids."""
|
||||
return request.cookies.get("polygon_stand", "test")
|
||||
stand = request.cookies.get("polygon_stand", "test")
|
||||
if stand not in ("dev", "test", "prod"):
|
||||
stand = "test"
|
||||
return stand
|
||||
|
||||
|
||||
def get_token():
|
||||
|
||||
Reference in New Issue
Block a user