Repository navigation
fix(config): corrige le log d'avertissement des variables ${VAR} abse… - #296
Conversation
…ntes _resolve passait la variable en argument positionnel à un message sans marqueur de formatage : chaque variable d'environnement absente produisait une « Logging error » (TypeError de formatage avalé par logging) au lieu d'un avertissement lisible. La variable est maintenant un champ structuré, comme le demande la convention du dépôt. Le comportement de résolution est inchangé : une variable absente donne une chaîne vide. Test de non-régression qui échoue avant le correctif.
Reviewer's GuideLe correctif conserve le comportement de résolution des variables File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="xcore/configurations/helper.py" line_range="25" />
<code_context>
+ logging.Handler,
+ "handleError",
+ lambda self, record: erreurs.append(record),
+ )
+ monkeypatch.delenv("XCORE_TEST_VAR_ABSENTE", raising=False)
+
</code_context>
<issue_to_address>
**Config can forge text log lines**
When an attacker-controlled configuration contains an unresolved `${...}` placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, `_resolve` passes the captured variable name as `var`, and `_TextFormatter.format` inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.
Escape or remove control characters from structured field values before rendering them in the text formatter.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: xcore/configurations/helper.py:25
| extra={"var": var}, | ||
| "variable d'environnement non définie, chaîne vide utilisée", | ||
| var=var, | ||
| ) |
There was a problem hiding this comment.
🟡 Medium · Config can forge text log lines
When an attacker-controlled configuration contains an unresolved ${...} placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, _resolve passes the captured variable name as var, and _TextFormatter.format inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.
Escape or remove control characters from structured field values before rendering them in the text formatter.
Prompt for AI agents
In `xcore/configurations/helper.py` at line 25:
**Config can forge text log lines**
When an attacker-controlled configuration contains an unresolved `${...}` placeholder whose contents include a newline, and the configuration is loaded while the unescaped text formatter is active, `_resolve` passes the captured variable name as `var`, and `_TextFormatter.format` inserts field values into text output without escaping; a newline in the name therefore forges additional log lines, misleading log consumers.
Escape or remove control characters from structured field values before rendering them in the text formatter.
…ntes
_resolve passait la variable en argument positionnel à un message sans marqueur de formatage : chaque variable d'environnement absente produisait une « Logging error » (TypeError de formatage avalé par logging) au lieu d'un avertissement lisible. La variable est maintenant un champ structuré, comme le demande la convention du dépôt.
Le comportement de résolution est inchangé : une variable absente donne une chaîne vide. Test de non-régression qui échoue avant le correctif.
Summary by Sourcery
Corrige le traitement des avertissements pour les variables d’environnement absentes sans modifier leur comportement de résolution.
Bug Fixes:
Tests: