INNER CODE UNIT · Python
resources_source
darama22/Malware-Research-Hub · app/server.py:48
def resources_source(lang):
if lang == "en" and (DATA_DIR / "resources_en.json").exists():
return "resources_en.json"
return "resources.json"
def resolve_and_validate(rel_path):
"""Resuelve una ruta relativa a la raíz del repo y verifica que no se
escape de ahí (evita path traversal). Aborta con 400/403/404 si algo falla."""
if not rel_path:
abort(400)
abs_path = (REPO_ROOT / rel_path).resolve()
try:
abs_path.relative_to(REPO_ROOT.resolve())
except ValueError:
abort(403)
if not abs_path.exists():
abort(404)