From 948ae90e5038ccaab05d976369294662d8aa60d3 Mon Sep 17 00:00:00 2001 From: Konloch Date: Mon, 12 Jul 2021 05:13:35 -0700 Subject: [PATCH] Security Manager Cleanup --- .../the/bytecode/club/bytecodeviewer/Constants.java | 5 +++-- .../bytecodeviewer/compilers/impl/JavaCompiler.java | 2 +- .../compilers/impl/KrakatauAssembler.java | 2 +- .../decompilers/impl/FernFlowerDecompiler.java | 2 +- .../decompilers/impl/KrakatauDecompiler.java | 11 ++++------- .../decompilers/impl/KrakatauDisassembler.java | 4 ++-- .../bytecodeviewer/resources/ExternalResources.java | 2 +- .../bytecode/club/bytecodeviewer/util/Enjarify.java | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java index a981a96a..49b71a17 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java @@ -73,13 +73,14 @@ public class Constants */ private static void hideFile(File f) { - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); // Hide file by running attrib system command (on Windows) Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); } catch (Exception e) { BytecodeViewer.handleException(e); + } finally { + BytecodeViewer.sm.resumeBlocking(); } - BytecodeViewer.sm.resumeBlocking(); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java index 86f0d176..e1babd37 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java @@ -68,8 +68,8 @@ public class JavaCompiler extends InternalCompiler JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), cp.getAbsolutePath()); boolean cont = true; - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); StringBuilder log = new StringBuilder(); ProcessBuilder pb; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java index 8b6fc3d5..d92979fd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java @@ -65,9 +65,9 @@ public class KrakatauAssembler extends InternalCompiler StringBuilder log = new StringBuilder(); - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index e9fc8746..63b189dc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -88,12 +88,12 @@ public class FernFlowerDecompiler extends InternalDecompiler { try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( new String[]{ExternalResources.getSingleton().getJavaCommand(true), "-jar", ExternalResources.getSingleton().findLibrary("fernflower")}, generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath()) )); - BytecodeViewer.sm.pauseBlocking(); Process p = pb.start(); BytecodeViewer.createdProcesses.add(p); p.waitFor(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java index e26055d3..cff9c937 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java @@ -91,8 +91,8 @@ public class KrakatauDecompiler extends InternalDecompiler String s = ExceptionUI.SEND_STACKTRACE_TO_NL; - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 @@ -171,9 +171,8 @@ public class KrakatauDecompiler extends InternalDecompiler JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - BytecodeViewer.sm.pauseBlocking(); - try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 @@ -247,12 +246,10 @@ public class KrakatauDecompiler extends InternalDecompiler final File tempDirectory = new File(Constants.tempDirectory + fs + ran + fs); tempDirectory.mkdir(); - final File tempJar = new File(sourceJar); - - BytecodeViewer.sm.pauseBlocking(); - + try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java index 2cea60b5..15ee2cb3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java @@ -58,8 +58,8 @@ public class KrakatauDisassembler extends InternalDecompiler final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 @@ -122,8 +122,8 @@ public class KrakatauDisassembler extends InternalDecompiler final File tempJar = new File(sourceJar); - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python2, "-O", //love you storyyeller <3 diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java index 608a54cf..9e2351a5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java @@ -57,9 +57,9 @@ public class ExternalResources if(!empty) return Configuration.java; - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); //TODO read the version output to verify it exists ProcessBuilder pb = new ProcessBuilder("java", "-version"); pb.start(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java index 8a1b1f80..05d9e5aa 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java @@ -50,8 +50,8 @@ public class Enjarify { return; } - BytecodeViewer.sm.pauseBlocking(); try { + BytecodeViewer.sm.pauseBlocking(); ProcessBuilder pb = new ProcessBuilder( Configuration.python3, "-O",