Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.1
-
None
Description
I'm trying to compile Groovy Scripts while rejecting calls to System.exit() by using using a SecureASTCustomizer like this:
final SecureASTCustomizer customizer = new SecureASTCustomizer(); customizer.setImportsBlacklist(asList("java.lang.System", "groovy.lang.GroovyShell", "groovy.lang.GroovyClassLoader")); customizer.setIndirectImportCheckEnabled(true); CompilerConfiguration configuration = new CompilerConfiguration(); configuration.addCompilationCustomizers(customizer); ClassLoader parent = ScriptCompiler.class.getClassLoader(); GroovyClassLoader loader = new GroovyClassLoader(parent, configuration);
The following Script is blocked correctly and I get an exception during parseClass()
System.exit(1);
In the following script, System.exit() is called successfully:
def x() { System.exit(1) }
x()