File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed
python/ql/test/experimental
library-tests/frameworks/django-v1 Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change 1
- | response_test.py:21:12:21:56 | ControlFlowNode for HttpResponseRedirect() | Unexpected result: mimetype=text/html; charset=utf-8 |
2
- | response_test.py:21:59:21:132 | Comment # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute() | Missing result:mimetype=text/html; |
3
- | response_test.py:25:12:25:56 | ControlFlowNode for HttpResponseNotFound() | Unexpected result: mimetype=text/html; charset=utf-8 |
4
- | response_test.py:25:59:25:132 | Comment # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute() | Missing result:mimetype=text/html; |
5
- | response_test.py:32:16:32:29 | ControlFlowNode for HttpResponse() | Unexpected result: mimetype=text/html; charset=utf-8 |
6
- | response_test.py:32:32:32:80 | Comment # $HttpResponse mimetype=text/html; charset=utf-8 | Missing result:mimetype=text/html; |
7
- | response_test.py:33:5:33:43 | ControlFlowNode for Attribute() | Unexpected result: mimetype=text/html; charset=utf-8 |
8
- | response_test.py:33:46:33:119 | Comment # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute() | Missing result:mimetype=text/html; |
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ def safe__manual_content_type(request):
18
18
# XSS FP reported in https://github.com/github/codeql/issues/3466
19
19
# Note: This should be an open-redirect sink, but not an XSS sink.
20
20
def or__redirect (request ):
21
- return HttpResponseRedirect (request .GET .get ("next" )) # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute()
21
+ return HttpResponseRedirect (request .GET .get ("next" )) # $HttpResponse mimetype=" text/html; charset=utf-8" responseBody=Attribute()
22
22
23
23
# Ensure that simple subclasses are still vuln to XSS
24
24
def xss__not_found (request ):
25
- return HttpResponseNotFound (request .GET .get ("name" )) # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute()
25
+ return HttpResponseNotFound (request .GET .get ("name" )) # $HttpResponse mimetype=" text/html; charset=utf-8" responseBody=Attribute()
26
26
27
27
# Ensure we still have an XSS sink when manually setting the content_type to HTML
28
28
def xss__manual_response_type (request ):
29
29
return HttpResponse (request .GET .get ("name" ), content_type = "text/html; charset=utf-8" ) # $HttpResponse mimetype=text/html responseBody=Attribute()
30
30
31
31
def xss__write (request ):
32
- response = HttpResponse () # $HttpResponse mimetype=text/html; charset=utf-8
33
- response .write (request .GET .get ("name" )) # $HttpResponse mimetype=text/html; charset=utf-8 responseBody=Attribute()
32
+ response = HttpResponse () # $HttpResponse mimetype=" text/html; charset=utf-8"
33
+ response .write (request .GET .get ("name" )) # $HttpResponse mimetype=" text/html; charset=utf-8" responseBody=Attribute()
34
34
35
35
# This is safe but probably a bug if the argument to `write` is not a result of `json.dumps` or similar.
36
36
def safe__write_json (request ):
Original file line number Diff line number Diff line change @@ -178,7 +178,14 @@ class HttpServerHttpResponseTest extends InlineExpectationsTest {
178
178
exists ( HTTP:: Server:: HttpResponse response |
179
179
___location = response .getLocation ( ) and
180
180
element = response .toString ( ) and
181
- value = response .getMimetype ( ) and
181
+ // Ensure that an expectation value such as "mimetype=text/html; charset=utf-8" is parsed as a
182
+ // single expectation with tag mimetype, and not as two expecations with tags mimetype and
183
+ // charset.
184
+ (
185
+ if exists ( response .getMimetype ( ) .indexOf ( " " ) )
186
+ then value = "\"" + response .getMimetype ( ) + "\""
187
+ else value = response .getMimetype ( )
188
+ ) and
182
189
tag = "mimetype"
183
190
)
184
191
)
You can’t perform that action at this time.
0 commit comments