From db618967e5bf7c1b37a1d6da94e23a412bfd2091 Mon Sep 17 00:00:00 2001 From: idawda Date: Thu, 7 Nov 2024 19:07:14 +0530 Subject: [PATCH 1/2] NR-336715: Fix for NR-322822 Where Incorrect user class details found in mule-demo-app --- .../agent/security/instrumentation/mule36/MuleHelper.java | 4 +--- .../processor/InvokerMessageProcessor_Instrumentation.java | 1 + .../agent/security/instrumentation/mule37/MuleHelper.java | 4 +--- .../processor/InvokerMessageProcessor_Instrumentation.java | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/instrumentation-security/mule-3.6/src/main/java/com/newrelic/agent/security/instrumentation/mule36/MuleHelper.java b/instrumentation-security/mule-3.6/src/main/java/com/newrelic/agent/security/instrumentation/mule36/MuleHelper.java index 4683aab38..ef8aaeeca 100644 --- a/instrumentation-security/mule-3.6/src/main/java/com/newrelic/agent/security/instrumentation/mule36/MuleHelper.java +++ b/instrumentation-security/mule-3.6/src/main/java/com/newrelic/agent/security/instrumentation/mule36/MuleHelper.java @@ -124,9 +124,7 @@ public static void gatherURLMappings(HttpListener messageSource, List Date: Thu, 7 Nov 2024 19:08:35 +0530 Subject: [PATCH 2/2] process stacktrace in mule server for both RXSS and non RXSS events --- .../listener/HttpRequestToMuleEvent_Instrumentation.java | 4 +--- .../listener/async/RequestHandler_Instrumentation.java | 4 +--- .../InvokerMessageProcessor_Instrumentation.java | 9 +++++++++ .../listener/HttpRequestToMuleEvent_Instrumentation.java | 4 +--- .../listener/async/RequestHandler_Instrumentation.java | 4 +--- .../InvokerMessageProcessor_Instrumentation.java | 9 +++++++++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java b/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java index c67512563..5aa5916de 100644 --- a/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java +++ b/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java @@ -82,9 +82,6 @@ private static void preprocessSecurityHook(HttpRequestContext requestContext) { // TODO: Create OutBoundHttp data here : Skipping for now. securityRequest.setContentType(MuleHelper.getContentType(securityRequest.getHeaders())); - - // TODO: need to update UserClassEntity - ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); securityRequest.setRequestParsed(true); } catch (Throwable ignored){} } @@ -95,6 +92,7 @@ private static void postProcessSecurityHook() { ) { return; } + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); ServletHelper.executeBeforeExitingTransaction(); //Add request URI hash to low severity event filter LowSeverityHelper.addRrequestUriToEventFilter(NewRelicSecurity.getAgent().getSecurityMetaData().getRequest()); diff --git a/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java b/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java index 5b4de2ce6..72cdf26b1 100644 --- a/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java +++ b/instrumentation-security/mule-3.6/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java @@ -73,9 +73,6 @@ private void preprocessSecurityHook(HttpRequestContext requestContext) { // TODO: Create OutBoundHttp data here : Skipping for now. securityRequest.setContentType(MuleHelper.getContentType(securityRequest.getHeaders())); - - // TODO: need to update UserClassEntity - ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); securityRequest.setRequestParsed(true); } catch (Throwable ignored){} } @@ -85,6 +82,7 @@ private void postProcessSecurityHook() { if (!NewRelicSecurity.isHookProcessingActive()) { return; } + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); ServletHelper.executeBeforeExitingTransaction(); //Add request URI hash to low severity event filter LowSeverityHelper.addRrequestUriToEventFilter(NewRelicSecurity.getAgent().getSecurityMetaData().getRequest()); diff --git a/instrumentation-security/mule-3.6/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java b/instrumentation-security/mule-3.6/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java index d497dc716..a19377b01 100644 --- a/instrumentation-security/mule-3.6/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java +++ b/instrumentation-security/mule-3.6/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java @@ -1,9 +1,13 @@ package org.mule.processor; import com.newrelic.agent.security.instrumentation.mule36.MuleHelper; +import com.newrelic.api.agent.security.instrumentation.helpers.ServletHelper; +import com.newrelic.api.agent.security.instrumentation.helpers.URLMappingsHelper; import com.newrelic.api.agent.weaver.MatchType; import com.newrelic.api.agent.weaver.Weave; import com.newrelic.api.agent.weaver.Weaver; +import org.mule.api.MuleEvent; +import org.mule.api.MuleException; import org.mule.api.lifecycle.InitialisationException; @Weave(originalName = "org.mule.processor.InvokerMessageProcessor", type = MatchType.ExactClass) @@ -18,4 +22,9 @@ public void initialise() throws InitialisationException { URLMappingsHelper.getHandlersHash().add(object.getClass().getName().hashCode()); } } + + public MuleEvent process(MuleEvent event) throws MuleException { + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); + return Weaver.callOriginal(); + } } diff --git a/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java b/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java index dbd8ff353..099e8119a 100644 --- a/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java +++ b/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/HttpRequestToMuleEvent_Instrumentation.java @@ -82,9 +82,6 @@ private static void preprocessSecurityHook(HttpRequestContext requestContext) { // TODO: Create OutBoundHttp data here : Skipping for now. securityRequest.setContentType(MuleHelper.getContentType(securityRequest.getHeaders())); - - // TODO: need to update UserClassEntity - ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); securityRequest.setRequestParsed(true); } catch (Throwable ignored){} } @@ -94,6 +91,7 @@ private static void postProcessSecurityHook() { if (!NewRelicSecurity.isHookProcessingActive()) { return; } + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); ServletHelper.executeBeforeExitingTransaction(); //Add request URI hash to low severity event filter LowSeverityHelper.addRrequestUriToEventFilter(NewRelicSecurity.getAgent().getSecurityMetaData().getRequest()); diff --git a/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java b/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java index 4dd3ad108..166369320 100644 --- a/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java +++ b/instrumentation-security/mule-3.7/src/main/java/org/mule/module/http/internal/listener/async/RequestHandler_Instrumentation.java @@ -73,9 +73,6 @@ private void preprocessSecurityHook(HttpRequestContext requestContext) { // TODO: Create OutBoundHttp data here : Skipping for now. securityRequest.setContentType(MuleHelper.getContentType(securityRequest.getHeaders())); - - // TODO: need to update UserClassEntity - ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); securityRequest.setRequestParsed(true); } catch (Throwable ignored){} } @@ -85,6 +82,7 @@ private void postProcessSecurityHook() { if (!NewRelicSecurity.isHookProcessingActive()) { return; } + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); ServletHelper.executeBeforeExitingTransaction(); //Add request URI hash to low severity event filter LowSeverityHelper.addRrequestUriToEventFilter(NewRelicSecurity.getAgent().getSecurityMetaData().getRequest()); diff --git a/instrumentation-security/mule-3.7/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java b/instrumentation-security/mule-3.7/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java index da294f74f..b52486147 100644 --- a/instrumentation-security/mule-3.7/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java +++ b/instrumentation-security/mule-3.7/src/main/java/org/mule/processor/InvokerMessageProcessor_Instrumentation.java @@ -1,9 +1,13 @@ package org.mule.processor; import com.newrelic.agent.security.instrumentation.mule37.MuleHelper; +import com.newrelic.api.agent.security.instrumentation.helpers.ServletHelper; +import com.newrelic.api.agent.security.instrumentation.helpers.URLMappingsHelper; import com.newrelic.api.agent.weaver.MatchType; import com.newrelic.api.agent.weaver.Weave; import com.newrelic.api.agent.weaver.Weaver; +import org.mule.api.MuleEvent; +import org.mule.api.MuleException; import org.mule.api.lifecycle.InitialisationException; @Weave(originalName = "org.mule.processor.InvokerMessageProcessor", type = MatchType.ExactClass) @@ -18,4 +22,9 @@ public void initialise() throws InitialisationException { URLMappingsHelper.getHandlersHash().add(object.getClass().getName().hashCode()); } } + + public MuleEvent process(MuleEvent event) throws MuleException { + ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME); + return Weaver.callOriginal(); + } }