Search in sources :

Example 11 with ASTVariableDeclaration

use of net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration in project pmd by pmd.

the class ApexBadCryptoRule method visit.

@Override
public Object visit(ASTUserClass node, Object data) {
    if (Helper.isTestMethodOrClass(node)) {
        return data;
    }
    List<ASTFieldDeclaration> fieldDecl = node.findDescendantsOfType(ASTFieldDeclaration.class);
    for (ASTFieldDeclaration var : fieldDecl) {
        findSafeVariables(var);
    }
    List<ASTVariableDeclaration> variableDecl = node.findDescendantsOfType(ASTVariableDeclaration.class);
    for (ASTVariableDeclaration var : variableDecl) {
        findSafeVariables(var);
    }
    List<ASTMethodCallExpression> methodCalls = node.findDescendantsOfType(ASTMethodCallExpression.class);
    for (ASTMethodCallExpression methodCall : methodCalls) {
        if (Helper.isMethodName(methodCall, CRYPTO, ENCRYPT) || Helper.isMethodName(methodCall, CRYPTO, DECRYPT) || Helper.isMethodName(methodCall, CRYPTO, ENCRYPT_WITH_MANAGED_IV) || Helper.isMethodName(methodCall, CRYPTO, DECRYPT_WITH_MANAGED_IV)) {
            validateStaticIVorKey(methodCall, data);
        }
    }
    potentiallyStaticBlob.clear();
    return data;
}
Also used : ASTVariableDeclaration(net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration) ASTFieldDeclaration(net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclaration) ASTMethodCallExpression(net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression)

Aggregations

ASTVariableDeclaration (net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration)11 ASTMethodCallExpression (net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression)7 ASTVariableExpression (net.sourceforge.pmd.lang.apex.ast.ASTVariableExpression)5 ASTAssignmentExpression (net.sourceforge.pmd.lang.apex.ast.ASTAssignmentExpression)4 ASTField (net.sourceforge.pmd.lang.apex.ast.ASTField)4 VariableDeclaration (apex.jorje.semantic.ast.statement.VariableDeclaration)2 ASTBinaryExpression (net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression)2 ASTFieldDeclaration (net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclaration)2 ASTLiteralExpression (net.sourceforge.pmd.lang.apex.ast.ASTLiteralExpression)2 ASTMethod (net.sourceforge.pmd.lang.apex.ast.ASTMethod)2 StandardFieldInfo (apex.jorje.semantic.symbol.member.variable.StandardFieldInfo)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 ASTNewObjectExpression (net.sourceforge.pmd.lang.apex.ast.ASTNewObjectExpression)1 ASTReturnStatement (net.sourceforge.pmd.lang.apex.ast.ASTReturnStatement)1 ASTUserClass (net.sourceforge.pmd.lang.apex.ast.ASTUserClass)1