github / github/codeql

A security issue that codeql cannot detect

Đang mở
#12,473 8 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**A security issue that codeql cannot detect**

A file upload cannot be detected by codeql using the transferTo function
```java
public static File uploadFile(MultipartFile fileUploader) {
if (fileUploader != null && !fileUploader.isEmpty()) {
String fileNameString = fileUploader.getOriginalFilename();
if (!fileNameString.contains(".")) {
throw new RuntimeException("文件后缀获取不到");
} else if (10485760L < fileUploader.getSize()) {
throw new RuntimeException("文件大小不支持大于10M");
} else {
String fileSuffix = fileNameString.substring(fileNameString.lastIndexOf(".") + 1);
String uuid = UUIDUtils.getUuid();
String newFileName = uuid + "." + fileSuffix;
String tmpPath = uploadFilePath + File.separator + newFileName;
File tmpFile = new File(tmpPath);

try {
fileUploader.transferTo(tmpFile);
return tmpFile;
} catch (Exception var8) {
throw new RuntimeException("系统异常:上传失败,请查看日志");
}
}
} else {
throw new RuntimeException("上传文件不能为空");
}
}
```
can you tell me how to solve it

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.