oarevalo / BugLogHQ

BugLogHQ is a tool to centralize the handling of automated bug reports from multiple applications. BugLogHQ provides a unified view of error messages sent from any number of applications, allowing the developer to search, graph, forward, and explore the bug reports submitted by the applications.
http://www.bugloghq.com
155 stars 67 forks source link

ExtraInfo and JSON with null #146

Closed KrunchMuffin closed 7 years ago

KrunchMuffin commented 7 years ago

Seems the sanitizeDump is getting tripped up on JSON keys with null values.

An error ocurred while rendering ExtraInfo! Element customfield_10002 is undefined in a CFML structure referenced as part of an expression.

"customfield_10001": "10901_*:*_1_*:*_0_*|*_10400_*:*_1_*:*_20200",
"customfield_10002": null,
oarevalo commented 7 years ago

interesting, are you noticing this on a particular version of CF/Railo/Lucee?

On Thu, Sep 15, 2016 at 8:18 AM, Derek notifications@github.com wrote:

Seems the sanitizeDump is getting tripped up on JSON keys with null values.

An error ocurred while rendering ExtraInfo! Element customfield_10002 is undefined in a CFML structure referenced as part of an expression.

"customfield_10001": "10901:1:0|10400:1:20200", "customfield_10002": null,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oarevalo/BugLogHQ/issues/146, or mute the thread https://github.com/notifications/unsubscribe-auth/AAI6NHbXWxRQ-ziJI1U-m-lyzHws0RwNks5qqWHFgaJpZM4J9_lt .

Oscar Arevalo twitter: @oarevalo https://twitter.com/oarevalo gh: https://github.com/oarevalo b: http://www.oscararevalo.com

KrunchMuffin commented 7 years ago

Sorry, ACF11

oarevalo commented 7 years ago

it might be a CF thing. I ran this code in Railo 4.1 and the bug report was added to BugLog without any issue:

            json = deserializeJSON("{'a':1,'b':2,'c':null}");
            application.buglog.notifyService(
                    message = "a json with a null",
                    extraInfo = json
                );

Does this reflect your use case?

KrunchMuffin commented 7 years ago

yes, pretty much. it's puking on line 563 <cfif isStruct(arguments.data[local.i])>

oarevalo commented 7 years ago

i wonder if a !isNull(arguments.data[local.i]) && isStruct(....) would take care of the problem here. Is that something you can quickly try?

KrunchMuffin commented 7 years ago

I actually did this and it worked...

        <cfif !StructKeyExists(arguments.data,local.i)>
            <cfset arguments.data[local.i] = "null">
        </cfif>
oarevalo commented 7 years ago

i'm not sure that does the same thing... that part of the code what is supposed to do is to check if the value of an attribute of the given struct is itself a struct, so that it then checks if the individual members of that struct need to be sanitized. If I remember correctly this was added in case the extraInfo had for example a form attribute with all the input fields on the submitted form, in which fields like password or credit_card_number or things like that should be scrubbed before being sent to the buglog server. With this fix it looks more like it will remove anything that is not a struct.

oarevalo commented 7 years ago

oops nevermind.... i thought you were doing another isStruct; but with now I see what you are trying to do. Can you post the entire body of the sanitizeKeyData function? or even better submit a PR?

KrunchMuffin commented 7 years ago

sure