12725N/Aslightly modified to adjust for gpatch fuzz for application to Kilo.
12725N/AFrom d585e5eb9acf92d10d39b6c2038917a7e8ac71bb Mon Sep 17 00:00:00 2001
12725N/AFrom: Richard Jones <r1chardj0n3s@gmail.com>
12725N/ADate: Tue, 3 May 2016 15:51:49 +1000
12725N/ASubject: [PATCH] Escape angularjs templating in unsafe HTML
12725N/AThis code extends the unsafe (typically user-supplied) HTML escape
12725N/Abuilt into Django to also escape angularjs templating markers. Safe
Change-Id: I0cbebfd0f814bdf1bf8c06833abf33cc2d4748e7
(cherry picked from commit 4bc01cedf39cdeff2553d01cdace707a1ecf6620)
3 files changed, 40 insertions(+)
+# Copyright 2016, Rackspace, US, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ # Replace our angular markup string with a different string
+ # (which just happens to be the Django comment string)
+ # this prevents user-supplied data from being intepreted in
+ # our pages by angularjs, thus preventing it from being used
+ # for XSS attacks. Note that we use {$ $} instead of the
+ # angularjs module through $interpolateProvider
+ return existing(text).replace('{$', '{%').replace('$}', '%}')
+# this will be invoked as early as possible in
settings.py+def monkeypatch_escape():
index 5761a91..803b079 100644
@@ -27,6 +27,9 @@ from openstack_dashboard import exceptions
from openstack_dashboard import exceptions
'%s: %s' % (category.__name__, message)
index 1926644..45f1d06 100644
@@ -17,6 +17,12 @@ from openstack_dashboard import exceptions
from openstack_dashboard import exceptions
+# this is used to protect from client XSS attacks, but it's worth
+# enabling in our test setup to find any issues it might cause
STATICFILES_DIRS = get_staticfiles_dirs()