use of cfml.parsing.cfscript.CFFunctionExpression in project CFLint by cflint.
the class CFLint method process.
private void process(final CFExpression expression, final Element elem, Context oldcontext) {
if (expression != null) {
final Context context = oldcontext.subContext(elem);
for (final CFLintScanner plugin : extensions) {
try {
plugin.expression(expression, context, bugs);
for (final ContextMessage message : context.getMessages()) {
reportRule(elem, expression, context, plugin, message);
}
context.getMessages().clear();
} catch (final Exception e) {
printException(e);
reportRule(elem, expression, context, plugin, PLUGIN_ERROR);
fireCFLintException(e, PLUGIN_ERROR, context.getFilename(), null, null, null, null);
}
}
// Handle a few expression types in a special fashion.
if (expression instanceof CFVarDeclExpression) {
handler.addVariable(((CFVarDeclExpression) expression).getName());
}
//CFIdentifier should not decompose
if (expression instanceof CFIdentifier) {
final String name = ((CFIdentifier) expression).getName();
handler.checkVariable(name);
}
if (expression instanceof CFAssignmentExpression && !(expression instanceof CFTernaryExpression)) {
final Context assignmentContext = context.subContext(elem);
assignmentContext.setInAssignmentExpression(true);
process(((CFAssignmentExpression) expression).getLeft(), elem, assignmentContext);
// Right hand side is handled below. Left hand side gets a
// special context.
process(((CFAssignmentExpression) expression).getRight(), elem, context);
//Only process function call expressions
} else if (expression instanceof CFFullVarExpression) {
final CFFullVarExpression fullVarExpression = (CFFullVarExpression) expression;
if (context.isInAssignmentExpression() && new CFScopes().isScoped(fullVarExpression, "local") && fullVarExpression.getExpressions().size() > 1) {
handler.addVariable(fullVarExpression.getExpressions().get(1).Decompile(0));
}
for (final CFExpression expr : fullVarExpression.getExpressions()) {
if (expr instanceof CFFunctionExpression) {
process(expr, elem, context);
}
if (expr instanceof CFMember) {
process(((CFMember) expr).getExpression(), elem, context);
}
}
} else {
// Loop into all relevant nested (child) expressions.
for (CFExpression child : expression.decomposeExpression()) {
process(child, elem, context);
}
}
}
}
use of cfml.parsing.cfscript.CFFunctionExpression in project CFLint by cflint.
the class FunctionXChecker method expression.
@Override
public void expression(final CFExpression expression, final Context context, final BugList bugs) {
if (expression instanceof CFFunctionExpression) {
final String cfmlFunctionCheck = getParameter("functionName");
final CFFunctionExpression functionExpression = (CFFunctionExpression) expression;
if (functionExpression.getName().equalsIgnoreCase(cfmlFunctionCheck)) {
// int lineNo = expression.getLine() + context.startLine() - 1;
// structNew(lineNo, context, bugs);
context.addMessage("AVOID_USING_" + cfmlFunctionCheck.toUpperCase(), cfmlFunctionCheck);
}
}
}
use of cfml.parsing.cfscript.CFFunctionExpression in project CFLint by cflint.
the class QueryParamChecker method expression.
@Override
public void expression(final CFExpression expression, final Context context, final BugList bugs) {
if (expression instanceof CFFunctionExpression) {
final CFFunctionExpression functionExpression = (CFFunctionExpression) expression;
if (functionExpression.getFunctionName().equalsIgnoreCase("setSql") && !functionExpression.getArgs().isEmpty()) {
final CFExpression argsExpression = functionExpression.getArgs().get(0);
final Pattern p = Pattern.compile(".*#[^#].*", Pattern.DOTALL);
if (p.matcher(argsExpression.Decompile(0)).matches()) {
context.addMessage("QUERYPARAM_REQ", functionExpression.getName());
}
}
}
}
Aggregations