@@ -6,7 +6,11 @@ import semmle.python.web.Http
6
6
// a FunctionValue, so we can't use `FunctionValue.getArgumentForCall`
7
7
// https://github.com/django/django/blob/master/django/urls/conf.py#L76
8
8
abstract class DjangoRoute extends CallNode {
9
- abstract FunctionValue getViewFunction ( ) ;
9
+ FunctionValue getViewFunction ( ) {
10
+ result = this .getArg ( 1 ) .pointsTo ( )
11
+ or
12
+ result = this .getArgByName ( "view" ) .pointsTo ( )
13
+ }
10
14
11
15
abstract string getANamedArgument ( ) ;
12
16
@@ -25,14 +29,12 @@ class DjangoRouteRegex extends RegexString {
25
29
26
30
class DjangoRegexRoute extends DjangoRoute {
27
31
ControlFlowNode route ;
28
- FunctionValue view ;
29
32
30
33
DjangoRegexRoute ( ) {
31
34
exists ( FunctionValue route_maker |
32
- // Django 1.x
35
+ // Django 1.x: https://docs.djangoproject.com/en/1.11/ref/urls/#django.conf.urls.url
33
36
Value:: named ( "django.conf.urls.url" ) = route_maker and
34
- route_maker .getArgumentForCall ( this , 0 ) = route and
35
- route_maker .getArgumentForCall ( this , 1 ) .pointsTo ( view )
37
+ route_maker .getArgumentForCall ( this , 0 ) = route
36
38
)
37
39
or
38
40
// Django 2.x and 3.x: https://docs.djangoproject.com/en/3.0/ref/urls/#re-path
@@ -41,16 +43,9 @@ class DjangoRegexRoute extends DjangoRoute {
41
43
route = this .getArg ( 0 )
42
44
or
43
45
route = this .getArgByName ( "route" )
44
- ) and
45
- (
46
- this .getArg ( 1 ) .pointsTo ( view )
47
- or
48
- this .getArgByName ( "view" ) .pointsTo ( view )
49
46
)
50
47
}
51
48
52
- override FunctionValue getViewFunction ( ) { result = view }
53
-
54
49
ControlFlowNode getRouteArg ( ) { result = route }
55
50
56
51
override string getANamedArgument ( ) {
@@ -69,7 +64,6 @@ class DjangoRegexRoute extends DjangoRoute {
69
64
70
65
class DjangoPathRoute extends DjangoRoute {
71
66
ControlFlowNode route ;
72
- FunctionValue view ;
73
67
74
68
DjangoPathRoute ( ) {
75
69
// Django 2.x and 3.x: https://docs.djangoproject.com/en/3.0/ref/urls/#path
@@ -78,16 +72,9 @@ class DjangoPathRoute extends DjangoRoute {
78
72
route = this .getArg ( 0 )
79
73
or
80
74
route = this .getArgByName ( "route" )
81
- ) and
82
- (
83
- this .getArg ( 1 ) .pointsTo ( view )
84
- or
85
- this .getArgByName ( "view" ) .pointsTo ( view )
86
75
)
87
76
}
88
77
89
- override FunctionValue getViewFunction ( ) { result = view }
90
-
91
78
override string getANamedArgument ( ) {
92
79
// regexp taken from django:
93
80
// https://github.com/django/django/blob/7d1bf29977bb368d7c28e7c6eb146db3b3009ae7/django/urls/resolvers.py#L199
0 commit comments