groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: `AstStringCompiler.compile(String, CompilePhase, boolean)` creates a groovy.lang.GroovyClassLoader classloader, which should be performed within a doPrivileged block
Date Thu, 05 Jul 2018 06:19:59 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 5aecfefe5 -> 49fb3594e


`AstStringCompiler.compile(String, CompilePhase, boolean)` creates a groovy.lang.GroovyClassLoader
classloader, which should be performed within a doPrivileged block

This code creates a classloader, which needs permission if a security manage is installed.
If this code might be invoked by code that does not have security permissions, then the classloader
creation needs to occur inside a doPrivileged block.

(cherry picked from commit 2934d3c)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/49fb3594
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/49fb3594
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/49fb3594

Branch: refs/heads/GROOVY_2_5_X
Commit: 49fb3594eb164f8b6f2b9c8a9850b15c0ef6a849
Parents: 5aecfef
Author: sunlan <sunlan@apache.org>
Authored: Thu Jul 5 14:17:50 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Thu Jul 5 14:19:55 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/ast/builder/AstStringCompiler.groovy    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/49fb3594/src/main/groovy/org/codehaus/groovy/ast/builder/AstStringCompiler.groovy
----------------------------------------------------------------------
diff --git a/src/main/groovy/org/codehaus/groovy/ast/builder/AstStringCompiler.groovy b/src/main/groovy/org/codehaus/groovy/ast/builder/AstStringCompiler.groovy
index 6089c0c..400566e 100644
--- a/src/main/groovy/org/codehaus/groovy/ast/builder/AstStringCompiler.groovy
+++ b/src/main/groovy/org/codehaus/groovy/ast/builder/AstStringCompiler.groovy
@@ -26,6 +26,9 @@ import org.codehaus.groovy.control.CompilationUnit
 import org.codehaus.groovy.control.CompilePhase
 import org.codehaus.groovy.control.CompilerConfiguration
 
+import java.security.AccessController
+import java.security.PrivilegedAction
+
 /**
  * This class handles converting Strings to ASTNode lists.
  *
@@ -46,7 +49,7 @@ import org.codehaus.groovy.control.CompilerConfiguration
     List<ASTNode> compile(String script, CompilePhase compilePhase, boolean statementsOnly)
{
         final scriptClassName = makeScriptClassName()
         GroovyCodeSource codeSource = new GroovyCodeSource(script, "${scriptClassName}.groovy",
"/groovy/script")
-        CompilationUnit cu = new CompilationUnit(CompilerConfiguration.DEFAULT, codeSource.codeSource,
new GroovyClassLoader())
+        CompilationUnit cu = new CompilationUnit(CompilerConfiguration.DEFAULT, codeSource.codeSource,
AccessController.doPrivileged({ new GroovyClassLoader() } as PrivilegedAction<GroovyClassLoader>))
         cu.addSource(codeSource.getName(), script)
         cu.compile(compilePhase.getPhaseNumber())
         // collect all the ASTNodes into the result, possibly ignoring the script body if
desired


Mime
View raw message