Skip to content
Myr

sandbox disallows `clear` and `pop` on mutable sequence (#2033)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 1dc04bc, b512058 · Browse files · 3 files+7 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+7 added−1 removed

  • tests:+2 added−0 removed
  • other:+5 added−1 removed

3 files+7 added−1 removed

modified:src/jinja2/sandbox.py+3 added-1 removed
58 unmodified lines
59 frozenset(["clear", "pop", "popitem", "setdefault", "update"]),60 ),61 (62 abc.MutableSequence,63 frozenset(["append", "reverse", "insert", "sort", "extend", "remove"]),63 frozenset(64 ["append", "clear", "pop", "reverse", "insert", "sort", "extend", "remove"]65 ),66 ),67 (68 deque,69 frozenset(
362 unmodified lines
modified:tests/test_security.py+2 added
56 unmodified lines
5758 def test_immutable_environment(self, env):59 env = ImmutableSandboxedEnvironment()60 pytest.raises(SecurityError, env.from_string("{{ [].append(23) }}").render)61 pytest.raises(SecurityError, env.from_string("{{ [].clear() }}").render)62 pytest.raises(SecurityError, env.from_string("{{ [1].pop() }}").render)63 pytest.raises(SecurityError, env.from_string("{{ {1:2}.clear() }}").render)6465 def test_restricted(self, env):66 env = SandboxedEnvironment()
109 unmodified lines
modified:CHANGES.rst+2 added
24 unmodified lines
25- Fix dunder protocol (`copy`/`pickle`/etc) interaction with ``Undefined``26 objects. :issue:`2025`27- Fix `copy`/`pickle` support for the internal ``missing`` object.28 :issue:`2027`29- Sandbox does not allow ``clear`` and ``pop`` on known mutable sequence30 types. :issue:`2032`313233Version 3.1.434-------------
994 unmodified lines