protected class SecureASTCustomizer.SecuringCodeVisitor
extends Object
implements GroovyCodeVisitor
This visitor directly implements the GroovyCodeVisitor interface instead of using the CodeVisitorSupport class to make sure that future features of the language gets managed by this visitor. Thus, adding a new feature would result in a compilation error if this visitor is not updated.
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
assertExpressionAuthorized(Expression expression)Checks that a given expression is either in the allowed list or not in the disallowed list. |
|
protected void |
assertStatementAuthorized(Statement statement)Checks that a given statement is either in the allowed list or not in the disallowed list. |
|
protected void |
assertTokenAuthorized(Token token)Checks that a given token is either in the allowed list or not in the disallowed list. |
|
protected ClassNode |
getExpressionType(ClassNode objectExpressionType)Returns the effective receiver type for nested array expressions. |
|
public void |
visitArgumentlistExpression(ArgumentListExpression expression)Validates an argument-list expression and then visits its elements. |
|
public void |
visitArrayExpression(ArrayExpression expression)Validates an array expression and then visits its elements and size expressions. |
|
public void |
visitAssertStatement(AssertStatement statement)Validates an assert statement and then visits its condition and message. |
|
public void |
visitAttributeExpression(AttributeExpression expression)Validates an attribute expression and then visits its receiver and attribute. |
|
public void |
visitBinaryExpression(BinaryExpression expression)Validates a binary expression, its operator token, and both operands. |
|
public void |
visitBitwiseNegationExpression(BitwiseNegationExpression expression)Validates a bitwise-negation expression and then visits its operand. |
|
public void |
visitBlockStatement(BlockStatement block)Validates a block statement and then visits each nested statement. |
|
public void |
visitBooleanExpression(BooleanExpression expression)Validates a boolean expression and then visits its wrapped expression. |
|
public void |
visitBreakStatement(BreakStatement statement)Validates a break statement. |
|
public void |
visitBytecodeExpression(BytecodeExpression expression)Validates a bytecode expression. |
|
public void |
visitCaseStatement(CaseStatement statement)Validates a case statement and then visits its condition and body. |
|
public void |
visitCastExpression(CastExpression expression)Validates a cast expression and then visits its operand. |
|
public void |
visitCatchStatement(CatchStatement statement)Validates a catch block and then visits its body. |
|
public void |
visitClassExpression(ClassExpression expression)Validates a class expression. |
|
public void |
visitClosureExpression(ClosureExpression expression)Validates a closure expression and then visits its body when closures are allowed. |
|
public void |
visitClosureListExpression(ClosureListExpression closureListExpression)Validates a closure-list expression and then visits its nested expressions. |
|
public void |
visitConstantExpression(ConstantExpression expression)Validates a constant expression and its constant type. |
|
public void |
visitConstructorCallExpression(ConstructorCallExpression call)Validates a constructor call and then visits its arguments. |
|
public void |
visitContinueStatement(ContinueStatement statement)Validates a continue statement. |
|
public void |
visitDeclarationExpression(DeclarationExpression expression)Validates a declaration expression via binary-expression handling. |
|
public void |
visitDoWhileLoop(DoWhileStatement loop)Validates a do/while loop and then visits its body and condition. |
|
public void |
visitEmptyStatement(EmptyStatement statement)Ignores empty statements. |
|
public void |
visitExpressionStatement(ExpressionStatement statement)Validates an expression statement and then visits its expression. |
|
public void |
visitFieldExpression(FieldExpression expression)Validates a field expression. |
|
public void |
visitForLoop(ForStatement forLoop)Validates a for loop and then visits its collection and body. |
|
public void |
visitGStringExpression(GStringExpression expression)Validates a GString expression and then visits its string and value parts. |
|
public void |
visitIfElse(IfStatement ifElse)Validates an if-else statement and then visits its condition and branches. |
|
public void |
visitLambdaExpression(LambdaExpression expression)Delegates lambda-expression validation to closure-expression handling. |
|
public void |
visitListExpression(ListExpression expression)Validates a list expression and then visits its elements. |
|
public void |
visitMapEntryExpression(MapEntryExpression expression)Validates a map entry expression and then visits its key and value. |
|
public void |
visitMapExpression(MapExpression expression)Validates a map expression and then visits its entries. |
|
public void |
visitMethodCallExpression(MethodCallExpression call)Validates a method call and then visits its receiver, name, and arguments. |
|
public void |
visitMethodPointerExpression(MethodPointerExpression expression)Validates a method-pointer expression and then visits its target and method name. |
|
public void |
visitMethodReferenceExpression(MethodReferenceExpression expression)Delegates method-reference validation to method-pointer handling. |
|
public void |
visitNotExpression(NotExpression expression)Validates a logical-not expression and then visits its operand. |
|
public void |
visitPostfixExpression(PostfixExpression expression)Validates a postfix expression and then visits its operand. |
|
public void |
visitPrefixExpression(PrefixExpression expression)Validates a prefix expression and then visits its operand. |
|
public void |
visitPropertyExpression(PropertyExpression expression)Validates a property expression and then visits its receiver and property. |
|
public void |
visitRangeExpression(RangeExpression expression)Validates a range expression and then visits both endpoints. |
|
public void |
visitReturnStatement(ReturnStatement statement)Validates a return statement and then visits its return value. |
|
public void |
visitShortTernaryExpression(ElvisOperatorExpression expression)Validates an Elvis expression and then delegates to ternary-expression handling. |
|
public void |
visitSpreadExpression(SpreadExpression expression)Validates a spread expression and then visits its nested expression. |
|
public void |
visitSpreadMapExpression(SpreadMapExpression expression)Validates a spread-map expression and then visits its nested expression. |
|
public void |
visitStaticMethodCallExpression(StaticMethodCallExpression call)Validates a static method call and then visits its arguments. |
|
public void |
visitSwitch(SwitchStatement statement)Validates a switch statement and then visits its selector and branches. |
|
public void |
visitSynchronizedStatement(SynchronizedStatement statement)Validates a synchronized statement and then visits its expression and body. |
|
public void |
visitTernaryExpression(TernaryExpression expression)Validates a ternary expression and then visits all branches. |
|
public void |
visitThrowStatement(ThrowStatement statement)Validates a throw statement and then visits the thrown expression. |
|
public void |
visitTryCatchFinally(TryCatchStatement statement)Validates a try-catch-finally statement and then visits all nested blocks. |
|
public void |
visitTupleExpression(TupleExpression expression)Validates a tuple expression and then visits its elements. |
|
public void |
visitUnaryMinusExpression(UnaryMinusExpression expression)Validates a unary-minus expression and then visits its operand. |
|
public void |
visitUnaryPlusExpression(UnaryPlusExpression expression)Validates a unary-plus expression and then visits its operand. |
|
public void |
visitVariableExpression(VariableExpression expression)Validates a variable expression and its inferred type. |
|
public void |
visitWhileLoop(WhileStatement loop)Validates a while loop and then visits its condition and body. |
Checks that a given expression is either in the allowed list or not in the disallowed list.
expression - the expression to be checkedChecks that a given statement is either in the allowed list or not in the disallowed list.
statement - the statement to be checkedChecks that a given token is either in the allowed list or not in the disallowed list.
token - the token to be checkedReturns the effective receiver type for nested array expressions.
objectExpressionType - the candidate receiver typeValidates an argument-list expression and then visits its elements.
expression - the argument-list expression to visitValidates an array expression and then visits its elements and size expressions.
expression - the array expression to visitValidates an assert statement and then visits its condition and message.
statement - the statement to visitValidates an attribute expression and then visits its receiver and attribute.
expression - the attribute expression to visitValidates a binary expression, its operator token, and both operands.
expression - the binary expression to visitValidates a bitwise-negation expression and then visits its operand.
expression - the bitwise-negation expression to visitValidates a block statement and then visits each nested statement.
block - the block statement to visitValidates a boolean expression and then visits its wrapped expression.
expression - the boolean expression to visitValidates a break statement.
statement - the statement to visitValidates a bytecode expression.
expression - the bytecode expression to visitValidates a case statement and then visits its condition and body.
statement - the statement to visitValidates a cast expression and then visits its operand.
expression - the cast expression to visitValidates a catch block and then visits its body.
statement - the statement to visitValidates a class expression.
expression - the class expression to visitValidates a closure expression and then visits its body when closures are allowed.
expression - the closure expression to visitValidates a closure-list expression and then visits its nested expressions.
closureListExpression - the closure-list expression to visitValidates a constant expression and its constant type.
expression - the constant expression to visitValidates a constructor call and then visits its arguments.
call - the constructor call to visitValidates a continue statement.
statement - the statement to visitValidates a declaration expression via binary-expression handling.
expression - the declaration expression to visit Validates a do/while loop and then visits its body and condition.
loop - the loop to visitIgnores empty statements.
statement - the empty statementValidates an expression statement and then visits its expression.
statement - the statement to visitValidates a field expression.
expression - the field expression to visit Validates a for loop and then visits its collection and body.
forLoop - the loop to visitValidates a GString expression and then visits its string and value parts.
expression - the GString expression to visitValidates an if-else statement and then visits its condition and branches.
ifElse - the conditional statement to visitDelegates lambda-expression validation to closure-expression handling.
expression - the lambda expression to visitValidates a list expression and then visits its elements.
expression - the list expression to visitValidates a map entry expression and then visits its key and value.
expression - the map entry expression to visitValidates a map expression and then visits its entries.
expression - the map expression to visitValidates a method call and then visits its receiver, name, and arguments.
call - the method call expression to visitValidates a method-pointer expression and then visits its target and method name.
expression - the method-pointer expression to visitDelegates method-reference validation to method-pointer handling.
expression - the method-reference expression to visitValidates a logical-not expression and then visits its operand.
expression - the not expression to visitValidates a postfix expression and then visits its operand.
expression - the postfix expression to visitValidates a prefix expression and then visits its operand.
expression - the prefix expression to visitValidates a property expression and then visits its receiver and property.
expression - the property expression to visitValidates a range expression and then visits both endpoints.
expression - the range expression to visitValidates a return statement and then visits its return value.
statement - the statement to visitValidates an Elvis expression and then delegates to ternary-expression handling.
expression - the Elvis expression to visitValidates a spread expression and then visits its nested expression.
expression - the spread expression to visitValidates a spread-map expression and then visits its nested expression.
expression - the spread-map expression to visitValidates a static method call and then visits its arguments.
call - the static method call to visitValidates a switch statement and then visits its selector and branches.
statement - the statement to visitValidates a synchronized statement and then visits its expression and body.
statement - the statement to visitValidates a ternary expression and then visits all branches.
expression - the ternary expression to visitValidates a throw statement and then visits the thrown expression.
statement - the statement to visitValidates a try-catch-finally statement and then visits all nested blocks.
statement - the statement to visitValidates a tuple expression and then visits its elements.
expression - the tuple expression to visitValidates a unary-minus expression and then visits its operand.
expression - the unary-minus expression to visitValidates a unary-plus expression and then visits its operand.
expression - the unary-plus expression to visitValidates a variable expression and its inferred type.
expression - the variable expression to visit Validates a while loop and then visits its condition and body.
loop - the loop to visit