Skip to content

Commit 296c2ce

Browse files
committed
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.21-lts
2 parents 82cb854 + 28c1bdd commit 296c2ce

File tree

7 files changed

+70
-14
lines changed

7 files changed

+70
-14
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Changes:
5+
* Restrict access to parts of the Java API
6+
They can still be enabled if desired by the server admin.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Fixes:
5+
* Update to graal 24.1.1, fixes issues for some JDK 23 users, Closes #30
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Fixes:
5+
* Re-enable shadow renames, except for com.oracle.truffle, Closes #32
6+
This makes this mod work correctle on all JVMs, including GraalVM 21 and 23.
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Fixes:
5+
* Use jar-in-jar instead of shadowing, Closes #34
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Changes:
5+
* Restrict access to parts of the Java API
6+
They can still be enabled if desired by the server admin.

src/main/java/org/cyclops/integratedscripting/GeneralConfig.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,40 @@ public class GeneralConfig extends DummyConfig {
2222
@ConfigurableProperty(category = "general", comment = "The minimum number of ticks inbetween sending a script change packet from client to server.", minimalValue = 0, configLocation = ModConfig.Type.SERVER)
2323
public static int terminalScriptingClientSyncTickInterval = 20;
2424

25-
@ConfigurableProperty(category = "general", comment = "If new processes can be created from guest languages.", configLocation = ModConfig.Type.SERVER)
25+
@ConfigurableProperty(category = "general", comment = "If new processes can be created from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
2626
public static boolean graalAllowCreateProcess = false;
27-
@ConfigurableProperty(category = "general", comment = "If new threads can be created from guest languages.", configLocation = ModConfig.Type.SERVER)
27+
@ConfigurableProperty(category = "general", comment = "If new threads can be created from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
2828
public static boolean graalAllowCreateThread = false;
29-
@ConfigurableProperty(category = "general", comment = "If IO is allowed from guest languages.", configLocation = ModConfig.Type.SERVER)
29+
@ConfigurableProperty(category = "general", comment = "If IO is allowed from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
3030
public static boolean graalAllowIo = false;
31-
@ConfigurableProperty(category = "general", comment = "If host class loading is allowed from guest languages.", configLocation = ModConfig.Type.SERVER)
31+
@ConfigurableProperty(category = "general", comment = "If host class loading is allowed from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
3232
public static boolean graalAllowHostClassLoading = false;
33-
@ConfigurableProperty(category = "general", comment = "If experimental options can be used in guest languages.", configLocation = ModConfig.Type.SERVER)
33+
@ConfigurableProperty(category = "general", comment = "If experimental options can be used in guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
3434
public static boolean graalAllowExperimentalOptions = false;
35-
@ConfigurableProperty(category = "general", comment = "If environment variables can be accessed from guest languages.", configLocation = ModConfig.Type.SERVER)
35+
@ConfigurableProperty(category = "general", comment = "If environment variables can be accessed from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
3636
public static boolean graalAllowEnvironment = false;
37-
@ConfigurableProperty(category = "general", comment = "If the native interface can be accessed from guest languages.", configLocation = ModConfig.Type.SERVER)
37+
@ConfigurableProperty(category = "general", comment = "If the native interface can be accessed from guest languages. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
3838
public static boolean graalAllowNative = false;
39+
@ConfigurableProperty(category = "general", comment = "If all Java public constructors should be accessible. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
40+
public static boolean graalAllowHostPublicAccess = false;
41+
@ConfigurableProperty(category = "general", comment = "Allow guest languages to implement any Java interface. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
42+
public static boolean graalAllowHostAllImplementations = false;
43+
@ConfigurableProperty(category = "general", comment = "Allow guest languages to implement (extend) any Java class. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
44+
public static boolean graalAllowHostAllClassImplementations = false;
45+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access arrays as values with array elements.", configLocation = ModConfig.Type.SERVER)
46+
public static boolean graalAllowHostArrayAccess = true;
47+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access lists as values with array elements and iterators.", configLocation = ModConfig.Type.SERVER)
48+
public static boolean graalAllowHostListAccess = true;
49+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access java. nio. ByteBuffers as values with buffer elements.", configLocation = ModConfig.Type.SERVER)
50+
public static boolean graalAllowHostBufferAccess = true;
51+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access iterables as values with iterators.", configLocation = ModConfig.Type.SERVER)
52+
public static boolean graalAllowHostIterableAccess = true;
53+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access iterators as iterator values.", configLocation = ModConfig.Type.SERVER)
54+
public static boolean graalAllowHostIteratorAccess = true;
55+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to access map as hash values.", configLocation = ModConfig.Type.SERVER)
56+
public static boolean graalAllowHostMapAccess = true;
57+
@ConfigurableProperty(category = "general", comment = "Allows the guest application to inherit access to allowed methods, i. e. implementations of allowed abstract and interface methods and overrides of allowed concrete methods. Only enable this on private servers and if you know what you are doing.", configLocation = ModConfig.Type.SERVER)
58+
public static boolean graalAllowHostAccessInheritance = false;
3959
@ConfigurableProperty(category = "general", comment = "The maximum number of statements that can be executed in one evaluation. This is to avoid infinite loops or very complex programs. Set to -1 to disable limit (not recommended).", configLocation = ModConfig.Type.SERVER, minimalValue = -1)
4060
public static int graalStatementLimit = 16384;
4161
@ConfigurableProperty(category = "general", comment = "The maximum number of lines in stdout and stderr script log files. Set to -1 to disable limit.", minimalValue = -1, configLocation = ModConfig.Type.SERVER)

src/main/java/org/cyclops/integratedscripting/evaluate/ScriptHelpers.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
import org.cyclops.integratedscripting.GeneralConfig;
1010
import org.cyclops.integratedscripting.api.evaluate.translation.IEvaluationExceptionFactory;
1111
import org.cyclops.integratedscripting.evaluate.translation.ValueTranslators;
12-
import org.graalvm.polyglot.Context;
13-
import org.graalvm.polyglot.Engine;
14-
import org.graalvm.polyglot.EnvironmentAccess;
15-
import org.graalvm.polyglot.HostAccess;
16-
import org.graalvm.polyglot.ResourceLimits;
17-
import org.graalvm.polyglot.Value;
12+
import org.graalvm.polyglot.*;
1813

1914
import javax.annotation.Nullable;
2015
import java.nio.file.Path;
@@ -43,7 +38,18 @@ public static Context createBaseContext(@Nullable Function<Context.Builder, Cont
4338
.allowExperimentalOptions(GeneralConfig.graalAllowExperimentalOptions)
4439
.allowEnvironmentAccess(GeneralConfig.graalAllowEnvironment ? EnvironmentAccess.INHERIT : EnvironmentAccess.NONE)
4540
.allowNativeAccess(GeneralConfig.graalAllowNative)
46-
.allowHostAccess(HostAccess.ALL)
41+
.allowHostAccess(HostAccess.newBuilder()
42+
.allowPublicAccess(GeneralConfig.graalAllowHostPublicAccess)
43+
.allowAllImplementations(GeneralConfig.graalAllowHostAllImplementations)
44+
.allowAllClassImplementations(GeneralConfig.graalAllowHostAllClassImplementations)
45+
.allowArrayAccess(GeneralConfig.graalAllowHostArrayAccess)
46+
.allowListAccess(GeneralConfig.graalAllowHostListAccess)
47+
.allowBufferAccess(GeneralConfig.graalAllowHostBufferAccess)
48+
.allowIterableAccess(GeneralConfig.graalAllowHostIterableAccess)
49+
.allowIteratorAccess(GeneralConfig.graalAllowHostIteratorAccess)
50+
.allowMapAccess(GeneralConfig.graalAllowHostMapAccess)
51+
.allowAccessInheritance(GeneralConfig.graalAllowHostAccessInheritance)
52+
.build())
4753
.allowInnerContextOptions(false);
4854
if (GeneralConfig.graalStatementLimit > 0) {
4955
contextBuilder = contextBuilder.resourceLimits(ResourceLimits.newBuilder()

0 commit comments

Comments
 (0)