cflint / CFLint

Static code analysis for CFML (a linter)
BSD 3-Clause "New" or "Revised" License
173 stars 84 forks source link

Parsing Error. NullPointerException. cfml.parsing.cfscript.CFFunctionExpression.lambda$new$4 #602

Open Vintic opened 5 years ago

Vintic commented 5 years ago

Help me please. Why this can happen? Or how I can hide this message? java.lang.NullPointerException at cfml.parsing.cfscript.CFFunctionExpression.lambda$new$4(CFFunctionExpression.java:33) at java.util.ArrayList.forEach(ArrayList.java:1257) at cfml.parsing.cfscript.CFFunctionExpression.<init>(CFFunctionExpression.java:33) at cfml.parsing.cfscript.CFFunctionExpression.<init>(CFFunctionExpression.java:22) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitQualifiedFunctionCall(CFExpressionVisitor.java:457) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitQualifiedFunctionCall(CFExpressionVisitor.java:77) at cfml.CFSCRIPTParser$QualifiedFunctionCallContext.accept(CFSCRIPTParser.java:7255) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitMemberExpression(CFExpressionVisitor.java:286) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitMemberExpression(CFExpressionVisitor.java:77) at cfml.CFSCRIPTParser$MemberExpressionContext.accept(CFSCRIPTParser.java:6724) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitUnaryExpression(CFExpressionVisitor.java:242) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitBaseExpression(CFExpressionVisitor.java:223) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitBaseExpression(CFExpressionVisitor.java:77) at cfml.CFSCRIPTParser$BaseExpressionContext.accept(CFSCRIPTParser.java:5856) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) at cfml.CFSCRIPTParserBaseVisitor.visitStartExpression(CFSCRIPTParserBaseVisitor.java:237) at cfml.CFSCRIPTParser$StartExpressionContext.accept(CFSCRIPTParser.java:3117) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitAssignmentExpression(CFExpressionVisitor.java:195) at cfml.parsing.cfscript.walker.CFExpressionVisitor.visitAssignmentExpression(CFExpressionVisitor.java:77) at cfml.CFSCRIPTParser$AssignmentExpressionContext.accept(CFSCRIPTParser.java:5634) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46) at cfml.CFSCRIPTParserBaseVisitor.visitCfmlExpression(CFSCRIPTParserBaseVisitor.java:447) at cfml.CFSCRIPTParser$CfmlExpressionContext.accept(CFSCRIPTParser.java:5385) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at cfml.parsing.CFMLParser.parseCFMLExpression(CFMLParser.java:174) at com.cflint.CFLint.process(CFLint.java:466) at com.cflint.CFLint.processStack(CFLint.java:399) at com.cflint.CFLint.process(CFLint.java:342) at com.cflint.CFLint.scan(CFLint.java:295) at com.cflint.CFLint.scan(CFLint.java:206) at com.cflint.api.CFLintAPI.scan(CFLintAPI.java:65) at mteam.md.tasks.postCommitTasks.RejectCfErrors.checkContent(RejectCfErrors.java:89)

Error in: <cfset access_level_check = APPLICATION.sage_security.CheckSecurityLevel( @ 58: Error: "null" Location: cfml.parsing.cfscript.CFFunctionExpression.lambda$new$4(CFFunctionExpression.java:33)

Vintic commented 5 years ago

Ok, I found how to hide errors in console from external librari: `PrintStream originalStream = System.err; System.setErr(dummyStream); lintresult = cfLintAPI.scan(Collections.singletonList(tempFile.getAbsolutePath())); System.setErr(originalStream);

PrintStream dummyStream = new PrintStream(new OutputStream(){ public void write(int b) { // NO-OP } });`

KamasamaK commented 5 years ago

Reopening as this is still probably an error that should be looked at.

Vintic commented 5 years ago

I think, that can provide a file, which is checked.

lmajano commented 4 years ago

This happens to me when using lambda expressions:

this.constraints = {
        name        : { required : true },
        email       : { required : true, type : "email", udf : ( value, target ) => {
            if( isNull( arguments.value ) ) return false;
            return qb.from( "users" ).where( "email", arguments.value ).count() == 0;
        } },
        username    : { required : true, udf : ( value, target ) => {
            if( isNull( arguments.value ) ) return false;
            return qb.from( "users" ).where( "username", arguments.value ).count() == 0;
        }},
        password    : { required : true }
    };
lmajano commented 4 years ago

I have verified that the exception is caused by the lambda expressions which now Lucee and Adobe 2018 support

KamasamaK commented 4 years ago

@lmajano What version of CFLint/CFParser are you using? Arrow function support was added in CFParser 2.10.0, which is only being used in the latest CFLint v1.5.0 snapshots.

lmajano commented 4 years ago

1.4.1 the latest stable

KamasamaK commented 4 years ago

@lmajano Can you clone the latest on the dev branch and build it with gradlew build to see if the issue is fixed?

KamasamaK commented 4 years ago

So I just tried linting with @lmajano's code using the latest snapshot and there is an issue with the parsing. I don't know yet if it's the same issue as the OP.