Explorar el Código

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

Romain Rigaux hace 9 años
padre
commit
a3c5943
Se han modificado 2 ficheros con 6 adiciones y 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

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4 - 4
apps/search/src/search/tests.py


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio