Hice un análisis de vulnerabilidad en la plataforma Veracode y encontré una vulnerabilidad XSS: Este es el código que tiene la vulnerabilidad, estoy tratando de solucionarlo, pero necesito su ayuda:
<po-widget> <div class="po-row"> <div class="treeview-container po-md-12"> <kendo-treeview class="po-md-12 po-mt-1 po-mb-1" kendoTreeViewDragAndDrop kendoTreeViewDragAndDropEditing kendoTreeViewExpandable [expand by]="'id'" [(expandedKeys)]="expandedKeys" kendoTreeViewHierarchyBinding [childrenCampo]="'children'" [(nodes)]="treeviewItems" [textField]="'name'" kendoTreeViewSelectable [(selectedKeys)]="selectedKeys" (nodeDrop)="handleDrop($event)" (removeItem)="handleRemovedNode()" (selectionChange)="handleSelection($event)" // <==== XSS vulnerability here [selectBy]="'id'" [isSelected]="isItemSelected" > La línea (selectionChange)= "handleSelection($event)" es vulnerable por la Plataforma.
Mi sugerencia para arreglar la vulnerabilidad es:
(selectionChange)= XSSfix("handleSelection($event)") function XSSfix(inputXSS){ return inputXSS.replace(/\&/g, '&').replace(/\</g, '<').replace(/\>/g, '>'); }¿Qué piensas? ¿Es correcta esta solución? ¿Es trabajo arreglar la vulnerabilidad?