mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 13:26:53 -04:00
Allows user to enable message lookup
This commit is contained in:
parent
651fa6e2d1
commit
99b55d03c1
@ -180,15 +180,15 @@ public class DefaultLauncher extends Launcher {
|
|||||||
|
|
||||||
res.addDefault("-Dfml.ignoreInvalidMinecraftCertificates=", "true");
|
res.addDefault("-Dfml.ignoreInvalidMinecraftCertificates=", "true");
|
||||||
res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true");
|
res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true");
|
||||||
|
|
||||||
// Fix RCE vulnerability of log4j2
|
|
||||||
res.addDefault("-Dlog4j2.formatMsgNoLookups=", "true");
|
|
||||||
res.addDefault("-Djava.rmi.server.useCodebaseOnly=", "true");
|
|
||||||
res.addDefault("-Dcom.sun.jndi.rmi.object.trustURLCodebase=", "false");
|
|
||||||
res.addDefault("-Dcom.sun.jndi.cosnaming.object.trustURLCodebase=", "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUsingLog4j()) {
|
// Fix RCE vulnerability of log4j2
|
||||||
|
res.addDefault("-Djava.rmi.server.useCodebaseOnly=", "true");
|
||||||
|
res.addDefault("-Dcom.sun.jndi.rmi.object.trustURLCodebase=", "false");
|
||||||
|
res.addDefault("-Dcom.sun.jndi.cosnaming.object.trustURLCodebase=", "false");
|
||||||
|
|
||||||
|
String formatMsgNoLookups = res.addDefault("-Dlog4j2.formatMsgNoLookups=", "true");
|
||||||
|
if (!"-Dlog4j2.formatMsgNoLookups=false".equals(formatMsgNoLookups) && isUsingLog4j()) {
|
||||||
res.addDefault("-Dlog4j.configurationFile=", getLog4jConfigurationFile().getAbsolutePath());
|
res.addDefault("-Dlog4j.configurationFile=", getLog4jConfigurationFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +476,6 @@ public class DefaultLauncher extends Launcher {
|
|||||||
private Map<String, String> getEnvVars() {
|
private Map<String, String> getEnvVars() {
|
||||||
String versionName = Optional.ofNullable(options.getVersionName()).orElse(version.getId());
|
String versionName = Optional.ofNullable(options.getVersionName()).orElse(version.getId());
|
||||||
Map<String, String> env = new HashMap<>();
|
Map<String, String> env = new HashMap<>();
|
||||||
env.put("LOG4J_FORMAT_MSG_NO_LOOKUPS", "true");
|
|
||||||
env.put("INST_NAME", versionName);
|
env.put("INST_NAME", versionName);
|
||||||
env.put("INST_ID", versionName);
|
env.put("INST_ID", versionName);
|
||||||
env.put("INST_DIR", repository.getVersionRoot(version.getId()).getAbsolutePath());
|
env.put("INST_DIR", repository.getVersionRoot(version.getId()).getAbsolutePath());
|
||||||
|
@ -83,33 +83,33 @@ public final class CommandBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder addDefault(String opt) {
|
public String addDefault(String opt) {
|
||||||
for (Item item : raw) {
|
for (Item item : raw) {
|
||||||
if (item.arg.equals(opt)) {
|
if (item.arg.equals(opt)) {
|
||||||
return this;
|
return item.arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
raw.add(new Item(opt, true));
|
raw.add(new Item(opt, true));
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder addDefault(String opt, String value) {
|
public String addDefault(String opt, String value) {
|
||||||
for (Item item : raw) {
|
for (Item item : raw) {
|
||||||
if (item.arg.startsWith(opt)) {
|
if (item.arg.startsWith(opt)) {
|
||||||
LOG.info("Default option '" + opt + value + "' is suppressed by '" + item.arg + "'");
|
LOG.info("Default option '" + opt + value + "' is suppressed by '" + item.arg + "'");
|
||||||
return this;
|
return item.arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
raw.add(new Item(opt + value, true));
|
raw.add(new Item(opt + value, true));
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder addUnstableDefault(String opt, boolean value) {
|
public String addUnstableDefault(String opt, boolean value) {
|
||||||
for (Item item : raw) {
|
for (Item item : raw) {
|
||||||
final Matcher matcher = UNSTABLE_BOOLEAN_OPTION_PATTERN.matcher(item.arg);
|
final Matcher matcher = UNSTABLE_BOOLEAN_OPTION_PATTERN.matcher(item.arg);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
if (matcher.group("key").equals(opt)) {
|
if (matcher.group("key").equals(opt)) {
|
||||||
return this;
|
return item.arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,21 +119,21 @@ public final class CommandBuilder {
|
|||||||
} else {
|
} else {
|
||||||
raw.add(new Item("-XX:-" + opt, true));
|
raw.add(new Item("-XX:-" + opt, true));
|
||||||
}
|
}
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder addUnstableDefault(String opt, String value) {
|
public String addUnstableDefault(String opt, String value) {
|
||||||
for (Item item : raw) {
|
for (Item item : raw) {
|
||||||
final Matcher matcher = UNSTABLE_OPTION_PATTERN.matcher(item.arg);
|
final Matcher matcher = UNSTABLE_OPTION_PATTERN.matcher(item.arg);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
if (matcher.group("key").equals(opt)) {
|
if (matcher.group("key").equals(opt)) {
|
||||||
return this;
|
return item.arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
raw.add(new Item("-XX:" + opt + "=" + value, true));
|
raw.add(new Item("-XX:" + opt + "=" + value, true));
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeIf(Predicate<String> pred) {
|
public boolean removeIf(Predicate<String> pred) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user