You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2023/09/09 06:42:44 UTC
[groovy] branch GROOVY_4_0_X updated (1a939beef1 -> 46773d6c50)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a change to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
from 1a939beef1 GROOVY-10974, GROOVY-10975: STC: method pointer / reference parameter(s)
new cfe5c8d097 Improve method selection for script body in SecureASTCustomizer
new 46773d6c50 GROOVY-11170: Fix edge cases for SecureASTCustomizer (test cases)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../control/customizers/SecureASTCustomizer.java | 2 +-
.../customizers/SecureASTCustomizerTest.groovy | 56 ++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletion(-)
[groovy] 02/02: GROOVY-11170: Fix edge cases for SecureASTCustomizer (test cases)
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 46773d6c501e553733e25e7d3c1eac4ed7c40124
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Sep 9 16:42:32 2023 +1000
GROOVY-11170: Fix edge cases for SecureASTCustomizer (test cases)
---
.../customizers/SecureASTCustomizerTest.groovy | 56 ++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy b/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
index 1edb45998c..befa5f0335 100644
--- a/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
+++ b/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
@@ -525,6 +525,62 @@ final class SecureASTCustomizerTest {
}
}
+ @Test
+ void testAllowedReceiversMethod() {
+ customizer.allowedReceiversClasses = [Integer.TYPE]
+ def shell = new GroovyShell(configuration)
+ shell.evaluate('''
+ static main(args) {
+ 1.plus(1)
+ }
+ ''')
+ assert hasSecurityException {
+ shell.evaluate('''
+ static main(args) {
+ "string".toUpperCase()
+ }
+ ''')
+ }
+ assert hasSecurityException {
+ shell.evaluate('''
+ static main(args) {
+ 2.0.multiply(4)
+ }
+ ''')
+ }
+ }
+
+ @Test
+ void testAllowedReceiversClass() {
+ customizer.allowedReceiversClasses = [Integer.TYPE]
+ def shell = new GroovyShell(configuration)
+ shell.evaluate('''
+ class Dummy {
+ static main(args) {
+ 1.plus(1)
+ }
+ }
+ ''')
+ assert hasSecurityException {
+ shell.evaluate('''
+ class Dummy {
+ static main(args) {
+ "string".toUpperCase()
+ }
+ }
+ ''')
+ }
+ assert hasSecurityException {
+ shell.evaluate('''
+ class Dummy {
+ static main(args) {
+ 2.0.multiply(4)
+ }
+ }
+ ''')
+ }
+ }
+
@Test
void testDisallowedReceivers() {
customizer.disallowedReceiversClasses = [String]
[groovy] 01/02: Improve method selection for script body in SecureASTCustomizer
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit cfe5c8d097d71a745a67fe20138245024a9f0aa5
Author: Jochen Theodorou <bl...@gmx.org>
AuthorDate: Tue Aug 29 18:03:40 2023 +0200
Improve method selection for script body in SecureASTCustomizer
---
.../org/codehaus/groovy/control/customizers/SecureASTCustomizer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java b/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
index ac3dbda4df..fca20e0cbf 100644
--- a/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
+++ b/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
@@ -963,7 +963,7 @@ public class SecureASTCustomizer extends CompilationCustomizer {
List<MethodNode> methods = owner.getMethods();
for (MethodNode method : methods) {
if (method.getDeclaringClass() == owner && !method.isSynthetic()) {
- if ("main".equals(method.getName()) || "run".equals(method.getName()) && owner.isScriptBody()) continue;
+ if (("main".equals(method.getName()) || "run".equals(method.getName())) && owner.isScriptBody()) continue;
result.add(method);
}
}