我收到 Fortify 错误,该错误表示 Method 向 Web 浏览器发送未经验证的数据,这可能导致浏览器执行恶意代码。 这是一个使用spring框架的java web应用程序。 Controller 类:
public class Controller {
@Autowired
public Server server;
@Autowired
public Service xxxservice;
@RequestMapping("\path1\serverId\")
@ResponseBody
public String openFile(....) {
List<FilePath> filePath= getFilePaths(server, form.getPaths.values);
FileResultResponse response = xxxservice.openFile(server, getAbsolutePath(filePath);
String jsonOutput = getOutput(response,filePath);
return jsonOutput;
服务器.java
class Server {
String serverName;
String serverDescription;
int serverId;
String serverAddress;
List<String> rootDirectories;
public void setServerName() {
this.serverName = serverName;
所有 setter 方法都可用于上述类。
报告在 getOutput 方法行抛出错误,指出在将数据发送到 Web 浏览器之前应验证 server.setName、server.setRootDirectories 等。 服务器值是通过 getFilePaths() 方法内的一些初始化方法设置的,如下
public void initialization(server,root) {
this.server=server;
this.root=root;
应如何验证这些服务器值以纠正 Fortify 扫描问题?
最佳答案
由于您没有像我一样处理字节数组,因此您可能可以尝试使用
Jsoup.clean(filePath,Whitelist.basic());
这解决了我的大部分问题,除了我需要从字节数组写入 pdf 的情况。
关于java - Fortify 扫描问题 (XSS) 跨站点脚本反射 - 方法将未经验证的数据发送到网络浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58420034/