summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2024-11-08 21:27:31 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-04 13:47:31 +0100
commit6943d61818e63e77b65d8b1ae65941e8f04bd87b (patch)
treef9ef7f720bcde4fd310a46bcfa25530cb195cbfa /tests/model_fields
parentbbc74a7f7eb7335e913bdb4787f22e83a9be947e (diff)
[5.1.x] Fixed CVE-2024-53908 -- Prevented SQL injections in direct HasKeyLookup usage on Oracle.
Thanks Seokchan Yoon for the report, and Mariusz Felisiak and Sarah Boyce for the reviews.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_jsonfield.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
index ff42b1a14c..e517ef6826 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -29,6 +29,7 @@ from django.db.models import (
from django.db.models.expressions import RawSQL
from django.db.models.fields.json import (
KT,
+ HasKey,
KeyTextTransform,
KeyTransform,
KeyTransformFactory,
@@ -582,6 +583,14 @@ class TestQuerying(TestCase):
[expected],
)
+ def test_has_key_literal_lookup(self):
+ self.assertSequenceEqual(
+ NullableJSONModel.objects.filter(
+ HasKey(Value({"foo": "bar"}, JSONField()), "foo")
+ ).order_by("id"),
+ self.objs,
+ )
+
def test_has_key_list(self):
obj = NullableJSONModel.objects.create(value=[{"a": 1}, {"b": "x"}])
tests = [