经常被误用:Java和JSP文件中的文件上载
我在下面几行看到“经常被误用:文件上传”。 有人能提出解决办法吗经常被误用:Java和JSP文件中的文件上载,java,jsp,file-upload,fortify,Java,Jsp,File Upload,Fortify,我在下面几行看到“经常被误用:文件上传”。 有人能提出解决办法吗 JAVA文件: **public void setAttachedFile(FormFile formFile) { // File upload error at this line** attachedFile = formFile; if (attachedFile != null) { formData.put("attachedFile", attachedFile)
**public void setAttachedFile(FormFile formFile) { // File upload error at this line**
attachedFile = formFile;
if (attachedFile != null) {
formData.put("attachedFile", attachedFile);
} else {
formData.remove("attachedFile");
}
}
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="label" width="1%"> </td>
<td class="label" width="22%">Select File Name</td>
<td class="field" width="26%">
**<input class="textfield width450" type="file" name="File_Name" maxlength="255" value=""> // Getting the fortify here**
</td>
</tr>
</table>
选择文件名
**//在这里得到防御**
是否有人可以建议修复/解决方案您的后端代码是否已验证文件的扩展名 你的后端代码必须验证文件的扩展名,然后你可以扫描而不发出任何问题 C#中的示例如下:
enter code here string extension = Path.GetExtension(file.FileName);
enter code here if (extension.ToLower().Trim() != ".xlsx" && enter code here extension.ToLower().Trim() != ".xls")
enter code here {
enter code here throw new Exception("Check the extension!");
enter code here }
和JSP文件:
enter code here<input class="textfield width450" type="file" name="File_Name" maxlength="255" value="" accept=".xlsx,.xls">
在此处输入代码
没有修复/解决方案。这是一个警告,如果您不知道自己在做什么,您可能正在创建一个安全漏洞。这可能会提供更多信息: