Package com.axelor.script
Class GroovyCheckTransformation
java.lang.Object
org.codehaus.groovy.transform.AbstractASTTransformation
com.axelor.script.GroovyCheckTransformation
- All Implemented Interfaces:
org.codehaus.groovy.transform.ASTTransformation,org.codehaus.groovy.transform.ErrorCollecting
public class GroovyCheckTransformation
extends org.codehaus.groovy.transform.AbstractASTTransformation
A custom groovy ast transformer to validate type of objects against the policy settings.
This transformer will transform the ctor/method/property calls, method pointers (
obj.&name, obj::name) and subscripts (obj[index]) by wrapping the object side in
a GroovySandbox check, which also checks the execution timeout.
It also adds a timeout check (GroovySandbox.timeout()) at the start of each loop body,
as a loop body may contain no call, and of each method and closure body, as they can run many
times without a loop of the script (recursion, closures called by Java: each,
times...).
For example:
def value = some.method()
while(true) {
println('Hello')
}
items.each { it.foo() }
would become:
def value = GroovySandbox.check(some).method()
while(true) {
GroovySandbox.timeout()
GroovySandbox.check(this).println('Hello')
}
GroovySandbox.check(items).each {
GroovySandbox.timeout()
GroovySandbox.check(it).foo()
}
-
Field Summary
Fields inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
RETENTION_CLASSNODE, sourceUnit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvisit(org.codehaus.groovy.ast.ASTNode[] nodes, org.codehaus.groovy.control.SourceUnit source) Methods inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
addError, checkIncludeExcludeUndefinedAware, checkIncludeExcludeUndefinedAware, checkNotInterface, checkPropertyList, checkPropertyList, checkPropertyList, copyAnnotatedNodeAnnotations, copyAnnotatedNodeAnnotations, deemedInternalName, getAnnotationName, getMemberClassList, getMemberClassValue, getMemberClassValue, getMemberIntValue, getMemberStringList, getMemberStringValue, getMemberStringValue, getMemberValue, hasAnnotation, init, memberHasValue, shouldSkip, shouldSkip, shouldSkipOnDescriptorUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, tokenize
-
Constructor Details
-
GroovyCheckTransformation
public GroovyCheckTransformation()
-
-
Method Details
-
visit
public void visit(org.codehaus.groovy.ast.ASTNode[] nodes, org.codehaus.groovy.control.SourceUnit source)
-