强化扫描问题(XSS)反映了跨站点脚本-方法将未经验证的数据发送到Web浏览器

问题描述 投票:1回答:1

我收到Fortify错误,该错误表明Method将未经验证的数据发送到Web浏览器,这可能导致浏览器执行恶意代码。这是一个使用spring框架的Java Web应用程序。控制器类:

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;

Server.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扫描问题?

java file spring-mvc xss fortify
1个回答
0
投票

由于您没有像我这样处理字节数组,可能您可以尝试使用

Jsoup.clean(filePath,Whitelist.basic());

这解决了我的大多数问题,除了需要从字节数组写入pdf的情况。

© www.soinside.com 2019 - 2024. All rights reserved.