Skip to content

Commit

Permalink
#89
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Oct 11, 2015
1 parent 740d50e commit 2337b8f
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions src/main/java/com/cflint/plugins/core/WriteDumpChecker.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.cflint.plugins.core;

import javax.swing.plaf.synth.SynthScrollBarUI;

import ro.fortsoft.pf4j.Extension;
import net.htmlparser.jericho.Element;

import cfml.parsing.cfscript.CFExpression;
import cfml.parsing.cfscript.CFFunctionExpression;
import cfml.parsing.cfscript.script.CFExpressionStatement;
import cfml.parsing.cfscript.script.CFScriptStatement;

Expand All @@ -16,29 +18,45 @@
public class WriteDumpChecker extends CFLintScannerAdapter {
final String severity = "INFO";



@Override
public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
if (expression instanceof CFExpressionStatement) {
String code = ((CFExpressionStatement) expression).getExpression().Decompile(0);
int lineNo = ((CFExpressionStatement) expression).getLine() + context.startLine() - 1;

if (code.toLowerCase().contains("writedump(")) {
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("writeDump")){
final int lineNo = functionExpression.getLine() + context.startLine() - 1;
writeDump(lineNo, context, bugs);
}
}

}

@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals("cfset")) {
String content = element.getStartTag().getTagContent().toString();
int lineNo = element.getSource().getRow(element.getBegin());
// @Override
// public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
// if (expression instanceof CFExpressionStatement) {
// String code = ((CFExpressionStatement) expression).getExpression().Decompile(0);
// int lineNo = ((CFExpressionStatement) expression).getLine() + context.startLine() - 1;
//
// if (code.toLowerCase().contains("writedump(")) {
// writeDump(lineNo, context, bugs);
// }
// }
// }

if (content.toLowerCase().contains("writedump(")) {
writeDump(lineNo, context, bugs);
}
}
}
// @Override
// public void element(final Element element, final Context context, final BugList bugs) {
// if (element.getName().equals("cfset")) {
// String content = element.getStartTag().getTagContent().toString();
// int lineNo = element.getSource().getRow(element.getBegin());
//
// if (content.toLowerCase().contains("writedump(")) {
// writeDump(lineNo, context, bugs);
// }
// }
// }

protected void writeDump(final int lineNo, final Context context, final BugList bugs) {
bugs.add(new BugInfo.BugInfoBuilder().setLine(lineNo).setMessageCode("AVOID_USING_WRITEDUMP")
Expand Down

0 comments on commit 2337b8f

Please sign in to comment.