From efd9f84729662e168c6747416aec338494bb2686 Mon Sep 17 00:00:00 2001 From: Konloch Date: Mon, 19 Jul 2021 11:28:47 -0700 Subject: [PATCH] Strict Python Parameters --- .../bytecode/club/bytecodeviewer/Configuration.java | 4 ++-- .../club/bytecodeviewer/SettingsSerializer.java | 12 ++++++++---- .../compilers/impl/KrakatauAssembler.java | 4 ++-- .../decompilers/impl/KrakatauDecompiler.java | 12 ++++++------ .../decompilers/impl/KrakatauDisassembler.java | 8 ++++---- .../club/bytecodeviewer/gui/components/HTMLPane.java | 4 ++-- .../bytecodeviewer/resources/ExternalResources.java | 6 +++--- .../club/bytecodeviewer/util/SecurityMan.java | 2 +- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java index 61bff43d..2b608fc7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Configuration.java @@ -15,9 +15,9 @@ import java.io.File; public class Configuration { public static String python2 = ""; - public static String python2Extra = ""; + public static boolean python2Extra = false; public static String python3 = ""; - public static String python3Extra = ""; + public static boolean python3Extra = false; public static String rt = ""; public static String library = ""; public static String javac = ""; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java b/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java index 36f41078..13bacc0e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/SettingsSerializer.java @@ -194,10 +194,12 @@ public class SettingsSerializer save(BytecodeViewer.viewer.viewPane3.isPaneEditable()); save(Configuration.javaTools); - save(Configuration.python2Extra); - save(Configuration.python3Extra); + save("deprecated"); + save("deprecated"); save(Configuration.lastSaveDirectory); save(Configuration.lastPluginDirectory); + save(Configuration.python2Extra); + save(Configuration.python3Extra); } catch (Exception e) { BytecodeViewer.handleException(e); } @@ -388,10 +390,12 @@ public class SettingsSerializer BytecodeViewer.viewer.viewPane3.setPaneEditable(asBoolean(133)); Configuration.javaTools = asString(134); - Configuration.python2Extra = asString(135); - Configuration.python3Extra = asString(136); + //ignore 135 + //ignore 136 Configuration.lastSaveDirectory = asString(137); Configuration.lastPluginDirectory = asString(138); + Configuration.python2Extra = asBoolean(139); + Configuration.python3Extra = asBoolean(140); } catch (IndexOutOfBoundsException e) { 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 66c026e2..3093fc94 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 @@ -70,8 +70,8 @@ public class KrakatauAssembler extends InternalCompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, 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 ec021dd2..d7889f67 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 @@ -93,8 +93,8 @@ public class KrakatauDecompiler extends InternalDecompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, @@ -177,8 +177,8 @@ public class KrakatauDecompiler extends InternalDecompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, @@ -255,8 +255,8 @@ public class KrakatauDecompiler extends InternalDecompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, 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 f76a3272..ceb9f21b 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 @@ -62,8 +62,8 @@ public class KrakatauDisassembler extends InternalDecompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, @@ -127,8 +127,8 @@ public class KrakatauDisassembler extends InternalDecompiler try { String[] pythonCommands = new String[]{Configuration.python2}; - if(!Configuration.python2Extra.isEmpty()) - pythonCommands = ArrayUtils.addAll(pythonCommands, Configuration.python2Extra); + if(Configuration.python2Extra) + pythonCommands = ArrayUtils.addAll(pythonCommands, "-2"); ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( pythonCommands, diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/HTMLPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/HTMLPane.java index f7b47e8d..e109fdfd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/HTMLPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/HTMLPane.java @@ -34,8 +34,8 @@ public class HTMLPane extends JEditorPane text = text.replace("{java}", Configuration.java); text = text.replace("{javac}", Configuration.javac); text = text.replace("{bcvDir}", BCVDir.getAbsolutePath()); - text = text.replace("{python}", Configuration.python2+" " + Configuration.python2Extra); - text = text.replace("{python3}", Configuration.python3 + " " + Configuration.python3Extra); + text = text.replace("{python}", Configuration.python2+" " + (Configuration.python2Extra ? "-2" : "")); + text = text.replace("{python3}", Configuration.python3 + " " + (Configuration.python3Extra ? "-3" : "")); text = text.replace("{rt}", Configuration.rt); text = text.replace("{lib}", Configuration.library); text = text.replace("{krakatauVersion}", krakatauVersion); 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 bf128c69..b79e4a3c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ExternalResources.java @@ -128,7 +128,7 @@ public class ExternalResources //check using python CLI flag testCommand(new String[]{"python", "-2", "--version"}, "python 2", ()->{ Configuration.python2 = "python"; - Configuration.python2Extra = "-2"; + Configuration.python2Extra = true; }); if(!Configuration.python2.isEmpty()) return Configuration.python2; @@ -230,7 +230,7 @@ public class ExternalResources return; Configuration.python2 = file.getAbsolutePath(); - Configuration.python2Extra = ""; + Configuration.python2Extra = false; SettingsSerializer.saveSettingsAsync(); } @@ -244,7 +244,7 @@ public class ExternalResources return; Configuration.python3 = file.getAbsolutePath(); - Configuration.python3Extra = ""; + Configuration.python3Extra = false; SettingsSerializer.saveSettingsAsync(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java index ebcf819e..cd93f3a3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java @@ -64,7 +64,7 @@ public class SecurityMan extends SecurityManager * * When paired with checkWrite it should prevent most escapes * JNI is still possible so make sure to block checkLink as well //TODO for BCV - * + * * Rewritten on 07/19/2021 * * @author Konloch