Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb7e30d

Browse files
committed
Python: Add test of django view handler with decorator
Which we currently don't handle :( Also added a bit more explanatory comments
1 parent 8a2e063 commit eb7e30d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • python/ql/test/experimental/library-tests/frameworks/django-v2-v3

python/ql/test/experimental/library-tests/frameworks/django-v2-v3/routing_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse, HttpResponseNotFound
44
from django.views import View
55
import django.views.generic.base
6+
from django.views.decorators.http import require_GET
67

78

89
def url_match_xss(request, foo, bar, no_taint=None): # $requestHandler routedParameter=foo routedParameter=bar
@@ -105,6 +106,10 @@ def not_valid_identifier(request): # $requestHandler
105106
path("not_valid/<not_valid!>", not_valid_identifier), # $routeSetup="not_valid/<not_valid!>"
106107
]
107108

109+
################################################################################
110+
# Deprecated django.conf.urls.url
111+
################################################################################
112+
108113
# This version 1.x way of defining urls is deprecated in Django 3.1, but still works
109114
from django.conf.urls import url
110115

@@ -116,9 +121,22 @@ def deprecated(request): # $requestHandler
116121
]
117122

118123

124+
################################################################################
125+
# Special stuff
126+
################################################################################
127+
119128
class PossiblyNotRouted(View):
120129
# Even if our analysis can't find a route-setup for this class, we should still
121130
# consider it to be a handle incoming HTTP requests
122131

123132
def get(self, request, possibly_not_routed=42): # $ requestHandler routedParameter=possibly_not_routed
124133
return HttpResponse('PossiblyNotRouted get: {}'.format(possibly_not_routed)) # $HttpResponse
134+
135+
136+
@require_GET
137+
def with_decorator(request, foo): # $ MISSING: requestHandler routedParameter=foo
138+
pass
139+
140+
urlpatterns = [
141+
path("with_decorator/<foo>", with_decorator), # $ routeSetup="with_decorator/<foo>"
142+
]

0 commit comments

Comments
 (0)