【发布时间】:2021-05-03 11:15:06
【问题描述】:
我正在构建一个 Spring Boot 应用程序,我需要在其中读取 json 文件以进行组件测试。我有一个实用方法,它采用文件名并使用 ResourceUtils 读取内容。代码如下:
public static String getContent(String path) throws IOException {
File file = ResourceUtils.getFile(MyTest.class.getResource(path));
String content = new String(Files.readAllBytes(file.toPath()));
return content;
}
checkmarx 将上述代码报告为“这可能会导致路径 遍历漏洞。” 如何解决这个问题?
谢谢
【问题讨论】:
标签: spring-boot spring-mvc checkmarx