Skip to content

Commit c4285f7

Browse files
committed
Change jinja environment to be SandboxedEnvironment
This to remove the need to enabled autoescape Signed-off-by: Luca Carrogu <[email protected]>
1 parent e061f46 commit c4285f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm/slurm/pcluster_slurm_config_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
import requests
2323
import yaml
24-
from jinja2 import Environment, FileSystemLoader
24+
from jinja2 import FileSystemLoader
25+
from jinja2.sandbox import SandboxedEnvironment
2526

2627
log = logging.getLogger()
2728
instance_types_data = {}
@@ -185,7 +186,7 @@ def _get_jinja_env(template_directory, realmemory_to_ec2memory_ratio):
185186
# A nosec comment is appended to the following line in order to disable the B701 check.
186187
# The contents of the default templates are known and the input configuration data is
187188
# validated by the CLI.
188-
env = Environment(loader=file_loader, trim_blocks=True, lstrip_blocks=True) # nosec nosemgrep
189+
env = SandboxedEnvironment(loader=file_loader, trim_blocks=True, lstrip_blocks=True) # nosec nosemgrep
189190
env.filters["sanify_name"] = lambda value: re.sub(r"[^A-Za-z0-9]", "", value)
190191
env.filters["gpus"] = _gpus
191192
env.filters["vcpus"] = _vcpus

0 commit comments

Comments
 (0)