From 89ef8924229aeea7bc512a85e45c298dd86473a7 Mon Sep 17 00:00:00 2001 From: Kai Koenig Date: Thu, 23 Nov 2023 16:41:48 +1300 Subject: [PATCH] 1.6.0 from TheRealAgentK dev repo (#55) Release for 1.6.0 feature: Applying content/sensitivity filter later and against the full payload before being sent to Raygun. fix: fixed error in exception message on recent versions of ACF. --- .gitignore | 1 + README.md | 2 +- box.json | 4 +- changelog.md | 5 ++ .../raygun4cfml/RaygunClient.cfc | 49 ++++++++++++------- .../raygun4cfml/RaygunExceptionMessage.cfc | 24 ++++----- .../raygun4cfml/RaygunRequestMessage.cfc | 1 - 7 files changed, 52 insertions(+), 34 deletions(-) mode change 100644 => 100755 src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc mode change 100644 => 100755 src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc diff --git a/.gitignore b/.gitignore index 46a883e..1fb37bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .* !.gitignore *.iml +/server.json diff --git a/README.md b/README.md index 9cf52b8..25a2437 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ raygun4cfml Raygun Crash Reporting client for CFML. -Current Version: 1.5.0 (November 14 2022) +Current Version: 1.6.0 (November 23 2023) Dependencies: diff --git a/box.json b/box.json index 5f25d8c..a7c3409 100644 --- a/box.json +++ b/box.json @@ -1,7 +1,7 @@ { "name":"raygun4cfml", - "version":"1.5.0", - "location":"MindscapeHQ/raygun4cfml#1.5.0", + "version":"1.6.0", + "location":"MindscapeHQ/raygun4cfml#1.6.0", "author":"Kai Koenig ", "homepage":"https://github.com/MindscapeHQ/raygun4cfml/", "documentation":"https://github.com/MindscapeHQ/raygun4cfml/blob/master/README.md", diff --git a/changelog.md b/changelog.md index 9bdf046..3fbc231 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,11 @@ History ======= +1.6.0 (November 23 2023) + +- Fixed issue in RaygunExceptionMessage on recent version of ACF +- Changed content/sensitivity filter behaviour. It now runs just before data is being send to RG and filters against the full pre-send payload and not just URL/FORM scopes. + 1.5.0 (November 14 2022) - Added .sendAsync() entry point wrapping the HTTP call into its own thread. diff --git a/src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc b/src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc old mode 100644 new mode 100755 index f0b0465..ec83718 --- a/src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc +++ b/src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc @@ -96,7 +96,7 @@ limitations under the License. - + @@ -136,11 +136,6 @@ limitations under the License. throw("API integration not valid, cannot send message to Raygun"); } - if (isObject(variables.contentFilter)) - { - applyFilter(variables.contentFilter); - } - if (len(variables.appVersion)) { issueData["appVersion"] = variables.appVersion @@ -171,6 +166,12 @@ limitations under the License. } messageContent = message.build(duplicate(issueData)); + + if (isObject(variables.contentFilter)) + { + messageContent = applyFilter(variables.contentFilter, messageContent); + } + jSONData = serializeJSON(messageContent); // Remove '//' in case CF is adding it when serializing JSON (which is recommended in the CF Lockdown Guide) @@ -235,12 +236,12 @@ limitations under the License. - + + - var defaultScopes = [url,form]; var filter = arguments.contentFilter.getFilter(); var match = {}; var matchResult = ""; @@ -248,23 +249,35 @@ limitations under the License. for (var i=1; i<=ArrayLen(filter); i++) { // current filter object (filter,replacement) - match = filter[i]; + matcher = filter[i]; + + var findKeysByFilter = structFindKey(arguments.messageData,matcher.filter); - // loop over scopes - for (var j=1; j<=ArrayLen(defaultScopes); j++) + // loop over general finds and replace + for (var j=1; j<=ArrayLen(findKeysByFilter); j++) { - // for each scope loop over keys - for (var key in defaultScopes[j]) + var element = findKeysByFilter[j]; + element.owner[matcher.filter] = matcher.replacement; + } + + // additional case - rawData might be JSON + if (!isNull(arguments.messageData.details.request.rawData) && isJSON(arguments.messageData.details.request.rawData)) { + var rawDataJSON = deserializeJSON(arguments.messageData.details.request.rawData); + + var findRawDataKeysByFilter = structFindKey(rawDataJSON,matcher.filter); + + // loop over finds in rawData and replace + for (var k=1; k<=ArrayLen(findRawDataKeysByFilter); k++) { - matchResult = reMatchNoCase(match.filter,key); + var element = findRawDataKeysByFilter[k]; + element.owner[matcher.filter] = matcher.replacement; - if (isArray(matchResult) && ArrayLen(matchResult)) - { - defaultScopes[j][key] = match.replacement; - } } + arguments.messageData.details.request.rawData = serializeJSON(rawDataJSON); } } + + return arguments.messageData; diff --git a/src/nz/co/ventego-creative/raygun4cfml/RaygunExceptionMessage.cfc b/src/nz/co/ventego-creative/raygun4cfml/RaygunExceptionMessage.cfc index 2d277ce..a6307cb 100755 --- a/src/nz/co/ventego-creative/raygun4cfml/RaygunExceptionMessage.cfc +++ b/src/nz/co/ventego-creative/raygun4cfml/RaygunExceptionMessage.cfc @@ -45,14 +45,14 @@ limitations under the License. var entryPoint = arguments.issueDataStruct; - if (StructKeyExists(arguments.issueDataStruct,"Cause") && StructKeyExists(arguments.issueDataStruct.cause,"CatchBlock")) { - entryPoint = arguments.issueDataStruct.cause.CatchBlock; - } - - if (isArray(entryPoint.stacktrace)) { - stackTraceData = entryPoint.stacktrace; - } elseif (isSimpleValue(entryPoint.stacktrace)) { - stackTraceLines = entryPoint.stacktrace.split("\sat"); + if (StructKeyExists(arguments.issueDataStruct,"Cause") && StructKeyExists(arguments.issueDataStruct.cause,"CatchBlock")) { + entryPoint = arguments.issueDataStruct.cause.CatchBlock; + } + + if (isArray(entryPoint.stacktrace)) { + stackTraceData = entryPoint.stacktrace; + } else if (isSimpleValue(entryPoint.stacktrace)) { + stackTraceLines = entryPoint.stacktrace.split("\sat"); lenStackTraceLines = ArrayLen(stackTraceLines); for (j=2;j<=lenStackTraceLines;j++) @@ -81,7 +81,7 @@ limitations under the License. ArrayAppend(stackTraceData, stackTraceLineElement); } } - } + } if (structKeyExists(entryPoint,"tagcontext")) { lenTagContext = arraylen(entryPoint.tagcontext); @@ -94,7 +94,7 @@ limitations under the License. tagContextData[j]["fileName"] = trim( entryPoint.tagcontext[j]["template"] ); tagContextData[j]["lineNumber"] = trim( entryPoint.tagcontext[j]["line"] ); } - } + } returnContent["data"] = {"JavaStrackTrace" = stackTraceData}; returnContent["stackTrace"] = tagContextData; @@ -111,8 +111,8 @@ limitations under the License. } returnContent["catchingMethod"] = "Error struct"; } else { - // otherwise there's no root cause and the specific data has to be grabbed from somewhere else - if (!isLucee || isACF2021) { + // otherwise there's no root cause and the specific data has to be grabbed from somewhere else + if (!isLucee || isACF2021) { returnContent["data"]["type"] = entryPoint.type; } returnContent["message"] = entryPoint.message; diff --git a/src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc b/src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc old mode 100644 new mode 100755 index 9ab1448..2159061 --- a/src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc +++ b/src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc @@ -43,7 +43,6 @@ limitations under the License. returnContent["form"] = FORM; if (CGI.CONTENT_TYPE != "text/html" && CGI.CONTENT_TYPE != "application/x-www-form-urlencoded" && CGI.REQUEST_METHOD != "GET") { - // TODO check if this is JSON and if yes, deserialise and apply content filter in some way here and then deserialise again var temp = httpRequest.content; returnContent["rawData"] = Left(temp, rawDataMaxLength); } else {