Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NR-336715: Fix for NR-322822 Where Incorrect user class details found in Mule App #352

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ public static void gatherURLMappings(HttpListener messageSource, List<MessagePro
}
}
for (String method : messageSource.getAllowedMethods()){
if (handlerClass != null){
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(method, path, handlerClass));
}
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(method, path, handlerClass));
}
}catch (Exception ignored){}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){}
}
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){}
}
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -15,6 +19,12 @@ public void initialise() throws InitialisationException {
Weaver.callOriginal();
} finally {
MuleHelper.getHandlerMap().put(hashCode(), object.getClass().getName());
URLMappingsHelper.getHandlersHash().add(object.getClass().getName().hashCode());
}
}

public MuleEvent process(MuleEvent event) throws MuleException {
ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME);
return Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public static void gatherURLMappings(HttpListener messageSource, List<MessagePro
}
}
for (String method : messageSource.getAllowedMethods()){
if (handlerClass != null){
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(method, path, handlerClass));
}
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(method, path, handlerClass));
}
} catch (Exception ignored){}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){}
}
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){}
}
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -15,6 +19,12 @@ public void initialise() throws InitialisationException {
Weaver.callOriginal();
} finally {
MuleHelper.getHandlerMap().put(hashCode(), object.getClass().getName());
URLMappingsHelper.getHandlersHash().add(object.getClass().getName().hashCode());
}
}

public MuleEvent process(MuleEvent event) throws MuleException {
ServletHelper.registerUserLevelCode(MuleHelper.LIBRARY_NAME);
return Weaver.callOriginal();
}
}
Loading