Fortify 在进行新文件(路径)比较的线路上给出路径操作错误。我正在使用 Struts 2。
谁能告诉我如何解决这个问题,以便 fortify 不会给出这个错误?
private boolean filePresent(String fileName) {
if (fileName != null) {
String path = getDirPath();
if (path != null) {
path = path.endsWith("/") ? path : path + "/";
path = path + fileName;
if (new File(path).exists()) {
setFileName(fileName);
return true;
}
}
}
return false;
}
我需要查看该文件是否存在于我们的 Web 服务器中,因此我将文件名作为参数传递,从 web.xml 获取整个目录路径,将其附加到文件名中,然后组合路径并检查它针对 File 对象查看它是否存在。