Fority сканирование сообщило о проблемах безопасности «Путь Manipulation» в следующем фрагментеFortify Пути Манипуляция ошибка
String filePath = getFilePath(fileLocation, fileName);
final File file = new File(filePath);
LOGGER.info("Saving report at : " + filePath);
BufferedWriter fileWriter = new BufferedWriter(new FileWriter(file));
fileWriter.write(fileContent);
поэтому я проверка в черный список символов в fileLocation и бросать исключение, по-прежнему Fortify бросает исключение.
try {
String filePath = getFilePath(fileLocation, fileName);
if (isSecurePath(filePath)) {
final File file = new File(filePath);
LOGGER.info("Saving report at : " + filePath);
BufferedWriter fileWriter = new BufferedWriter(new FileWriter(file));
fileWriter.write(fileContent);
} else {
throw new Exception("Security Issue. File Path has blacklisted characters");
}
} catch (final Exception e) {
LOGGER.error("Unable to prepare mail attachment : ", e);
message = "Mail cannot be send, Unable to prepare mail attachment";
}
private boolean isSecurePath(String filePath) {
String[] blackListChars = {".."};
return (StringUtils.indexOfAny(filePath, blackListChars)< 0);
}
Должен ли я игнорировать отчет о сканировании или что было бы правильным решением для этого?
Посмотрите это также https://security.stackexchange.com/questions/103884/how-to-resolve-path-manipulation-error-given-by-fortify –