Skip to content

Commit 9bb45f3

Browse files
committed
refactor: merging develop_04
2 parents 08ac20b + 37429c4 commit 9bb45f3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ requests = "2.32.4" # Mitigates security vuln in < 2.31.0
3939
schedula = "1.2.19"
4040
sqlalchemy = "2.0.19"
4141
typing_extensions = "4.6.2"
42-
urllib3 = "2.5.0" # Mitigates security vuln in < 1.26.19
42+
urllib3 = "2.6.0" # Mitigates security vuln in < 2.5.0
4343
xmltodict = "0.13.0"
4444

4545
[tool.poetry.group.dev]

src/dve/core_engine/backends/metadata/reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BaseReportingConfig(BaseModel):
2828
2929
"""
3030

31-
UNTEMPLATED_FIELDS: ClassVar[set[str]] = {"message"}
31+
UNTEMPLATED_FIELDS: ClassVar[set[str]] = set()
3232
"""Fields that should not be templated."""
3333

3434
emit: Optional[str] = None

src/dve/core_engine/templating.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
from dve.core_engine.type_hints import JSONable, TemplateVariables
1212

1313

14+
class PreserveTemplateUndefined(jinja2.Undefined):
15+
"""
16+
Preserve the original template in instances where the value cannot be populated. Whilst this
17+
may result in templates coming back in the FeedbackMessage object, it's more useful to know
18+
exactly what should have been populated rather than just returning blank values.
19+
"""
20+
def __str__(self):
21+
return "{{" + self._undefined_name + "}}"
22+
23+
1424
class RuleTemplateError(ValueError):
1525
"""A rule template error."""
1626

@@ -21,7 +31,10 @@ def _raise_rule_templating_error(message: str) -> NoReturn:
2131

2232

2333
T = TypeVar("T", bound=JSONable)
24-
ENVIRONMENT = jinja2.Environment(autoescape=False)
34+
ENVIRONMENT = jinja2.Environment(
35+
autoescape=jinja2.select_autoescape(default_for_string=False),
36+
undefined=PreserveTemplateUndefined,
37+
)
2538
ENVIRONMENT.globals["repr"] = repr
2639
ENVIRONMENT.globals["str"] = str
2740
ENVIRONMENT.globals["raise"] = _raise_rule_templating_error

0 commit comments

Comments
 (0)