问题描述
在Java中,在以下行中:
TypedQuery<T> query=entityManger.createQuery(queryString,clazz);
List<T> result =query.getResultList();
据说变量结果需要适当地过滤或编码,否则可能会导致跨站点脚本攻击。
我已经使用过HtmlUtils.htmlEscape(queryString)
字符串对象。
任何帮助和建议将不胜感激。谢谢
解决方法
Checkmarx最终将查看接收器(输出)。然后,您必须在列表中的每个结果项中执行htmlEscape
List<T> newResult = new ArrayList<T>();
for (T temp : result) {
newResult.add(HtmlUtils.htmlEscape((String) temp));
}