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):
1818# XSS FP reported in https://github.com/github/codeql/issues/3466
1919# Note: This should be an open-redirect sink, but not an XSS sink.
2020def 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()
2222
2323# Ensure that simple subclasses are still vuln to XSS
2424def 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()
2626
2727# Ensure we still have an XSS sink when manually setting the content_type to HTML
2828def xss__manual_response_type (request ):
2929 return HttpResponse (request .GET .get ("name" ), content_type = "text/html; charset=utf-8" ) # $HttpResponse mimetype=text/html responseBody=Attribute()
3030
3131def 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()
3434
3535# This is safe but probably a bug if the argument to `write` is not a result of `json.dumps` or similar.
3636def safe__write_json (request ):
Original file line number Diff line number Diff line change @@ -178,7 +178,14 @@ class HttpServerHttpResponseTest extends InlineExpectationsTest {
178178 exists ( HTTP:: Server:: HttpResponse response |
179179 location = response .getLocation ( ) and
180180 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
182189 tag = "mimetype"
183190 )
184191 )
You can’t perform that action at this time.
0 commit comments