@@ -4,38 +4,20 @@ import semmle.python.security.strings.Basic
44private import semmle.python.web.django.Shared
55private import semmle.python.web.Http
66
7- /**
8- * A django.http.response.Response object
9- * This isn't really a "taint", but we use the value tracking machinery to
10- * track the flow of response objects.
11- */
12- class DjangoResponse extends TaintKind {
13- DjangoResponse ( ) { this = "django.response.HttpResponse" }
7+ /** INTERNAL class used for tracking a django response object. */
8+ private class DjangoResponseKind extends TaintKind {
9+ DjangoResponseKind ( ) { this = "django.response.HttpResponse" }
1410}
1511
16- private ClassValue theDjangoHttpResponseClass ( ) {
17- (
18- // version 1.x
19- result = Value:: named ( "django.http.response.HttpResponse" )
20- or
21- // version 2.x
22- // https://docs.djangoproject.com/en/2.2/ref/request-response/#httpresponse-objects
23- result = Value:: named ( "django.http.HttpResponse" )
24- ) and
25- // TODO: does this do anything? when could they be the same???
26- not result = theDjangoHttpRedirectClass ( )
27- }
28-
29- /** internal class used for tracking a django response. */
12+ /** INTENRAL taint-source used for tracking a django response. */
3013private class DjangoResponseSource extends TaintSource {
3114 DjangoResponseSource ( ) {
32- exists ( ClassValue cls |
33- cls .getASuperType ( ) = theDjangoHttpResponseClass ( ) and
15+ exists ( DjangoXSSVulnResponse cls |
3416 cls .getACall ( ) = this
3517 )
3618 }
3719
38- override predicate isSourceOf ( TaintKind kind ) { kind instanceof DjangoResponse }
20+ override predicate isSourceOf ( TaintKind kind ) { kind instanceof DjangoResponseKind }
3921
4022 override string toString ( ) { result = "django.http.response.HttpResponse" }
4123}
@@ -45,7 +27,7 @@ class DjangoResponseWrite extends HttpResponseTaintSink {
4527 DjangoResponseWrite ( ) {
4628 exists ( AttrNode meth , CallNode call |
4729 call .getFunction ( ) = meth and
48- any ( DjangoResponse response ) .taints ( meth .getObject ( "write" ) ) and
30+ any ( DjangoResponseKind response ) .taints ( meth .getObject ( "write" ) ) and
4931 this = call .getArg ( 0 )
5032 )
5133 }
@@ -58,9 +40,8 @@ class DjangoResponseWrite extends HttpResponseTaintSink {
5840/** An argument to initialization of a django response, which is vulnerable to external data (xss) */
5941class DjangoResponseContent extends HttpResponseTaintSink {
6042 DjangoResponseContent ( ) {
61- exists ( CallNode call , ClassValue cls |
62- cls .getASuperType ( ) = theDjangoHttpResponseClass ( ) and
63- call .getFunction ( ) .pointsTo ( cls )
43+ exists ( CallNode call , DjangoXSSVulnResponse cls |
44+ call = cls .getACall ( )
6445 |
6546 call .getArg ( 0 ) = this
6647 or
@@ -75,7 +56,7 @@ class DjangoResponseContent extends HttpResponseTaintSink {
7556
7657class DjangoCookieSet extends CookieSet , CallNode {
7758 DjangoCookieSet ( ) {
78- any ( DjangoResponse r ) .taints ( this .getFunction ( ) .( AttrNode ) .getObject ( "set_cookie" ) )
59+ any ( DjangoResponseKind r ) .taints ( this .getFunction ( ) .( AttrNode ) .getObject ( "set_cookie" ) )
7960 }
8061
8162 override string toString ( ) { result = CallNode .super .toString ( ) }
0 commit comments