Package com.axelor.script
Class SandboxGroovyMethods
java.lang.Object
com.axelor.script.SandboxGroovyMethods
Groovy extension methods overriding the GDK methods that escape the script sandbox.
Registered as an extension module (see
META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule), these take precedence over the GDK
methods of the same signature, so they intercept the call however it is dispatched: direct call,
dynamic method name, invokeMethod, closure delegate, spread, etc. The receiver check
cannot catch these, as they run on allow-listed receivers (String, List, any
object).
execute: starts an operating system processuse: applies a category, exposing static methods of any class (e.g.System.getenv) as methods of allow-listed receiversmixin: mixes any class (e.g.GroovyShell) into an allow-listed class, for the whole applicationsetMetaClass,metaClass: replace the metaclass of a class, for the whole application (e.g. removing the guard ofSandboxGuardedMethods)asType(as): converting a list or map calls a constructor of the target class, so the target class must be allowedaddShutdownHook: registers code run when the JVM shuts down, outside of any evaluation (no timeout), for the whole applicationgetAtwith a property name (list['name']): reads the property of each element of a collection or an array, which must be allowed as receivers
They are denied only when called from sandboxed code; otherwise they delegate to the GDK.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddShutdownHook(Object self, groovy.lang.Closure<?> closure) static <T> Tstatic <T> Tstatic <T> TasType(CharSequence self, Class<T> type) static <T> Tstatic <T> Tstatic <T> Tstatic <T> Tstatic <T> Tstatic <T> TasType(Collection<?> self, Class<T> type) static <T> Tstatic Processstatic Processstatic Processstatic Processstatic Processstatic Processstatic Processstatic Processstatic Processstatic Objectstatic ListgetAt(Collection<?> self, String property) static groovy.lang.MetaClassstatic groovy.lang.MetaClassstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidsetMetaClass(groovy.lang.GroovyObject self, groovy.lang.MetaClass metaClass) static voidsetMetaClass(Class<?> self, groovy.lang.MetaClass metaClass) static voidsetMetaClass(Object self, groovy.lang.MetaClass metaClass) static <T> Tstatic Objectstatic <T> T
-
Method Details
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
use
-
use
-
use
-
setMetaClass
-
setMetaClass
-
setMetaClass
public static void setMetaClass(groovy.lang.GroovyObject self, groovy.lang.MetaClass metaClass) -
metaClass
-
metaClass
-
asType
-
asType
-
asType
-
asType
-
asType
-
asType
-
asType
-
asType
-
asType
-
asType
-
getAt
-
getAt
-
addShutdownHook
-
mixin
-
mixin
-
mixin
-
mixin
-
mixin
-
mixin
-