OCT REM: 1. 增加输入路径合法性校验
This commit is contained in:
parent
545ae65db8
commit
c763477a31
|
@ -227,7 +227,13 @@ public class MiddlewareManagerServiceImpl implements MiddlewareManagerService {
|
|||
private MulReturnType<ErrorCode, String> downloadAndValidateFiles(String workDir, List<RemoteFileDetails> configFiles) {
|
||||
for (RemoteFileDetails file : configFiles) {
|
||||
try {
|
||||
String saveName = Paths.get(workDir + File.separator + file.getFileName()).toString();
|
||||
Path path = Paths.get(workDir + File.separator + file.getFileName());
|
||||
String saveName = path.normalize().toString();
|
||||
|
||||
if (!saveName.startsWith(workDir + File.separator)) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_INPUTFORMAT, file.fileName);
|
||||
}
|
||||
|
||||
/* Http Download Usage: new FileDownloader(file.getUrl(), saveName).downloadFile(); */
|
||||
OssService service = ossFactory.getOssService();
|
||||
service.download(new URL(file.getUrl()), new File(saveName));
|
||||
|
|
Loading…
Reference in New Issue