This repository was archived by the owner on Aug 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
frontend/server/src/main/java/org/pytorch/serve/wlm Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 20
20
import java .util .concurrent .ExecutionException ;
21
21
import java .util .concurrent .Executors ;
22
22
import java .util .concurrent .ScheduledExecutorService ;
23
+ import org .apache .commons .io .FileUtils ;
23
24
import org .pytorch .serve .archive .DownloadArchiveException ;
24
25
import org .pytorch .serve .archive .model .Manifest ;
25
26
import org .pytorch .serve .archive .model .ModelArchive ;
@@ -238,7 +239,14 @@ private void setupModelDependencies(Model model)
238
239
null );
239
240
240
241
ProcessBuilder processBuilder = new ProcessBuilder (commandParts );
241
- processBuilder .directory (model .getModelDir ().getAbsoluteFile ());
242
+ if (isValidDependencyPath (dependencyPath )) {
243
+ processBuilder .directory (dependencyPath );
244
+ } else {
245
+ throw new ModelException (
246
+ "Invalid 3rd party package installation path "
247
+ + dependencyPath .getCanonicalPath ());
248
+ }
249
+
242
250
Map <String , String > environment = processBuilder .environment ();
243
251
for (String envVar : envp ) {
244
252
String [] parts = envVar .split ("=" , 2 );
@@ -274,6 +282,16 @@ private void setupModelDependencies(Model model)
274
282
}
275
283
}
276
284
285
+ private boolean isValidDependencyPath (File dependencyPath ) {
286
+ if (dependencyPath
287
+ .toPath ()
288
+ .normalize ()
289
+ .startsWith (FileUtils .getTempDirectory ().toPath ().normalize ())) {
290
+ return true ;
291
+ }
292
+ return false ;
293
+ }
294
+
277
295
private Model createModel (
278
296
ModelArchive archive ,
279
297
int batchSize ,
You can’t perform that action at this time.
0 commit comments