From e50eec17859275763e888706583adfd9e59638e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Sun, 3 May 2026 17:34:38 +0200 Subject: [PATCH] =?UTF-8?q?security:=20remplace=20les=20chemins=20syst?= =?UTF-8?q?=C3=A8me=20hardcod=C3=A9s=20par=20des=20variables=20d'env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit admin/builds.py : STATE_FILE, LOG_FILE, DEPLOY_SCRIPT lus depuis l'environnement dynamic/db.py : supprime le fallback de chemin système pour DATABASE admin/.env.example : documente les nouvelles variables STATE_FILE, LOG_FILE Co-Authored-By: Claude Sonnet 4.6 --- admin/.env.example | 4 +++- admin/builds.py | 7 ++++--- dynamic/db.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/admin/.env.example b/admin/.env.example index 0a2805c..008db34 100644 --- a/admin/.env.example +++ b/admin/.env.example @@ -7,5 +7,7 @@ ALPID_DISCOVERY_URL=https://alpid.alpinux.org/realms/alpinux/.well-known/openid- # Noms des groupes Keycloak autorisés (séparés par virgule) ADMIN_GROUPS=admins -# Chemin du script de déploiement (défaut dans builds.py si non défini) +# Chemins de déploiement (valeurs par défaut dans /tmp — à définir en production) # DEPLOY_SCRIPT= +# STATE_FILE= +# LOG_FILE= diff --git a/admin/builds.py b/admin/builds.py index 4b93bf9..ed98aab 100644 --- a/admin/builds.py +++ b/admin/builds.py @@ -3,15 +3,16 @@ Gestion des builds : exécution, état, historique. Un seul build peut tourner à la fois. """ import json +import os import subprocess import threading import time from datetime import datetime from pathlib import Path -STATE_FILE = Path("/var/lib/alpinux-admin/builds.json") -LOG_FILE = Path("/var/lib/alpinux-admin/current.log") -DEPLOY_SCRIPT = Path("/home/alpinux/site/scripts") / "deploy-wiki.sh" +STATE_FILE = Path(os.environ.get("STATE_FILE", "/tmp/admin-state.json")) +LOG_FILE = Path(os.environ.get("LOG_FILE", "/tmp/admin-build.log")) +DEPLOY_SCRIPT = Path(os.environ.get("DEPLOY_SCRIPT", "deploy-wiki.sh")) _lock = threading.Lock() diff --git a/dynamic/db.py b/dynamic/db.py index ec5e022..26216ea 100644 --- a/dynamic/db.py +++ b/dynamic/db.py @@ -5,7 +5,7 @@ from flask import g def get_db(): if 'db' not in g: - db_path = os.environ.get('DATABASE', '/var/lib/dynamic-alpinux/scores.db') + db_path = os.environ.get('DATABASE', 'scores.db') os.makedirs(os.path.dirname(db_path), exist_ok=True) g.db = sqlite3.connect(db_path) g.db.row_factory = sqlite3.Row