use of net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression in project pmd by pmd.
the class ApexInsecureEndpointRule method findInsecureEndpoints.
private void findInsecureEndpoints(AbstractApexNode<?> node) {
ASTVariableExpression variableNode = node.getFirstChildOfType(ASTVariableExpression.class);
findInnerInsecureEndpoints(node, variableNode);
ASTBinaryExpression binaryNode = node.getFirstChildOfType(ASTBinaryExpression.class);
if (binaryNode != null) {
findInnerInsecureEndpoints(binaryNode, variableNode);
}
}
use of net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression in project pmd by pmd.
the class ApexOpenRedirectRule method getObjectValue.
/**
* Finds any variables being present in PageReference constructor
*
* @param node
* - PageReference
* @param data
*/
private void getObjectValue(ApexNode<?> node, Object data) {
// PageReference(foo);
final List<ASTVariableExpression> variableExpressions = node.findChildrenOfType(ASTVariableExpression.class);
for (ASTVariableExpression variable : variableExpressions) {
if (variable.jjtGetChildIndex() == 0 && !listOfStringLiteralVariables.contains(Helper.getFQVariableName(variable))) {
addViolation(data, variable);
}
}
// PageReference(foo + bar)
final List<ASTBinaryExpression> binaryExpressions = node.findChildrenOfType(ASTBinaryExpression.class);
for (ASTBinaryExpression z : binaryExpressions) {
getObjectValue(z, data);
}
}
use of net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression in project pmd by pmd.
the class ApexSOQLInjectionRule method findSelectContainingVariables.
private void findSelectContainingVariables(AbstractApexNode<?> node) {
final ASTVariableExpression left = node.getFirstChildOfType(ASTVariableExpression.class);
final ASTBinaryExpression right = node.getFirstChildOfType(ASTBinaryExpression.class);
if (left != null && right != null) {
recursivelyCheckForSelect(left, right);
}
}
use of net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression in project pmd by pmd.
the class ApexSOQLInjectionRule method reportStrings.
private void reportStrings(ASTMethodCallExpression m, Object data) {
final HashSet<ASTVariableExpression> setOfSafeVars = new HashSet<>();
final List<ASTStandardCondition> conditions = m.findDescendantsOfType(ASTStandardCondition.class);
for (ASTStandardCondition c : conditions) {
List<ASTVariableExpression> vars = c.findDescendantsOfType(ASTVariableExpression.class);
setOfSafeVars.addAll(vars);
}
final List<ASTBinaryExpression> binaryExpr = m.findChildrenOfType(ASTBinaryExpression.class);
for (ASTBinaryExpression b : binaryExpr) {
List<ASTVariableExpression> vars = b.findDescendantsOfType(ASTVariableExpression.class);
for (ASTVariableExpression v : vars) {
String fqName = Helper.getFQVariableName(v);
if (selectContainingVariables.containsKey(fqName)) {
boolean isLiteral = selectContainingVariables.get(fqName);
if (isLiteral) {
continue;
}
}
if (setOfSafeVars.contains(v) || safeVariables.contains(fqName)) {
continue;
}
final ASTMethodCallExpression parentCall = v.getFirstParentOfType(ASTMethodCallExpression.class);
boolean isSafeMethod = Helper.isMethodName(parentCall, STRING, ESCAPE_SINGLE_QUOTES) || Helper.isMethodName(parentCall, STRING, JOIN);
if (!isSafeMethod) {
addViolation(data, v);
}
}
}
}
use of net.sourceforge.pmd.lang.apex.ast.ASTBinaryExpression in project pmd by pmd.
the class ApexXSSFromURLParamRule method processBinaryExpression.
private void processBinaryExpression(AbstractApexNode<?> node, Object data) {
ASTBinaryExpression nestedBinaryExpression = node.getFirstChildOfType(ASTBinaryExpression.class);
if (nestedBinaryExpression != null) {
processBinaryExpression(nestedBinaryExpression, data);
}
ASTMethodCallExpression methodCallAssignment = node.getFirstChildOfType(ASTMethodCallExpression.class);
if (methodCallAssignment != null) {
processInlineMethodCalls(methodCallAssignment, data, true);
}
final List<ASTVariableExpression> nodes = node.findChildrenOfType(ASTVariableExpression.class);
for (ASTVariableExpression n : nodes) {
if (urlParameterStrings.contains(Helper.getFQVariableName(n))) {
addViolation(data, n);
}
}
}
Aggregations