Skip to content

Commit 6ca7301

Browse files
Potential fix for code scanning alert no. 428: Jinja2 templating with autoescape=False
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Hemil Desai <[email protected]> Signed-off-by: Hemil Desai <[email protected]>
1 parent dc65031 commit 6ca7301

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

nemo_run/core/execution/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Optional
1818

1919
import jinja2
20+
from jinja2 import select_autoescape
2021

2122

2223
def fill_template(template_name: str, variables: dict, template_dir: Optional[str] = None) -> str:
@@ -29,8 +30,9 @@ def fill_template(template_name: str, variables: dict, template_dir: Optional[st
2930
with open(template_path, "r", encoding="utf-8") as fin:
3031
template = fin.read()
3132

32-
j2_template = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir)).from_string(
33-
template
34-
)
33+
j2_template = jinja2.Environment(
34+
loader=jinja2.FileSystemLoader(template_dir),
35+
autoescape=select_autoescape(['html', 'xml'])
36+
).from_string(template)
3537
content = j2_template.render(**variables)
3638
return content

0 commit comments

Comments
 (0)