Explorar o código

HUE-5340 [search] Escape Solr field that have XSS injection (like <script>alert(1234)</script>)

Romain Rigaux %!s(int64=9) %!d(string=hai) anos
pai
achega
a3c5943
Modificáronse 2 ficheiros con 6 adicións e 6 borrados
  1. 2 2
      apps/search/src/search/models.py
  2. 4 4
      apps/search/src/search/tests.py

+ 2 - 2
apps/search/src/search/models.py

@@ -560,7 +560,7 @@ class Collection2(object):
           <div class="span12">%s</div>
         </div>
         <br/>
-      </div>""" % ' '.join(['{{%s}}' % field['name'] for field in fields]),
+      </div>""" % ' '.join(['{{%s}}' % escape(field['name']) for field in fields]),
       "isGridLayout": True,
       "showFieldList": True,
       "showGrid": True,
@@ -599,7 +599,7 @@ class Collection2(object):
   @classmethod
   def _make_field(cls, field, attributes):
     return {
-        'name': str(field),
+        'name': str(escape(field)),
         'type': str(attributes.get('type', '')),
         'isId': attributes.get('required') and attributes.get('uniqueKey'),
         'isDynamic': 'dynamicBase' in attributes

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 4 - 4
apps/search/src/search/tests.py


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio