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.xml中的整個目錄路徑,附加到文件名&存在或不然後編寫路徑&,根據File對象檢查它是否存在。