|
|
@@ -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(Content-Type 或扩展名任一命中),
|
|
|
+ // 非 PDF/恶意内容直接 HTTP 415,防止进入存储/解析链路(对齐 HealthReportController 口径)
|
|
|
+ String contentType = file.getContentType();
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ boolean isPdf = (contentType != null && "application/pdf".equalsIgnoreCase(contentType))
|
|
|
+ || (originalFilename != null && originalFilename.toLowerCase().endsWith(".pdf"));
|
|
|
+ if (!isPdf) {
|
|
|
+ response.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
|
|
|
+ return Result.error(415, "仅支持PDF文件");
|
|
|
+ }
|
|
|
+
|
|
|
String filePath = fileStorageService.store(file, "assessment-reports");
|
|
|
if (filePath == null) {
|
|
|
return Result.error("文件上传失败");
|