mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
CodeStyle для EnvHelper
This commit is contained in:
parent
91f9e11b36
commit
23f67c2160
4 changed files with 17 additions and 13 deletions
|
@ -19,7 +19,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
|||
LogHelper.printVersion("Launcher");
|
||||
JVMHelper.checkStackTrace(ClientLauncherWrapper.class);
|
||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||
EnvHelper.checkDangerousParametrs();
|
||||
EnvHelper.checkDangerousParams();
|
||||
LogHelper.debug("Restart Launcher");
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.inheritIO();
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
import ru.gravit.launcher.request.auth.AuthRequest;
|
||||
import ru.gravit.launcher.request.auth.CheckServerRequest;
|
||||
import ru.gravit.launcher.request.auth.JoinServerRequest;
|
||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||
import ru.gravit.launcher.request.update.UpdateRequest;
|
||||
import ru.gravit.launcher.request.uuid.BatchProfileByUsernameRequest;
|
||||
import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest;
|
||||
|
@ -151,7 +150,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
|
|||
public static void main(String... args) throws Throwable {
|
||||
JVMHelper.checkStackTrace(LauncherEngine.class);
|
||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||
EnvHelper.checkDangerousParametrs();
|
||||
EnvHelper.checkDangerousParams();
|
||||
if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
||||
LogHelper.printVersion("Launcher");
|
||||
// Start Launcher
|
||||
|
|
|
@ -407,7 +407,7 @@ public static void main(String... args) throws Throwable {
|
|||
}
|
||||
checkJVMBitsAndVersion();
|
||||
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
||||
EnvHelper.checkDangerousParametrs();
|
||||
EnvHelper.checkDangerousParams();
|
||||
JVMHelper.checkStackTrace(ClientLauncher.class);
|
||||
LogHelper.printVersion("Client Launcher");
|
||||
// Read and delete params file
|
||||
|
|
|
@ -14,20 +14,25 @@ public class EnvHelper {
|
|||
}
|
||||
|
||||
public static void addEnv(ProcessBuilder builder) {
|
||||
Map<String, String> repl = builder.environment();
|
||||
for (String str : toTest) {
|
||||
repl.put(str, "");
|
||||
repl.put(str.toLowerCase(Locale.US), "");
|
||||
Map<String, String> map = builder.environment();
|
||||
for (String env : toTest) {
|
||||
if(map.containsKey(env))
|
||||
map.put(env, "");
|
||||
String lower_env = env.toLowerCase(Locale.US);
|
||||
if(map.containsKey(lower_env))
|
||||
map.put(lower_env, "");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkDangerousParametrs() {
|
||||
for (String t : toTest)
|
||||
if (System.getenv(t) != null) {
|
||||
String env = System.getenv(t).toLowerCase(Locale.US);
|
||||
public static void checkDangerousParams() {
|
||||
for (String t : toTest) {
|
||||
String env = System.getenv(t);
|
||||
if (env != null) {
|
||||
env = env.toLowerCase(Locale.US);
|
||||
if (env.contains("-cp") || env.contains("-classpath") || env.contains("-javaagent")
|
||||
|| env.contains("-agentpath") || env.contains("-agentlib"))
|
||||
throw new SecurityException("JavaAgent in global optings not allow");
|
||||
throw new SecurityException("JavaAgent in global options not allow");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue