fix(跟价): 指定ASIN文件提交改 fileKey + 服务端三形态解析兼容
- 前端 resolveAsinRequestPaths 改发上传返回的 fileKey(与去重/转换/采集一致), 修复安全加固后服务端按拼接解析绝对路径失败导致"ASIN 文件不存在或不可读" - Java parseAsinRowsByCountry 三种形态解析:绝对路径直读 → tempRoot 拼接 → fileKey 反查, 均过 isInsideTempDir 穿越校验,不放开临时目录外读取
This commit is contained in:
+13
-6
@@ -1463,13 +1463,20 @@ public class PriceTrackTaskService {
|
||||
if (rawPath == null || rawPath.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
// 只允许解析上传落库的临时目录文件:直接 new File(请求路径) 可被穿越读服务器任意 csv/xlsx
|
||||
File file = new File(localFileStorageService.localTempRoot().getAbsolutePath(), rawPath);
|
||||
// 上传文件路径解析(三种形态都过 isInsideTempDir 穿越校验,不放开临时目录外读取):
|
||||
// ①绝对路径:老客户端提交上传接口返回的 localPath 时按原路径直读;
|
||||
// ②相对路径/裸文件名:相对上传临时目录拼接;
|
||||
// ③fileKey/索引键:按上传索引反查临时目录(与去重/转换等模块统一的口径)。
|
||||
File file = new File(rawPath);
|
||||
if (!file.isFile()) {
|
||||
// 传入的是 fileKey/索引键时按上传索引反查临时目录
|
||||
File resolved = localFileStorageService.findLocalSourceFile(rawPath);
|
||||
if (resolved != null) {
|
||||
file = resolved;
|
||||
File joined = new File(localFileStorageService.localTempRoot().getAbsolutePath(), rawPath);
|
||||
if (joined.isFile()) {
|
||||
file = joined;
|
||||
} else {
|
||||
File resolved = localFileStorageService.findLocalSourceFile(rawPath);
|
||||
if (resolved != null) {
|
||||
file = resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!file.isFile() || !isInsideTempDir(file)) {
|
||||
|
||||
Reference in New Issue
Block a user