CodeStyle для EnvHelper

This commit is contained in:
Gravit 2018-10-26 21:42:20 +07:00
parent 91f9e11b36
commit 23f67c2160
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 17 additions and 13 deletions

View file

@ -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();

View file

@ -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

View file

@ -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

View 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");
}
}
}
}