fix(M2): configuration, secrets et rédaction — correction des écarts FIXME_M2
Sécurité : - ical_url : str → SecretStr | None (masquage dans str/repr/model_dump_json) - En-têtes Authorization/Proxy-Authorization : masquage complet de la valeur - _URL_PATTERN : insensible à la casse (HTTPS:// reconnu) - redact_url() : masquage du nom d'utilisateur (userinfo complet) Configuration : - Sous-configs : Field(default_factory=...) pour rechargement à chaque appel - Suppression du singleton settings (injection de dépendances) - .env.example : ajout AI_PROVIDER et CALDAV_CALENDAR_PATH - Guide : BLOG_RSS_ENABLED → BLOG_ENABLED, AI_MODEL=None par défaut - .secrets.baseline : ligne décalée 5112 → 5117 (faux positif audité) - pre-commit : ajout de pytest aux additional_dependencies du hook mypy Tests : 15 tests (config + redaction) couvrant rechargement, masquage SecretStr, en-têtes Authorization, URL auth intégrée et casse variable. Co-authored-by: opencode/coder <coder@agents.invalid> Co-authored-by: opencode/test-engineer <test-engineer@agents.invalid>
This commit is contained in:
@@ -267,6 +267,8 @@ Le projet utilise **`pydantic-settings`** pour valider et charger la configurati
|
||||
| `CALDAV_URL` | URL du serveur CalDAV. | `https://caldav.example.com/calendars/...` | `str` |
|
||||
| `CALDAV_USERNAME` | Identifiant CalDAV. | `user@example.com` | `str` |
|
||||
| `CALDAV_PASSWORD` | Mot de passe CalDAV. | `SecretStr` (masqué) | `SecretStr` |
|
||||
| `CALDAV_CALENDAR_PATH` | Chemin du calendrier CalDAV de destination. | `/pronote-sync/` | `str` |
|
||||
| `CALDAV_CALENDAR_PATH` | Chemin du calendrier CalDAV de destination. | `/pronote-sync/` | `str` |
|
||||
| `XMPP_JID` | Identifiant XMPP (ex: `user@example.com`). | `user@example.com` | `str` |
|
||||
| `XMPP_PASSWORD` | Mot de passe XMPP. | `SecretStr` (masqué) | `SecretStr` |
|
||||
| `XMPP_RECIPIENT` | Destinataire XMPP (ex: `parent@example.com`). | `parent@example.com` | `str` |
|
||||
@@ -291,9 +293,10 @@ Le projet utilise **`pydantic-settings`** pour valider et charger la configurati
|
||||
> Leur placement dans `AppSettings` (sans préfixe) garantit un mappage correct avec `SYNC_PAST_DAYS` / `SYNC_FUTURE_DAYS`.
|
||||
| `THEORETICAL_AGENDA_PATH` | Chemin vers le fichier iCal/CSV de l'agenda théorique. | `None` | `str \| None`|
|
||||
| `AI_ENABLED` | Activer la synthèse IA. | `False` | `bool` |
|
||||
| `AI_PROVIDER` | Fournisseur IA (`openai` ou `litellm`). | `openai` | `str` |
|
||||
| `AI_BASE_URL` | URL de base pour l'API IA (ex: OpenAI compatible). | `None` | `str \| None`|
|
||||
| `AI_API_KEY` | Clé API pour l'API IA. | `None` | `SecretStr` |
|
||||
| `AI_MODEL` | Modèle IA à utiliser. | `gpt-4o-mini` | `str` |
|
||||
| `AI_MODEL` | Modèle IA à utiliser (exemple recommandé : `gpt-4o-mini`). | `None` | `str \| None`|
|
||||
| `DRY_RUN` | Mode dry-run (pas de modifications CalDAV/XMPP). | `False` | `bool` |
|
||||
| `LOG_LEVEL` | Niveau de log (`DEBUG`, `INFO`, `WARNING`, `ERROR`). | `INFO` | `str` |
|
||||
|
||||
@@ -316,6 +319,7 @@ PRONOTE_MESSAGES_SOURCE=pronotepy
|
||||
CALDAV_URL=https://caldav.example.com/calendars/user/pronote/
|
||||
CALDAV_USERNAME=user@example.com
|
||||
CALDAV_PASSWORD=your_caldav_password
|
||||
CALDAV_CALENDAR_PATH=/pronote-sync/
|
||||
|
||||
# Fenêtre de synchronisation (jours)
|
||||
SYNC_PAST_DAYS=7
|
||||
@@ -331,9 +335,10 @@ XMPP_RECIPIENT=parent@example.com
|
||||
|
||||
# --- IA (optionnelle) ---
|
||||
AI_ENABLED=true
|
||||
AI_PROVIDER=openai
|
||||
AI_BASE_URL=https://api.openai.com/v1
|
||||
AI_API_KEY=your_ai_api_key
|
||||
AI_MODEL=gpt-4o-mini
|
||||
# AI_MODEL=gpt-4o-mini # exemple recommandé, non activé par défaut
|
||||
|
||||
# --- Divers ---
|
||||
DRY_RUN=false
|
||||
@@ -1142,7 +1147,7 @@ Ajouter les variables suivantes dans la configuration :
|
||||
|
||||
| **Variable** | **Description** | **Valeur par défaut** | **Type** |
|
||||
|----------------------------|-------------------------------------------------------------------------------|-----------------------|-------------------|
|
||||
| `BLOG_RSS_ENABLED` | Activer la récupération du blog. | `False` | `bool` |
|
||||
| `BLOG_ENABLED` | Activer la récupération du blog. | `False` | `bool` |
|
||||
| `BLOG_RSS_URL` | URL du flux RSS du blog. | `https://blogpeda.ac-bordeaux.fr/cjeliote/?feed=rss2` | `str` |
|
||||
|
||||
#### 5 bis.9.2 Modèle Pydantic pour la configuration du blog
|
||||
@@ -1177,7 +1182,7 @@ class Settings(BaseSettings):
|
||||
|
||||
```ini
|
||||
# --- Blog du collège ---
|
||||
BLOG_RSS_ENABLED=true
|
||||
BLOG_ENABLED=true
|
||||
BLOG_RSS_URL=https://blogpeda.ac-bordeaux.fr/cjeliote/?feed=rss2
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user