@@ -134,6 +134,9 @@ public class UploadDataUseCase {
134134 @ Value ("${file.prefix.small:small}" )
135135 private String small ;
136136
137+ @ Value ("${upload.url.whitelist}" )
138+ private String whitelist ;
139+
137140 private static final ExecutorService executorService = ThreadUtil .newExecutor (2 );
138141 private static final ExecutorService parseExecutorService = ThreadUtil .newExecutor (5 );
139142
@@ -156,6 +159,11 @@ public class UploadDataUseCase {
156159 @ Transactional (rollbackFor = RuntimeException .class )
157160 public Long upload (DataInfoUploadBO dataInfoUploadBO ) {
158161 var uploadRecordBO = uploadUseCase .createUploadRecord (dataInfoUploadBO .getFileUrl ());
162+ if (!checkUrlIsValid (whitelist ,dataInfoUploadBO .getFileUrl ())){
163+ uploadUseCase .updateUploadRecordStatus (uploadRecordBO .getId (), FAILED , DATASET_DATA_FILE_URL_ILLEGAL .getMessage ());
164+ log .error ("File url illegal,datasetId:{},userId:{},fileUrl:{}" , dataInfoUploadBO .getDatasetId (), dataInfoUploadBO .getUserId (), dataInfoUploadBO .getFileUrl ());
165+ return uploadRecordBO .getSerialNumber ();
166+ }
159167 var boo = DecompressionFileUtils .validateUrl (dataInfoUploadBO .getFileUrl ());
160168 if (!boo ) {
161169 uploadUseCase .updateUploadRecordStatus (uploadRecordBO .getId (), FAILED , DATASET_DATA_FILE_URL_ERROR .getMessage ());
@@ -195,6 +203,20 @@ public Long upload(DataInfoUploadBO dataInfoUploadBO) {
195203 return uploadRecordBO .getSerialNumber ();
196204 }
197205
206+
207+ public static boolean checkUrlIsValid (String whitelist , String url ) {
208+ if (StrUtil .isEmpty (whitelist )){
209+ return true ;
210+ }
211+ String [] substrings = whitelist .split ("," );
212+ for (String substring : substrings ) {
213+ if (url .contains (substring .trim ())) {
214+ return true ;
215+ }
216+ }
217+ return false ;
218+ }
219+
198220 /**
199221 * Download the file and unzip the file
200222 *
0 commit comments