Skip to content

Commit

Permalink
1.6.0 from TheRealAgentK dev repo (#55)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheRealAgentK authored Nov 23, 2023
1 parent edd82d4 commit 89ef892
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.*
!.gitignore
*.iml
/server.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"homepage":"https://github.com/MindscapeHQ/raygun4cfml/",
"documentation":"https://github.com/MindscapeHQ/raygun4cfml/blob/master/README.md",
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
49 changes: 31 additions & 18 deletions src/nz/co/ventego-creative/raygun4cfml/RaygunClient.cfc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ limitations under the License.
</cffunction>


<cffunction name="sendAsync" access="public" output="true" returntype="void">
<cffunction name="sendAsync" access="public" output="false" returntype="void">

<cfargument name="issueDataStruct" type="any" required="yes">
<cfargument name="userCustomData" type="RaygunUserCustomData" required="no">
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -235,36 +236,48 @@ limitations under the License.
</cffunction>


<cffunction name="applyFilter" access="private" output="false" returntype="void">
<cffunction name="applyFilter" access="private" output="false" returntype="struct">

<cfargument name="contentFilter" type="RaygunContentFilter" required="yes">
<cfargument name="messageData" type="struct" required="yes">

<cfscript>
var defaultScopes = [url,form];
var filter = arguments.contentFilter.getFilter();
var match = {};
var matchResult = "";

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;
</cfscript>

</cffunction>
Expand Down
24 changes: 12 additions & 12 deletions src/nz/co/ventego-creative/raygun4cfml/RaygunExceptionMessage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -81,7 +81,7 @@ limitations under the License.
ArrayAppend(stackTraceData, stackTraceLineElement);
}
}
}
}

if (structKeyExists(entryPoint,"tagcontext")) {
lenTagContext = arraylen(entryPoint.tagcontext);
Expand All @@ -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;
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/nz/co/ventego-creative/raygun4cfml/RaygunRequestMessage.cfc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 89ef892

Please sign in to comment.