|
|
@@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Date;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.List;
|
|
|
@@ -105,12 +106,24 @@ public class AssessmentReportController {
|
|
|
public Result<DanAssessmentResult> uploadReport(
|
|
|
@RequestParam("file") MultipartFile file,
|
|
|
@RequestParam("memberId") Long memberId,
|
|
|
- @RequestParam(value = "notes", required = false) String notes) {
|
|
|
+ @RequestParam(value = "notes", required = false) String notes,
|
|
|
+ HttpServletResponse response) {
|
|
|
|
|
|
if (file == null || file.isEmpty()) {
|
|
|
return Result.error("文件不能为空");
|
|
|
}
|
|
|
|
|
|
+ // 【SEC-20261031-01】上传类型校验:仅允许 PDF,非 PDF 按安全契约返回 HTTP 415
|
|
|
+ String contentType = file.getContentType();
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ boolean badFilename = originalFilename != null && !originalFilename.isEmpty()
|
|
|
+ && !originalFilename.toLowerCase().endsWith(".pdf");
|
|
|
+ boolean badContentType = contentType == null || !contentType.equalsIgnoreCase("application/pdf");
|
|
|
+ if (badFilename && badContentType) {
|
|
|
+ response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
|
|
|
+ return Result.error("仅支持PDF文件");
|
|
|
+ }
|
|
|
+
|
|
|
String filePath = fileStorageService.store(file, "assessment-reports");
|
|
|
if (filePath == null) {
|
|
|
return Result.error("文件上传失败");
|