fix(deploy): fix security
This commit is contained in:
@@ -92,8 +92,9 @@ public class SlicerService {
|
|||||||
// 3. Run slicer. Retry with arrange only for out-of-volume style failures.
|
// 3. Run slicer. Retry with arrange only for out-of-volume style failures.
|
||||||
for (boolean useArrange : new boolean[]{false, true}) {
|
for (boolean useArrange : new boolean[]{false, true}) {
|
||||||
// Build process arguments explicitly to avoid shell interpretation and command injection.
|
// Build process arguments explicitly to avoid shell interpretation and command injection.
|
||||||
ProcessBuilder pb = new ProcessBuilder(trustedSlicerPath);
|
ProcessBuilder pb = new ProcessBuilder();
|
||||||
List<String> command = pb.command();
|
List<String> command = pb.command();
|
||||||
|
command.add(trustedSlicerPath);
|
||||||
command.add("--load-settings");
|
command.add("--load-settings");
|
||||||
command.add(machineProfilePath);
|
command.add(machineProfilePath);
|
||||||
command.add("--load-settings");
|
command.add("--load-settings");
|
||||||
@@ -162,17 +163,17 @@ public class SlicerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ModelDimensions> inspectModelDimensions(File inputModel) {
|
public Optional<ModelDimensions> inspectModelDimensions(File inputModel) {
|
||||||
Path tempDir = null;
|
Path tempDir = null;
|
||||||
try {
|
try {
|
||||||
tempDir = Files.createTempDirectory("slicer_info_");
|
tempDir = Files.createTempDirectory("slicer_info_");
|
||||||
Path infoLogPath = tempDir.resolve("orcaslicer-info.log");
|
Path infoLogPath = tempDir.resolve("orcaslicer-info.log");
|
||||||
String inputModelPath = requireSafeArgument(inputModel.getAbsolutePath(), "input model path");
|
String inputModelPath = requireSafeArgument(inputModel.getAbsolutePath(), "input model path");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(
|
ProcessBuilder pb = new ProcessBuilder();
|
||||||
trustedSlicerPath,
|
List<String> infoCommand = pb.command();
|
||||||
"--info",
|
infoCommand.add(trustedSlicerPath);
|
||||||
inputModelPath
|
infoCommand.add("--info");
|
||||||
);
|
infoCommand.add(inputModelPath);
|
||||||
pb.directory(tempDir.toFile());
|
pb.directory(tempDir.toFile());
|
||||||
pb.redirectErrorStream(true);
|
pb.redirectErrorStream(true);
|
||||||
pb.redirectOutput(infoLogPath.toFile());
|
pb.redirectOutput(infoLogPath.toFile());
|
||||||
|
|||||||
Reference in New Issue
Block a user