소스 검색

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

Romain Rigaux 9 년 전
부모
커밋
a3c5943
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  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

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 4
apps/search/src/search/tests.py


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.