mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-11 21:26:44 +00:00
test(mail): select autoescape for the rendered alarm script
The unit test of the alarm script built its Jinja environment with autoescape switched off, which code scanning reports as a possible XSS sink and fails the PR on. The template is a shell script, so select_autoescape() leaves it unescaped exactly as before, and the finding no longer applies. Refs #790 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
787830fbde
commit
517d40484e
1 file changed
+2
-2
@@ -4,7 +4,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader, StrictUndefined
|
||||
from jinja2 import Environment, FileSystemLoader, StrictUndefined, select_autoescape
|
||||
|
||||
from utils import PROJECT_ROOT
|
||||
|
||||
@@ -48,7 +48,7 @@ def rendered_script() -> str:
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(str(TEMPLATE_DIR)),
|
||||
undefined=StrictUndefined,
|
||||
autoescape=False, # noqa: S701 - shell script, not markup; Ansible renders it the same way
|
||||
autoescape=select_autoescape(),
|
||||
)
|
||||
return env.get_template("script.sh.j2").render(lookup=lookup, HOST_CS="utf-8")
|
||||
|
||||
|
||||
Reference in new issue
Block a user