Skip to content

Commit

Permalink
feat: use sandboxed Jinja env for slightly elevated security (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Aug 7, 2024
1 parent 2205928 commit 79c13e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rattler_build_conda_compat/jinja/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import jinja2
import yaml
from jinja2.sandbox import SandboxedEnvironment

from rattler_build_conda_compat.jinja.filters import _bool, _split, _version_to_build_string
from rattler_build_conda_compat.jinja.objects import (
Expand All @@ -23,13 +24,13 @@ class RecipeWithContext(TypedDict, total=False):
context: dict[str, str]


def jinja_env() -> jinja2.Environment:
def jinja_env() -> SandboxedEnvironment:
"""
Create a `rattler-build` specific Jinja2 environment with modified syntax.
Target platform, build platform, and mpi are set to linux-64 by default.
"""

env = jinja2.Environment(
env = SandboxedEnvironment(
variable_start_string="${{",
variable_end_string="}}",
trim_blocks=True,
Expand Down

0 comments on commit 79c13e7

Please sign in to comment.