Package org.kohsuke.groovy.sandbox.impl
Class Checker
java.lang.Object
org.kohsuke.groovy.sandbox.impl.Checker
Intercepted Groovy script calls into this class.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcheckedBinaryOp(Object lhs, int op, Object rhs) Intercepts the binary expression of the formlhs op rhslikelhs+rhs,lhs>>rhs, etc.static ObjectcheckedBitwiseNegate(Object value) Intercepts unary expressions of the form~value.static ObjectcheckedCall(Object _receiver, boolean safe, boolean spread, String _method, Object[] _args) static ObjectcheckedCast(Class<?> clazz, Object exp, boolean ignoreAutoboxing, boolean coerce, boolean strict) RunsScriptBytecodeAdapter.asType(java.lang.Object, java.lang.Class)but only after giving interceptors the chance to reject any possible interface methods as applied to the receiver.static ObjectcheckedComparison(Object lhs, int op, Object rhs) A compare method that invokes a.equals(b) or a.compareTo(b)==0static ObjectcheckedConstructor(Class _type, Object[] _args) static ObjectcheckedCreateRange(Object from, Object to, boolean inclusive) Intercepts range expressions of the form[x..y]or[x..<y].static ObjectcheckedGetArray(Object _receiver, Object _index) static ObjectcheckedGetAttribute(Object _receiver, boolean safe, boolean spread, Object _property) static ObjectcheckedGetProperty(Object _receiver, boolean safe, boolean spread, Object _property) static ObjectcheckedPostfixArray(Object r, Object i, String op) a[i]++ / a[i]--static ObjectcheckedPostfixAttribute(Object receiver, Object property, boolean safe, boolean spread, String op) a.@x++ / a.@x--static ObjectcheckedPostfixProperty(Object receiver, Object property, boolean safe, boolean spread, String op) a.x++ / a.x--static ObjectcheckedPrefixArray(Object r, Object i, String op) ++a[i] / --a[i]static ObjectcheckedPrefixAttribute(Object receiver, Object property, boolean safe, boolean spread, String op) ++a.@x / --a.@xstatic ObjectcheckedPrefixProperty(Object receiver, Object property, boolean safe, boolean spread, String op) ++a.x / --a.xstatic ObjectcheckedSetArray(Object _receiver, Object _index, int op, Object _value) Intercepts the array assignment of the form "receiver[index] = value"static ObjectcheckedSetAttribute(Object _receiver, Object _property, boolean safe, boolean spread, int op, Object _value) Intercepts the attribute assignment of the form "receiver.@property = value"static ObjectcheckedSetProperty(Object _receiver, Object _property, boolean safe, boolean spread, int op, Object _value) static ObjectcheckedStaticCall(Class _receiver, String _method, Object[] _args) static ObjectcheckedSuperCall(Class _senderType, Object _receiver, String _method, Object[] _args) checkedSuperConstructor(Class<?> thisClass, Class<?> superClass, Object[] superCallArgs, Object[] constructorArgs, Class<?>[] constructorParamTypes) checkedThisConstructor(Class<?> clazz, Object[] thisCallArgs, Object[] constructorArgs, Class<?>[] constructorParamTypes) static ObjectcheckedUnaryMinus(Object value) Intercepts unary expressions of the form-value.static ObjectcheckedUnaryPlus(Object value) Intercepts unary expressions of the form+value.static Checker.ThunkpreCheckedCast(Class<?> clazz, Object exp, boolean ignoreAutoboxing, boolean coerce, boolean strict)
-
Constructor Details
-
Checker
public Checker()
-
-
Method Details
-
checkedCall
public static Object checkedCall(Object _receiver, boolean safe, boolean spread, String _method, Object[] _args) throws Throwable - Throws:
Throwable
-
checkedStaticCall
public static Object checkedStaticCall(Class _receiver, String _method, Object[] _args) throws Throwable - Throws:
Throwable
-
checkedConstructor
- Throws:
Throwable
-
checkedSuperCall
public static Object checkedSuperCall(Class _senderType, Object _receiver, String _method, Object[] _args) throws Throwable - Throws:
Throwable
-
checkedSuperConstructor
public static Checker.SuperConstructorWrapper checkedSuperConstructor(Class<?> thisClass, Class<?> superClass, Object[] superCallArgs, Object[] constructorArgs, Class<?>[] constructorParamTypes) throws Throwable - Throws:
Throwable
-
checkedThisConstructor
public static Checker.ThisConstructorWrapper checkedThisConstructor(Class<?> clazz, Object[] thisCallArgs, Object[] constructorArgs, Class<?>[] constructorParamTypes) throws Throwable - Throws:
Throwable
-
checkedGetProperty
public static Object checkedGetProperty(Object _receiver, boolean safe, boolean spread, Object _property) throws Throwable - Throws:
Throwable
-
checkedSetProperty
public static Object checkedSetProperty(Object _receiver, Object _property, boolean safe, boolean spread, int op, Object _value) throws Throwable - Throws:
Throwable
-
checkedGetAttribute
public static Object checkedGetAttribute(Object _receiver, boolean safe, boolean spread, Object _property) throws Throwable - Throws:
Throwable
-
checkedSetAttribute
public static Object checkedSetAttribute(Object _receiver, Object _property, boolean safe, boolean spread, int op, Object _value) throws Throwable Intercepts the attribute assignment of the form "receiver.@property = value"- Parameters:
op- One of the assignment operators ofTypes- Throws:
Throwable
-
checkedGetArray
- Throws:
Throwable
-
checkedSetArray
public static Object checkedSetArray(Object _receiver, Object _index, int op, Object _value) throws Throwable Intercepts the array assignment of the form "receiver[index] = value"- Parameters:
op- One of the assignment operators ofTypes- Throws:
Throwable
-
checkedPostfixArray
a[i]++ / a[i]--- Parameters:
op- "next" for ++, "previous" for --. These names are defined by Groovy.- Throws:
Throwable
-
checkedPrefixArray
++a[i] / --a[i]- Throws:
Throwable
-
checkedPostfixProperty
public static Object checkedPostfixProperty(Object receiver, Object property, boolean safe, boolean spread, String op) throws Throwable a.x++ / a.x--- Throws:
Throwable
-
checkedPrefixProperty
public static Object checkedPrefixProperty(Object receiver, Object property, boolean safe, boolean spread, String op) throws Throwable ++a.x / --a.x- Throws:
Throwable
-
checkedPostfixAttribute
public static Object checkedPostfixAttribute(Object receiver, Object property, boolean safe, boolean spread, String op) throws Throwable a.@x++ / a.@x--- Throws:
Throwable
-
checkedPrefixAttribute
public static Object checkedPrefixAttribute(Object receiver, Object property, boolean safe, boolean spread, String op) throws Throwable ++a.@x / --a.@x- Throws:
Throwable
-
checkedBinaryOp
Intercepts the binary expression of the formlhs op rhslikelhs+rhs,lhs>>rhs, etc. In Groovy, binary operators are method calls.- Parameters:
op- One of the binary operators ofTypes- Throws:
Throwable- See Also:
-
BinaryExpressionHelper.evaluateBinaryExpressionWithAssignment(java.lang.String, org.codehaus.groovy.ast.expr.BinaryExpression)
-
checkedBitwiseNegate
Intercepts unary expressions of the form~value. In Groovy, this operator may result in a call to a method namedbitwiseNegateon the receiver or to one of theDefaultGroovyMethods.bitwiseNegateoverloads.- Throws:
Throwable- See Also:
-
UnaryExpressionHelper.writeBitwiseNegate(org.codehaus.groovy.ast.expr.BitwiseNegationExpression)ScriptBytecodeAdapter.bitwiseNegate(java.lang.Object)InvokerHelper.bitwiseNegate(java.lang.Object)
-
checkedCreateRange
Intercepts range expressions of the form[x..y]or[x..<y]. If the from and to expressions are not integers, this operator constructs aObjectRange, which involves calling various methods on the endpoints during the construction of the range and whenever the range is used. We handle this like we do interfaces inpreCheckedCast(java.lang.Class<?>, java.lang.Object, boolean, boolean, boolean)and intercept all of the methods that may be called before allowing the range to be constructed rather than trying to implement our own range type that is sandbox-aware.- Throws:
Throwable- See Also:
-
ScriptBytecodeAdapter.createRange(java.lang.Object, java.lang.Object, boolean)ObjectRange
-
checkedUnaryMinus
Intercepts unary expressions of the form-value. In Groovy, this operator may result in a call to a method namednegativeon the receiver or to one of theDefaultGroovyMethods.unaryMinusoverloads.- Throws:
Throwable- See Also:
-
UnaryExpressionHelper.writeUnaryMinus(org.codehaus.groovy.ast.expr.UnaryMinusExpression)ScriptBytecodeAdapter.unaryMinus(java.lang.Object)InvokerHelper.unaryMinus(java.lang.Object)
-
checkedUnaryPlus
Intercepts unary expressions of the form+value. In Groovy, this operator may result in a call to a method namedpositiveon the receiver or to one of theDefaultGroovyMethods.unaryMinusoverloads.- Throws:
Throwable- See Also:
-
UnaryExpressionHelper.writeUnaryPlus(org.codehaus.groovy.ast.expr.UnaryPlusExpression)ScriptBytecodeAdapter.unaryPlus(java.lang.Object)InvokerHelper.unaryPlus(java.lang.Object)
-
checkedComparison
A compare method that invokes a.equals(b) or a.compareTo(b)==0- Throws:
Throwable
-
checkedCast
public static Object checkedCast(Class<?> clazz, Object exp, boolean ignoreAutoboxing, boolean coerce, boolean strict) throws Throwable RunsScriptBytecodeAdapter.asType(java.lang.Object, java.lang.Class)but only after giving interceptors the chance to reject any possible interface methods as applied to the receiver. For example, might runreceiver.method1(null, false)andreceiver.method2(0, null)if methods with matching signatures were defined in the interfaces.- Throws:
Throwable
-
preCheckedCast
public static Checker.Thunk preCheckedCast(Class<?> clazz, Object exp, boolean ignoreAutoboxing, boolean coerce, boolean strict) throws Throwable - Throws:
Throwable
-