SteamWar/BauSystem2.0
Archiviert
12
0

Optimize command injection
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-27 21:22:19 +02:00
Ursprung 456f7dd660
Commit be86b222d1
4 geänderte Dateien mit 5 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -185,6 +185,10 @@ public class LinkageProcessor extends AbstractProcessor {
}); });
} }
if (linkLines.containsKey(LinkageType.COMMAND)) {
linkLines.get(LinkageType.COMMAND).add(0, "de.steamwar.message.Message message = de.steamwar.bausystem.BauSystem.MESSAGE");
}
writer.write("package de.steamwar.bausystem.linkage;\n\n"); writer.write("package de.steamwar.bausystem.linkage;\n\n");
writer.write("public class LinkageUtils {\n"); writer.write("public class LinkageUtils {\n");
for (String s : fields) { for (String s : fields) {

Datei anzeigen

@ -19,13 +19,10 @@
package de.steamwar.bausystem.linkage; package de.steamwar.bausystem.linkage;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
public enum LinkageType { public enum LinkageType {
// NORMAL // NORMAL
COMMAND("$.setMessage(de.steamwar.bausystem.BauSystem.MESSAGE)", "de.steamwar.command.SWCommand"), COMMAND("$.setMessage(message)", "de.steamwar.command.SWCommand"),
ENABLE_LINK("$.enable()", null, "de.steamwar.bausystem.linkage.Enable"), ENABLE_LINK("$.enable()", null, "de.steamwar.bausystem.linkage.Enable"),
DISABLE_LINK("$.disable()", null, "de.steamwar.bausystem.linkage.Disable"), DISABLE_LINK("$.disable()", null, "de.steamwar.bausystem.linkage.Disable"),
PLAIN(), PLAIN(),

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.bausystem.region.loader; package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -40,11 +39,9 @@ public class PrototypeLoader {
public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion"); public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion");
public void load() { public void load() {
long time = System.currentTimeMillis();
YAPIONObject yapionObject = null; YAPIONObject yapionObject = null;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) { try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
yapionObject = YAPIONParser.parse(bufferedInputStream); yapionObject = YAPIONParser.parse(bufferedInputStream);
BauSystem.getInstance().getLogger().info("4.1.1 " + (System.currentTimeMillis() - time) + "ms");
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
@ -52,7 +49,6 @@ public class PrototypeLoader {
if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(DiffDelete.class::isInstance)) { if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(DiffDelete.class::isInstance)) {
throw new SecurityException("Version was not the specified version needed."); throw new SecurityException("Version was not the specified version needed.");
} }
BauSystem.getInstance().getLogger().info("4.1.2 " + (System.currentTimeMillis() - time) + "ms");
loaded = yapionObject; loaded = yapionObject;
yapionObject.forEach((key, yapionAnyType) -> { yapionObject.forEach((key, yapionAnyType) -> {
@ -60,6 +56,5 @@ public class PrototypeLoader {
new Prototype(key, (YAPIONObject) yapionAnyType); new Prototype(key, (YAPIONObject) yapionAnyType);
} }
}); });
BauSystem.getInstance().getLogger().info("4.1.3 " + (System.currentTimeMillis() - time) + "ms");
} }
} }

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.bausystem.region.loader; package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.FlagStorage; import de.steamwar.bausystem.region.FlagStorage;
import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Prototype;
@ -44,11 +43,9 @@ public class RegionLoader {
public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.yapion"); public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.yapion");
public void load() { public void load() {
long time = System.currentTimeMillis();
YAPIONObject yapionObject = null; YAPIONObject yapionObject = null;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) { try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
yapionObject = YAPIONParser.parse(bufferedInputStream); yapionObject = YAPIONParser.parse(bufferedInputStream);
BauSystem.getInstance().getLogger().info("4.2.1 " + (System.currentTimeMillis() - time) + "ms");
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);
} }
@ -56,7 +53,6 @@ public class RegionLoader {
if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffChange))) { if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffChange))) {
throw new SecurityException("Version was not the specified version needed."); throw new SecurityException("Version was not the specified version needed.");
} }
BauSystem.getInstance().getLogger().info("4.2.2 " + (System.currentTimeMillis() - time) + "ms");
loaded = yapionObject; loaded = yapionObject;
YAPIONObject optionsYapionObject = WorldData.getRegionsData(); YAPIONObject optionsYapionObject = WorldData.getRegionsData();
@ -78,7 +74,6 @@ public class RegionLoader {
Prototype.generateRegion(key, regionConfig, regionData); Prototype.generateRegion(key, regionConfig, regionData);
}); });
BauSystem.getInstance().getLogger().info("4.2.3 " + (System.currentTimeMillis() - time) + "ms");
YAPIONObject globalOptions = optionsYapionObject.getObject("global"); YAPIONObject globalOptions = optionsYapionObject.getObject("global");
if (globalOptions == null) { if (globalOptions == null) {
@ -92,6 +87,5 @@ public class RegionLoader {
flagStorage = new FlagStorage(); flagStorage = new FlagStorage();
} }
new GlobalRegion(flagStorage, globalOptions); new GlobalRegion(flagStorage, globalOptions);
BauSystem.getInstance().getLogger().info("4.2.4 " + (System.currentTimeMillis() - time) + "ms");
} }
} }