[ANY] IDEA Code Inspect

This commit is contained in:
Gravit 2019-05-15 18:09:32 +07:00
parent 846ec90575
commit 3521f5882d
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
12 changed files with 66 additions and 74 deletions

View file

@ -212,8 +212,7 @@ public void init()
protectHandler.checkLaunchServerLicense();
}
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler);
for (int i = 0; i < auth.length; ++i) {
AuthProviderPair pair = auth[i];
for (AuthProviderPair pair : auth) {
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
@ -225,8 +224,7 @@ public void init()
public void close() {
try {
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler);
for (int i = 0; i < auth.length; ++i) {
AuthProviderPair pair = auth[i];
for (AuthProviderPair pair : auth) {
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);

View file

@ -33,7 +33,7 @@ private StarterVisitor() {
try {
Files.deleteIfExists(filef);
Files.createFile(filef);
} catch (Throwable t) { }
} catch (Throwable ignored) { }
}
}

View file

@ -29,7 +29,6 @@ public static void registerProviders() {
public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception;
public void preAuth(String login, String password, String customText, String ip) {
return;
}
@Override

View file

@ -46,7 +46,7 @@ public final boolean sync() throws IOException {
return exists;
}
public static final Path resolve(LaunchServer server, String ext) {
public static Path resolve(LaunchServer server, String ext) {
return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext);
}
}

View file

@ -40,8 +40,8 @@ public Path process(Path inputFile) throws IOException {
SessionInfo info = p.createSessionFromConfig();
info.setInput(inputFile.toFile());
info.setOutput(outputFile.toFile());
List<File> libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList());
libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()));
List<File> libs = srv.launcherBinary.coreLibs.stream().map(Path::toFile).collect(Collectors.toList());
libs.addAll(srv.launcherBinary.addonLibs.stream().map(Path::toFile).collect(Collectors.toList()));
info.setLibraries(libs);
Radon r = new Radon(info);
r.run();

View file

@ -8,13 +8,13 @@
public final class TaskUtil {
public static void addCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskAdd) {
List<LauncherBuildTask> indexes = new ArrayList<>();
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
tasks.stream().filter(pred).forEach(indexes::add);
indexes.forEach(e -> tasks.add(tasks.indexOf(e) + count, taskAdd));
}
public static void replaceCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskRep) {
List<LauncherBuildTask> indexes = new ArrayList<>();
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
tasks.stream().filter(pred).forEach(indexes::add);
indexes.forEach(e -> tasks.set(tasks.indexOf(e) + count, taskRep));
}

View file

@ -82,7 +82,7 @@ protected final void debug(String message, Object... args) {
public abstract void reply() throws Exception;
protected static final void writeNoError(HOutput output) throws IOException {
protected static void writeNoError(HOutput output) throws IOException {
output.writeString("", 0);
}
}

View file

@ -100,56 +100,59 @@ private static void replaceClasses(boolean pb, boolean rt) {
* Use ASM to modify the byte array
*/
private static byte[] transformClass(String className, byte[] classBytes) {
if (className.equals("java.lang.Runtime")) {
ClassReader cr=new ClassReader(classBytes);
ClassNode cn=new ClassNode();
cr.accept(cn,ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if(m.name.equals("exec")) {
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
} else if (className.equals("java.lang.ProcessBuilder")) {
ClassReader cr=new ClassReader(classBytes);
ClassNode cn=new ClassNode();
cr.accept(cn,ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if(m.name.equals("start")) {
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
} else if (className.equals("java.awt.Robot")) {
ClassReader cr=new ClassReader(classBytes);
ClassNode cn=new ClassNode();
cr.accept(cn,ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if( m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
m.name.equals("mouseWheel"))
{
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
switch (className) {
case "java.lang.Runtime": {
ClassReader cr = new ClassReader(classBytes);
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if (m.name.equals("exec")) {
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
case "java.lang.ProcessBuilder": {
ClassReader cr = new ClassReader(classBytes);
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if (m.name.equals("start")) {
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
case "java.awt.Robot": {
ClassReader cr = new ClassReader(classBytes);
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.EXPAND_FRAMES);
for (Object o : cn.methods.toArray()) {
MethodNode m = (MethodNode) o;
if (m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
m.name.equals("mouseWheel")) {
m.instructions.insert(new InsnNode(ARETURN));
m.instructions.insert(new InsnNode(ACONST_NULL));
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
}
return classBytes;
}

View file

@ -40,13 +40,7 @@ public void invoke(String... args) throws Exception {
Request.service.registerHandler((result) -> {
if(result instanceof LogEvent)
{
LogHelper.rawLog(() -> {
return ((LogEvent) result).string;
}, () -> {
return ((LogEvent) result).string;
}, () -> {
return ((LogEvent) result).string;
});
LogHelper.rawLog(() -> ((LogEvent) result).string, () -> ((LogEvent) result).string, () -> ((LogEvent) result).string);
}
});
}

View file

@ -193,9 +193,7 @@ else if(entry.getType().equals(HashedEntry.Type.DIR))
startTime = Instant.now();
updateState("UnknownFile", 0L, 100);
ListDownloader listDownloader = new ListDownloader();
listDownloader.download(e.url, adds, dir, this::updateState, (add) -> {
totalDownloaded += add;
});
listDownloader.download(e.url, adds, dir, this::updateState, (add) -> totalDownloaded += add);
deleteExtraDir(dir, diff.extra, diff.extra.flag);
LogHelper.debug("Update success");
return e;

2
Radon

@ -1 +1 @@
Subproject commit 6410af8044e7346e06f546dc04636b631fa7584c
Subproject commit b288a56a2d6577c247b80ebd213599482aa17d20

@ -1 +1 @@
Subproject commit 3f7cf22f4270dcdf6baa5c74dd00673b2b4ffc9e
Subproject commit ba8ebcc06dbc5847210e10928725e8254e47a1d9