PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: pallets/jinja (python)
Issue: `MutableSequence` coverage in `ImmutableSandboxedEnvironment`
I happened to notice in using `ImmutableSandboxedEnvironment` that the default `modifies_known_mutable` check seems to be missing coverage for a couple of methods. In particular the `clear` and `pop` methods are checked for both `MutableMapping` and `MutableSet` but not `MutableSequence`.

Example:
```python
from jinja2.sandbox import ImmutableSandboxedEnvironment

env = ImmutableSandboxedEnvironment()
print(env.from_string("{{ [1].pop() }}").render())
```

Expected: `SecurityError` should be raised
Actual: `1` is printed

Environment:

- Python version: 3.10
- Jinja version: 3.1.4

Pull request description: sandbox disallows `clear` and `pop` on mutable sequence
This PR adds the attributes `clear` and `pop` on `MutableSequence` to the default `modifies_known_mutable` check used by `ImmutableSandboxedEnvironment`.

fixes #2032

Let me know if I should add an entry to CHANGES.rst. I didn't see any previous mention of `ImmutableSandboxedEnvironment` in there so I wasn't sure if I should.

Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 1a1a526b..f48eb039 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -26,6 +26,8 @@ Unreleased
     objects. :issue:`2025`
 -   Fix `copy`/`pickle` support for the internal ``missing`` object.
     :issue:`2027`
+-   Sandbox does not allow ``clear`` and ``pop`` on known mutable sequence
+    types. :issue:`2032`
 
 
 Version 3.1.4
diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py
index ce276156..8200195d 100644
--- a/src/jinja2/sandbox.py
+++ b/src/jinja2/sandbox.py
@@ -60,7 +60,9 @@ _mutable_spec: t.Tuple[t.Tuple[t.Type[t.Any], t.FrozenSet[str]], ...] = (
     ),
     (
         abc.MutableSequence,
-        frozenset(["append", "reverse", "insert", "sort", "extend", "remove"]),
+        frozenset(
+            ["append", "clear", "pop", "reverse", "insert", "sort", "extend", "remove"]
+        ),
     ),
     (
         deque,


Test patch:
diff --git a/tests/test_security.py b/tests/test_security.py
index 0e8dc5c0..9c7c4427 100644
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -58,6 +58,8 @@ class TestSandbox:
     def test_immutable_environment(self, env):
         env = ImmutableSandboxedEnvironment()
         pytest.raises(SecurityError, env.from_string("{{ [].append(23) }}").render)
+        pytest.raises(SecurityError, env.from_string("{{ [].clear() }}").render)
+        pytest.raises(SecurityError, env.from_string("{{ [1].pop() }}").render)
         pytest.raises(SecurityError, env.from_string("{{ {1:2}.clear() }}").render)
 
     def test_restricted(self, env):