Skip to content

Commit ca60132

Browse files
committed
Python: Django test: Add simple route handler and annotations
1 parent 44b9b7f commit ca60132

File tree

8 files changed

+35
-6
lines changed

8 files changed

+35
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| testapp/urls.py:6:31:6:50 | Comment # $routeSetup="foo/" | Missing result:routeSetup="foo/" |
2+
| testapp/urls.py:10:43:10:67 | Comment # $routeSetup=r"^ba[rz]/" | Missing result:routeSetup=r"^ba[rz]/" |
3+
| testapp/views.py:3:33:3:47 | Comment # $routeHandler | Missing result:routeHandler= |
4+
| testapp/views.py:6:37:6:51 | Comment # $routeHandler | Missing result:routeHandler= |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import python
2+
import experimental.meta.ConceptsTest

python/ql/test/experimental/library-tests/frameworks/django-v2-v3/TestTaint.expected

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import experimental.dataflow.tainttracking.TestTaintLib
2+
import experimental.dataflow.RemoteFlowSources
3+
4+
class RemoteFlowTestTaintConfiguration extends TestTaintTrackingConfiguration {
5+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
6+
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# to force extractor to see files under `testproj/` since we use `--max-import-depth=1`,
2-
# we use this "fake" import that doesn't actually work, but tricks the python extractor
3-
# to look at all the files
1+
# to force extractor to see files. since we use `--max-import-depth=1`, we use this
2+
# "fake" import that doesn't actually work, but tricks the python extractor to look at
3+
# all the files
44

55
from testproj import *
6+
from testapp import *
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.urls import path, re_path
2+
3+
from . import views
4+
5+
urlpatterns = [
6+
path("foo/", views.foo), # $routeSetup="foo/"
7+
# TODO: Doesn't include standard `$` to mark end of string, due to problems with
8+
# inline expectation tests (which thinks the `$` would mark the beginning of a new
9+
# line)
10+
re_path(r"^ba[rz]/", views.bar_baz), # $routeSetup=r"^ba[rz]/"
11+
]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
from django.shortcuts import render
1+
from django.http import HttpRequest, HttpResponse
22

3-
# Create your views here.
3+
def foo(request: HttpRequest): # $routeHandler
4+
return HttpResponse("foo")
5+
6+
def bar_baz(request: HttpRequest): # $routeHandler
7+
return HttpResponse("bar_baz")

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
1616
from django.contrib import admin
17-
from django.urls import path
17+
from django.urls import path, include
1818

1919
urlpatterns = [
2020
path('admin/', admin.site.urls),
21+
path("app/", include("testapp.urls")),
2122
]

0 commit comments

Comments
 (0)