gpt4 book ai didi

java - CWE-73 : External Control of File Name or Path Veracode java solution

转载 作者:行者123 更新时间:2023-12-01 19:31:38 25 4
gpt4 key购买 nike

有人可以帮我了解以下 Vera 代码 jar 装错误的 java 编码解决方案吗?

我正在创建一个文件并将文件位置作为参数传递。

File file1=new File(filePath);
**CWE-73: External Control of File Name or Path**

最佳答案

您可以使用:

Validator validator = ESAPI.validator();
validator.getValidDirectoryPath(..) // to validate the directory path
validator.getValidFileName(...) // to validate the file name

然后使用它们来创建您的文件

关于java - CWE-73 : External Control of File Name or Path Veracode java solution,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39194424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com