@Test public void dSaferParamInGhostScriptHelperTest() throws IOException, InterruptedException { String cmpPdf = sourceFolder + "maliciousPsInvokingCalcExe.ps"; String maliciousPsInvokingCalcExe = destinationFolder + "maliciousPsInvokingCalcExe.png"; int majorVersion = 0; int minorVersion = 0; boolean isWindows = identifyOsType().toLowerCase().contains("win"); if (isWindows) { String gsExec = SystemUtil.getPropertyOrEnvironmentVariable(GhostscriptHelper.GHOSTSCRIPT_ENVIRONMENT_VARIABLE); if (gsExec == null) { gsExec = SystemUtil.getPropertyOrEnvironmentVariable(GhostscriptHelper.GHOSTSCRIPT_ENVIRONMENT_VARIABLE_LEGACY); } String[] pathParts = gsExec.split("\\d\\.\\d\\d"); for (int i = 0; i < pathParts.length; i++) { gsExec = gsExec.replace(pathParts[i], ""); } String[] version = gsExec.split("\\."); majorVersion = Integer.parseInt(version[0]); minorVersion = Integer.parseInt(version[1]); } try { GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(); ghostscriptHelper.runGhostScriptImageGeneration(cmpPdf, destinationFolder, "maliciousPsInvokingCalcExe.png"); if (isWindows) { Assert.assertTrue((majorVersion > 9 || (majorVersion == 9 && minorVersion >= 50))); } } catch (GhostscriptHelper.GhostscriptExecutionException e) { if (isWindows) { Assert.assertTrue((majorVersion < 9 || (majorVersion == 9 && minorVersion < 50))); } } Assert.assertFalse(FileUtil.fileExists(maliciousPsInvokingCalcExe)); }
public void runGhostScriptImageGeneration(String pdf, String outDir, String image) throws IOException, InterruptedException { runGhostScriptImageGeneration(pdf, outDir, image, null); }
GhostscriptHelper { public void runGhostScriptImageGeneration(String pdf, String outDir, String image) throws IOException, InterruptedException { runGhostScriptImageGeneration(pdf, outDir, image, null); } }
GhostscriptHelper { public void runGhostScriptImageGeneration(String pdf, String outDir, String image) throws IOException, InterruptedException { runGhostScriptImageGeneration(pdf, outDir, image, null); } GhostscriptHelper();  GhostscriptHelper(String newGsExec); }
GhostscriptHelper { public void runGhostScriptImageGeneration(String pdf, String outDir, String image) throws IOException, InterruptedException { runGhostScriptImageGeneration(pdf, outDir, image, null); } GhostscriptHelper();  GhostscriptHelper(String newGsExec); String getCliExecutionCommand(); void runGhostScriptImageGeneration(String pdf, String outDir, String image); void runGhostScriptImageGeneration(String pdf, String outDir, String image, String pageList); }
GhostscriptHelper { public void runGhostScriptImageGeneration(String pdf, String outDir, String image) throws IOException, InterruptedException { runGhostScriptImageGeneration(pdf, outDir, image, null); } GhostscriptHelper();  GhostscriptHelper(String newGsExec); String getCliExecutionCommand(); void runGhostScriptImageGeneration(String pdf, String outDir, String image); void runGhostScriptImageGeneration(String pdf, String outDir, String image, String pageList); static final String GHOSTSCRIPT_ENVIRONMENT_VARIABLE; }