fix(sécurité): durcir les accès fichiers et les appels bq - #38
Merged
Conversation
…2026-07) Suite à l'audit de sécurité du projet : - Traversée de chemin via `model_name`/`full_path` (contrôlés côté HTTP) : nouveau helper `utils/path_guard.py:safe_join` (containment sous racine), appliqué à `_test_path` (raise), `read_model_sql`/`get_model_file_*`, `load_model_context` et le catch-all SPA de `server.py`. Un `../` ne peut plus lire/écrire/supprimer hors de `.mocksql/tests`, `models_path` ou le dossier statique (fuite `back/.env`). - Injection de commande dans `_run_bq_cli` : retrait de `shell=True`, exécutable résolu via `shutil.which`, et validation stricte (`_require_bq_component`) des composants projet/dataset/table/billing_project au build de la commande. Le wrapper `bq` étant un `.cmd` (arguments re-parsés par cmd.exe même sans shell), la validation des composants est le vrai garde-fou. - Garde hex sur `source_sha` avant injection dans un argv git (option-injection). - Outillage : règle ruff flake8-bandit `S` activée ; bruit inhérent au domaine ignoré (asserts, SQL en f-string). Les subprocess/binds restants sont `# noqa` justifiés ; les 2 binds `0.0.0.0` portent un TODO pointant le finding #1 (non traité — décision produit). Tests : back/tests/test_security_guards.py (10, rouges avant le fix).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Résumé
Validation
Pile
PR 1/5 — base de la série.