Skip to content

Commit

Permalink
add validation funcion
Browse files Browse the repository at this point in the history
  • Loading branch information
lxning committed Oct 6, 2023
1 parent 2c9f6c3 commit eae1ff8
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ private void setupModelDependencies(Model model)
null);

ProcessBuilder processBuilder = new ProcessBuilder(commandParts);
if (dependencyPath
.toPath()
.normalize()
.startsWith(FileUtils.getTempDirectory().toPath().normalize())) {
if (isValidDependencyPath(dependencyPath)) {
processBuilder.directory(dependencyPath);

Check failure

Code scanning / CodeQL

Uncontrolled command line Critical

This command line depends on a
user-provided value
.
} else {
throw new ModelException(
Expand Down Expand Up @@ -285,6 +282,16 @@ private void setupModelDependencies(Model model)
}
}

private boolean isValidDependencyPath(File dependencyPath) {
if (dependencyPath
.toPath()
.normalize()
.startsWith(FileUtils.getTempDirectory().toPath().normalize())) {
return true;
}
return false;
}

private Model createModel(
ModelArchive archive,
int batchSize,
Expand Down

0 comments on commit eae1ff8

Please sign in to comment.