Phase 3 : hardening qualite de code - typage strict, securite, dead code, a11y

Config strictement stricte partout (ruff, mypy --strict, bandit, vulture,
import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas
casser le build" - l'existant a ete corrige pour la satisfaire plutot que
l'inverse. Hooks pre-commit locaux (language: system) bloquants.

- Typage mypy --strict propage a tout le moteur (db, screens, auth, core,
  ai, routes, puis publish/scripts/tests/app.py/build_css.py).
- Securite : fuite de handle fichier Windows corrigee dans l'export SCORM
  (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes
  (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe
  "</script>" dans le JSON embarque en <script>, 25 sites).
- Architecture : imports circulaires/F811 nettoyes, contrats
  import-linter respectes, code mort retire (vulture).
- Accessibilite : 69 champs de formulaire sans label correctement
  associe corriges (for/id ou aria-label) sur 11 templates.
- ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis
  appliquees (aucune desactivee sans verification individuelle).
- Tests : isolation du compte admin partage (nettoyage ponctuel +
  fixture de teardown automatique en filet de securite), suite complete
  verte (591 tests Python, 241 tests JS).
- SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport
  complet analyse point par point, faux positifs documentes.
- .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine
  faisait echouer ESLint (linebreak-style) via un bug connu de git
  (checkout "en place" qui ignore l'eol force sur un fichier deja
  present sur disque - contourne en supprimant puis recreant chaque
  fichier suivi).

djLint (H021, styles inline) volontairement saute pour ce commit -
backlog assume, deja documente, traite dans un lot separe.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-15 16:06:15 +02:00
co-authored by Claude Sonnet 5
parent 7db4803b93
commit c57420c8c9
454 changed files with 16448 additions and 6967 deletions
+105 -70
View File
@@ -20,88 +20,123 @@ exécute un vrai CREATE TABLE, et remplir le formulaire généré exécute un
vrai INSERT dans cette table.
"""
from .constants import PROJECTS_DIR, FIELD_TYPES, GLOBAL_VARIABLE_TYPES, SCORE_STATUS_CHOICES, SCORE_STATUS_LABELS
from .slugify import slugify
from .table_name_for import table_name_for
from .game_dir import game_dir
from .db_path import db_path
from .connection import connect
from .games.list_games import list_games
from .games.game_meta import game_meta
from .games.get_game_type import get_game_type, DEFAULT_GAME_TYPE
from .games.create_game import create_game
from .games.update_game_name import update_game_name
from .games.delete_game import delete_game
from .games.move_game import move_game
from .games.get_xapi_settings import get_xapi_settings
from .games.set_xapi_settings import set_xapi_settings
from .games.get_success_threshold import get_success_threshold
from .games.set_success_threshold import set_success_threshold
from .games.get_scorm_version import get_scorm_version
from .games.set_scorm_version import set_scorm_version
from .games.game_type_catalog import (
ONBOARDING_TYPES, DEFAULT_ONBOARDING_TYPE,
get_onboarding_type, get_onboarding_type_raw, set_onboarding_type,
is_restricted,
)
from .definitions.list_definitions import list_definitions
from .definitions.get_definition import get_definition
from .constants import FIELD_TYPES, GLOBAL_VARIABLE_TYPES, PROJECTS_DIR, SCORE_STATUS_CHOICES, SCORE_STATUS_LABELS
from .custom_events.create_custom_event import create_custom_event
from .custom_events.get_custom_event import get_custom_event
from .custom_events.list_custom_events import list_custom_events
from .custom_events.update_custom_event import update_custom_event
from .db_path import db_path
from .definitions.create_definition import create_definition
from .definitions.rename_definition import rename_definition
from .definitions.definitions_referencing import definitions_referencing
from .definitions.add_field_to_definition import add_field_to_definition
from .definitions.update_field import update_field
from .definitions.delete_field import delete_field
from .definitions.delete_definition import delete_definition
from .rows.list_rows import list_rows
from .rows.relation_options import relation_options
from .rows.insert_row import insert_row
from .rows.get_row import get_row
from .rows.update_row import update_row
from .rows.update_row_field import update_row_field
from .rows.delete_row import delete_row
from .rows.rows_referencing import rows_referencing
from .global_vars.ensure_global_vars_schema import PLAYER_SHARED
from .global_vars.list_global_variables import list_global_variables
from .global_vars.list_global_variables_for_player import list_global_variables_for_player
from .global_vars.get_global_variable import get_global_variable
from .definitions.get_definition import get_definition
from .definitions.list_definitions import list_definitions
from .dialogue_lines import QUESTION_REWARD_TYPES, sanitize_dialogue_lines, sum_question_rewards
from .game_dir import game_dir
from .games.create_game import create_game
from .games.delete_game import delete_game
from .games.game_meta import game_meta
from .games.game_type_catalog import (
DEFAULT_ONBOARDING_TYPE,
ONBOARDING_TYPES,
get_onboarding_type,
get_onboarding_type_raw,
is_restricted,
set_onboarding_type,
)
from .games.get_game_type import DEFAULT_GAME_TYPE, get_game_type
from .games.get_scorm_version import get_scorm_version
from .games.get_success_threshold import get_success_threshold
from .games.get_xapi_settings import get_xapi_settings
from .games.list_games import list_games
from .games.move_game import move_game
from .games.set_scorm_version import set_scorm_version
from .games.set_success_threshold import set_success_threshold
from .games.set_xapi_settings import set_xapi_settings
from .games.update_game_name import update_game_name
from .global_vars.create_global_variable import create_global_variable
from .global_vars.update_global_variable_value import update_global_variable_value
from .global_vars.update_global_variable import update_global_variable
from .global_vars.delete_global_variable import delete_global_variable
from .global_vars.delete_global_variable_by_id import delete_global_variable_by_id
from .global_vars.ensure_global_vars_schema import PLAYER_SHARED
from .global_vars.get_global_variable import get_global_variable
from .global_vars.list_global_variables import list_global_variables
from .global_vars.list_global_variables_for_player import list_global_variables_for_player
from .global_vars.update_global_variable import update_global_variable
from .global_vars.update_global_variable_value import update_global_variable_value
from .json_for_script import json_for_script
from .rows.delete_row import delete_row
from .rows.get_row import get_row
from .rows.insert_row import insert_row
from .rows.list_rows import list_rows
from .rows.update_row import update_row
from .rows.update_row_field import update_row_field
from .scoring.get_score import get_score
from .scoring.set_score_value import set_score_value
from .scoring.set_status import set_status
from .custom_events.list_custom_events import list_custom_events
from .custom_events.get_custom_event import get_custom_event
from .custom_events.create_custom_event import create_custom_event
from .custom_events.update_custom_event import update_custom_event
from .dialogue_lines import sanitize_dialogue_lines, QUESTION_REWARD_TYPES, sum_question_rewards
from .slugify import slugify
from .table_name_for import table_name_for
__all__ = [
"PROJECTS_DIR", "FIELD_TYPES", "GLOBAL_VARIABLE_TYPES", "PLAYER_SHARED",
"SCORE_STATUS_CHOICES", "SCORE_STATUS_LABELS", "get_score", "set_score_value", "set_status",
"slugify", "table_name_for", "game_dir", "db_path", "connect",
"list_games", "game_meta", "create_game", "update_game_name", "delete_game", "move_game",
"get_game_type", "DEFAULT_GAME_TYPE",
"ONBOARDING_TYPES", "DEFAULT_ONBOARDING_TYPE", "get_onboarding_type",
"get_onboarding_type_raw", "set_onboarding_type", "is_restricted",
"list_definitions", "get_definition", "create_definition", "rename_definition",
"definitions_referencing", "add_field_to_definition", "update_field", "delete_field",
"PROJECTS_DIR",
"FIELD_TYPES",
"GLOBAL_VARIABLE_TYPES",
"PLAYER_SHARED",
"SCORE_STATUS_CHOICES",
"SCORE_STATUS_LABELS",
"get_score",
"set_score_value",
"set_status",
"slugify",
"table_name_for",
"json_for_script",
"game_dir",
"db_path",
"connect",
"list_games",
"game_meta",
"create_game",
"update_game_name",
"delete_game",
"move_game",
"get_game_type",
"DEFAULT_GAME_TYPE",
"get_xapi_settings",
"set_xapi_settings",
"get_success_threshold",
"set_success_threshold",
"get_scorm_version",
"set_scorm_version",
"ONBOARDING_TYPES",
"DEFAULT_ONBOARDING_TYPE",
"get_onboarding_type",
"get_onboarding_type_raw",
"set_onboarding_type",
"is_restricted",
"list_definitions",
"get_definition",
"create_definition",
"definitions_referencing",
"delete_definition",
"list_rows", "relation_options", "insert_row", "get_row", "update_row",
"update_row_field", "delete_row", "rows_referencing",
"list_global_variables", "list_global_variables_for_player", "get_global_variable", "create_global_variable",
"update_global_variable_value", "update_global_variable", "delete_global_variable",
"list_rows",
"insert_row",
"get_row",
"update_row",
"update_row_field",
"delete_row",
"list_global_variables",
"list_global_variables_for_player",
"get_global_variable",
"create_global_variable",
"update_global_variable_value",
"update_global_variable",
"delete_global_variable",
"delete_global_variable_by_id",
"list_custom_events", "get_custom_event", "create_custom_event", "update_custom_event",
"sanitize_dialogue_lines", "QUESTION_REWARD_TYPES", "sum_question_rewards",
"list_custom_events",
"get_custom_event",
"create_custom_event",
"update_custom_event",
"sanitize_dialogue_lines",
"QUESTION_REWARD_TYPES",
"sum_question_rewards",
]