- config/settings.py : modèles Pydantic Settings (Pronote, CalDAV, XMPP, AI, Blog, App) avec SecretStr pour les mots de passe et clés API - config/env.py : fonction load_settings() pour le chargement du .env - utils/redaction.py : redact_url, redact_secrets, redact_exception (masquage des tokens icalsecurise, mots de passe et URLs sensibles) - utils/logging.py : setup_logging + RedactingFormatter (masquage automatique des secrets dans les logs) - utils/uid.py : normalize_pronote_uid (suppression suffixes temporels) et generate_deterministic_uid (hash SHA-1 usedforsecurity=False) - .env.example : aligné sur les modèles finaux (XMPP_TO, XMPP_HOST, XMPP_ENABLED, BLOG_ENABLED, etc.) - .pre-commit-config.yaml : ajout pydantic + pydantic-settings aux additional_dependencies du hook mypy - TODO.md : items M2 cochés Décisions d'architecture (@architect) : - XmppSettings : modèle complet §10.2.3, tous champs optionnels - sync_past_days/future_days déplacés vers AppSettings (sans préfixe) - AISettings.enabled = False par défaut - BlogSettings inclus dès M2 - redact_exception comme fonction module (pas méthode) - normalize_pronote_uid (nom du guide et des tests) Validations : - ruff check : PASS - ruff format --check : PASS - mypy strict : PASS (7 fichiers) - bandit : PASS (0 issue) - import settings : OK (toutes valeurs par défaut) - redact_secrets/icalsecurise : masqué en REDACTED - logging : secret masqué dans la sortie - uid normalize : idempotent, deterministic OK - SecretStr : pas de fuite dans repr - pytest : 0 test (infrastructure OK) Co-authored-by: OpenCode/orchestrator <opencode-orchestrator@agents.invalid>
61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
# Hooks pre-commit pour pronote-sync
|
|
# Installation : pre-commit install
|
|
# Exécution manuelle : pre-commit run --all-files
|
|
default_language_version:
|
|
python: python3
|
|
|
|
repos:
|
|
# Outils du venv (ruff, mypy, bandit) — exécutés dans l'environnement géré par pre-commit
|
|
- repo: local
|
|
hooks:
|
|
- id: ruff-check
|
|
name: ruff check
|
|
entry: ruff check
|
|
language: python
|
|
additional_dependencies: ["ruff>=0.4.0"]
|
|
types: [python]
|
|
|
|
- id: ruff-format
|
|
name: ruff format
|
|
entry: ruff format
|
|
language: python
|
|
additional_dependencies: ["ruff>=0.4.0"]
|
|
types: [python]
|
|
|
|
- id: mypy
|
|
name: mypy
|
|
entry: mypy
|
|
language: python
|
|
additional_dependencies: ["mypy>=1.10.0", "pydantic>=2.0.0", "pydantic-settings>=2.0.0"]
|
|
types: [python]
|
|
pass_filenames: true
|
|
|
|
- id: bandit
|
|
name: bandit
|
|
entry: bandit
|
|
args: [-c, pyproject.toml, -r]
|
|
language: python
|
|
additional_dependencies: ["bandit>=1.7.0"]
|
|
types: [python]
|
|
|
|
# Hooks standard de pre-commit
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v5.0.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
exclude: 'GUIDE_DEV_PYTHON\.md'
|
|
- id: end-of-file-fixer
|
|
exclude: 'GUIDE_DEV_PYTHON\.md'
|
|
- id: check-yaml
|
|
- id: check-added-large-files
|
|
args: [--maxkb=500]
|
|
exclude: 'GUIDE_DEV_PYTHON\.md'
|
|
- id: check-merge-conflict
|
|
|
|
# Détection de secrets
|
|
- repo: https://github.com/Yelp/detect-secrets
|
|
rev: v1.5.0
|
|
hooks:
|
|
- id: detect-secrets
|
|
args: [--baseline, .secrets.baseline]
|