|
6 | 6 | except ImportError: # Django < 1.10 |
7 | 7 | from django.urls import reverse |
8 | 8 |
|
| 9 | +from django.contrib.auth.models import User |
| 10 | + |
9 | 11 | from .base import TestCase |
10 | 12 |
|
11 | 13 | # Silence logging during tests |
@@ -49,3 +51,25 @@ def test_find_xss_script_tag(self): |
49 | 51 | for param in ('from', 'until'): |
50 | 52 | response = self.client.get(url, {'query': 'test', param: xssStr}) |
51 | 53 | self.assertXSS(response, status_code=400, msg_prefix='XSS detected in %s: ' % param) |
| 54 | + |
| 55 | + |
| 56 | +class ComposerMyGraphXSSTest(TestCase): |
| 57 | + def setUp(self): |
| 58 | + self.user = User.objects.create_user('testxss', 'testxss@example.com', 'pass') |
| 59 | + self.client.login(username='testxss', password='pass') |
| 60 | + |
| 61 | + def test_mygraph_xss_action(self): |
| 62 | + """Test that XSS in the action parameter is properly escaped (issue #2794)""" |
| 63 | + url = reverse('composer_mygraph') |
| 64 | + xssStr = '"><script>alert(1)</script>' |
| 65 | + |
| 66 | + response = self.client.get(url, {'action': xssStr, 'graphName': 'test'}) |
| 67 | + self.assertXSS(response, msg_prefix='XSS detected in action: ') |
| 68 | + |
| 69 | + def test_mygraph_xss_graphname(self): |
| 70 | + """Test that XSS in the graphName parameter is properly escaped (issue #2794)""" |
| 71 | + url = reverse('composer_mygraph') |
| 72 | + xssStr = '"><script>alert(1)</script>' |
| 73 | + |
| 74 | + response = self.client.get(url, {'action': 'delete', 'graphName': xssStr}) |
| 75 | + self.assertXSS(response, msg_prefix='XSS detected in graphName: ') |
0 commit comments