Package: org.codehaus.groovy.control.customizers

## [Java] Class SecureASTCustomizer.SecuringCodeVisitor

- org.codehaus.groovy.control.customizers.SecureASTCustomizer.SecuringCodeVisitor

- All Implemented Interfaces and Traits:
    GroovyCodeVisitor

      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.

- - ### Methods Summary

    Methods
    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` | `visitSwitchExpression(SwitchExpression expression)` Validates a switch expression and then visits its selector and arms (GROOVY-12255).
    `` | `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.
    `` | `public void` | `visitYieldStatement(YieldStatement statement)` Validates a yield statement and then visits its operand (GROOVY-12255).

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### protected void assertExpressionAuthorized(Expression expression)

      Checks that a given expression is either in the allowed list or not in the disallowed list.

      throws:
        SecurityException if usage of this expression class is forbidden
      Parameters:
        `expression` - the expression to be checked

    - #### protected void assertStatementAuthorized(Statement statement)

      Checks that a given statement is either in the allowed list or not in the disallowed list.

      throws:
        SecurityException if usage of this statement class is forbidden
      Parameters:
        `statement` - the statement to be checked

    - #### protected void assertTokenAuthorized(Token token)

      Checks that a given token is either in the allowed list or not in the disallowed list.

      throws:
        SecurityException if usage of this token is forbidden
      Parameters:
        `token` - the token to be checked

    - #### protected ClassNode getExpressionType(ClassNode objectExpressionType)

      Returns the effective receiver type for nested array expressions.

      Parameters:
        `objectExpressionType` - the candidate receiver type
      Returns:
        the component type for arrays, otherwise the original type

    - #### public void visitArgumentlistExpression(ArgumentListExpression expression)

      Validates an argument-list expression and then visits its elements.

      Parameters:
        `expression` - the argument-list expression to visit

    - #### public void visitArrayExpression(ArrayExpression expression)

      Validates an array expression and then visits its elements and size expressions.

      Parameters:
        `expression` - the array expression to visit

    - #### public void visitAssertStatement(AssertStatement statement)

      Validates an assert statement and then visits its condition and message.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitAttributeExpression(AttributeExpression expression)

      Validates an attribute expression and then visits its receiver and attribute.

      Parameters:
        `expression` - the attribute expression to visit

    - #### public void visitBinaryExpression(BinaryExpression expression)

      Validates a binary expression, its operator token, and both operands.

      Parameters:
        `expression` - the binary expression to visit

    - #### public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

      Validates a bitwise-negation expression and then visits its operand.

      Parameters:
        `expression` - the bitwise-negation expression to visit

    - #### public void visitBlockStatement(BlockStatement block)

      Validates a block statement and then visits each nested statement.

      Parameters:
        `block` - the block statement to visit

    - #### public void visitBooleanExpression(BooleanExpression expression)

      Validates a boolean expression and then visits its wrapped expression.

      Parameters:
        `expression` - the boolean expression to visit

    - #### public void visitBreakStatement(BreakStatement statement)

      Validates a break statement.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitBytecodeExpression(BytecodeExpression expression)

      Validates a bytecode expression.

      Parameters:
        `expression` - the bytecode expression to visit

    - #### public void visitCaseStatement(CaseStatement statement)

      Validates a case statement and then visits its condition and body.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitCastExpression(CastExpression expression)

      Validates a cast expression and then visits its operand.

      Parameters:
        `expression` - the cast expression to visit

    - #### public void visitCatchStatement(CatchStatement statement)

      Validates a catch block and then visits its body.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitClassExpression(ClassExpression expression)

      Validates a class expression.

      Parameters:
        `expression` - the class expression to visit

    - #### public void visitClosureExpression(ClosureExpression expression)

      Validates a closure expression and then visits its body when closures are allowed.

      Parameters:
        `expression` - the closure expression to visit

    - #### public void visitClosureListExpression(ClosureListExpression closureListExpression)

      Validates a closure-list expression and then visits its nested expressions.

      Parameters:
        `closureListExpression` - the closure-list expression to visit

    - #### public void visitConstantExpression(ConstantExpression expression)

      Validates a constant expression and its constant type.

      Parameters:
        `expression` - the constant expression to visit

    - #### public void visitConstructorCallExpression(ConstructorCallExpression call)

      Validates a constructor call and then visits its arguments.

      Parameters:
        `call` - the constructor call to visit

    - #### public void visitContinueStatement(ContinueStatement statement)

      Validates a continue statement.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitDeclarationExpression(DeclarationExpression expression)

      Validates a declaration expression via binary-expression handling.

      Parameters:
        `expression` - the declaration expression to visit

    - #### public void visitDoWhileLoop(DoWhileStatement loop)

      Validates a `do`/`while` loop and then visits its body and condition.

      Parameters:
        `loop` - the loop to visit

    - #### public void visitEmptyStatement(EmptyStatement statement)

      Ignores empty statements.

      Parameters:
        `statement` - the empty statement

    - #### public void visitExpressionStatement(ExpressionStatement statement)

      Validates an expression statement and then visits its expression.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitFieldExpression(FieldExpression expression)

      Validates a field expression.

      Parameters:
        `expression` - the field expression to visit

    - #### public void visitForLoop(ForStatement forLoop)

      Validates a `for` loop and then visits its collection and body.

      Parameters:
        `forLoop` - the loop to visit

    - #### public void visitGStringExpression(GStringExpression expression)

      Validates a GString expression and then visits its string and value parts.

      Parameters:
        `expression` - the GString expression to visit

    - #### public void visitIfElse(IfStatement ifElse)

      Validates an if-else statement and then visits its condition and branches.

      Parameters:
        `ifElse` - the conditional statement to visit

    - #### public void visitLambdaExpression(LambdaExpression expression)

      Delegates lambda-expression validation to closure-expression handling.

      Parameters:
        `expression` - the lambda expression to visit

    - #### public void visitListExpression(ListExpression expression)

      Validates a list expression and then visits its elements.

      Parameters:
        `expression` - the list expression to visit

    - #### public void visitMapEntryExpression(MapEntryExpression expression)

      Validates a map entry expression and then visits its key and value.

      Parameters:
        `expression` - the map entry expression to visit

    - #### public void visitMapExpression(MapExpression expression)

      Validates a map expression and then visits its entries.

      Parameters:
        `expression` - the map expression to visit

    - #### public void visitMethodCallExpression(MethodCallExpression call)

      Validates a method call and then visits its receiver, name, and arguments.

      Parameters:
        `call` - the method call expression to visit

    - #### public void visitMethodPointerExpression(MethodPointerExpression expression)

      Validates a method-pointer expression and then visits its target and method name.

      Parameters:
        `expression` - the method-pointer expression to visit

    - #### public void visitMethodReferenceExpression(MethodReferenceExpression expression)

      Delegates method-reference validation to method-pointer handling.

      Parameters:
        `expression` - the method-reference expression to visit

    - #### public void visitNotExpression(NotExpression expression)

      Validates a logical-not expression and then visits its operand.

      Parameters:
        `expression` - the not expression to visit

    - #### public void visitPostfixExpression(PostfixExpression expression)

      Validates a postfix expression and then visits its operand.

      Parameters:
        `expression` - the postfix expression to visit

    - #### public void visitPrefixExpression(PrefixExpression expression)

      Validates a prefix expression and then visits its operand.

      Parameters:
        `expression` - the prefix expression to visit

    - #### public void visitPropertyExpression(PropertyExpression expression)

      Validates a property expression and then visits its receiver and property.

      Parameters:
        `expression` - the property expression to visit

    - #### public void visitRangeExpression(RangeExpression expression)

      Validates a range expression and then visits both endpoints.

      Parameters:
        `expression` - the range expression to visit

    - #### public void visitReturnStatement(ReturnStatement statement)

      Validates a return statement and then visits its return value.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitShortTernaryExpression(ElvisOperatorExpression expression)

      Validates an Elvis expression and then delegates to ternary-expression handling.

      Parameters:
        `expression` - the Elvis expression to visit

    - #### public void visitSpreadExpression(SpreadExpression expression)

      Validates a spread expression and then visits its nested expression.

      Parameters:
        `expression` - the spread expression to visit

    - #### public void visitSpreadMapExpression(SpreadMapExpression expression)

      Validates a spread-map expression and then visits its nested expression.

      Parameters:
        `expression` - the spread-map expression to visit

    - #### public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

      Validates a static method call and then visits its arguments.

      Parameters:
        `call` - the static method call to visit

    - #### public void visitSwitch(SwitchStatement statement)

      Validates a switch statement and then visits its selector and branches.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitSwitchExpression(SwitchExpression expression)

      Validates a switch expression and then visits its selector and arms (GROOVY-12255).

      Parameters:
        `expression` - the switch expression to visit
      Since:
        6.0.0

    - #### public void visitSynchronizedStatement(SynchronizedStatement statement)

      Validates a synchronized statement and then visits its expression and body.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitTernaryExpression(TernaryExpression expression)

      Validates a ternary expression and then visits all branches.

      Parameters:
        `expression` - the ternary expression to visit

    - #### public void visitThrowStatement(ThrowStatement statement)

      Validates a throw statement and then visits the thrown expression.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitTryCatchFinally(TryCatchStatement statement)

      Validates a try-catch-finally statement and then visits all nested blocks.

      Parameters:
        `statement` - the statement to visit

    - #### public void visitTupleExpression(TupleExpression expression)

      Validates a tuple expression and then visits its elements.

      Parameters:
        `expression` - the tuple expression to visit

    - #### public void visitUnaryMinusExpression(UnaryMinusExpression expression)

      Validates a unary-minus expression and then visits its operand.

      Parameters:
        `expression` - the unary-minus expression to visit

    - #### public void visitUnaryPlusExpression(UnaryPlusExpression expression)

      Validates a unary-plus expression and then visits its operand.

      Parameters:
        `expression` - the unary-plus expression to visit

    - #### public void visitVariableExpression(VariableExpression expression)

      Validates a variable expression and its inferred type.

      Parameters:
        `expression` - the variable expression to visit

    - #### public void visitWhileLoop(WhileStatement loop)

      Validates a `while` loop and then visits its condition and body.

      Parameters:
        `loop` - the loop to visit

    - #### public void visitYieldStatement(YieldStatement statement)

      Validates a yield statement and then visits its operand (GROOVY-12255).

      Parameters:
        `statement` - the yield statement to visit
      Since:
        6.0.0