我是CheckMarx的新手,可以防止XSS攻击。我得到这个错误:CheckMarx - 跨站点脚本攻击
Method %> at line 1 of \app\src\web\searchresults.jsp gets user input for the getSearchResults element. This element’s value then flows through the code without being properly sanitized or validated and is eventually displayed to the user in method %> at line 1 of \app\src\web\searchresults.jsp. This may enable a Cross-Site-Scripting attack.
这是它在下面的代码剪断抱怨行:
<c:forEach var="combo" items="${searchForm.searchResults}">
代码剪断从searchresults.jsp(修改后的代码,以保护无辜)
<% int i = 0;%>
<c:forEach var="combo" items="${searchForm.searchResults}">
<tr <%=i++%2==0?"":"class='odd'"%>>
<td align="center" style="width: 40px;"><c:out value="${combo.stay.status}"/></td>
<c:choose>
<c:when test="${hasDetailAccess}">
<c:url var="detailLink" value="/detail.do">
<c:param name="code" value="${searchForm.code}"/>
<c:param name="brandCode" value="${searchForm.brandCode}"/>
<c:param name="smUni" value="${combo.object1.smUni}"/>
<c:param name="shUni" value="${combo.object1.shUni}"/>
<c:param name="searchType" value="${searchForm.searchType}"/>
</c:choose>
<td style="width: 80px;"><fmt:formatDate pattern="MMM dd yyyy" value="${combo.object1.dateMade.date}"/></td>
<td style="width: 80px;"><c:out value="${combo.object1.lastName}"/></td>
<td style="width: 80px;"><c:out value="${combo.object1.firstName}"/></td>
</c:forEach>
,我不是肯定的如何解决的部分是,“searchForm.searchResults”是可以引用多个对象,这种情况下,“object1”的queueCombo。
我的想法是对物体进行清理。我这样做的方法是添加页面使用的所需属性(因为“object1”是大量的属性),并将其作为单个值并在构建对象时填充它们。