Skip to content

Commit

Permalink
NR-303615: Fix for API Endpoint reported giving 404 response code
Browse files Browse the repository at this point in the history
  • Loading branch information
IshikaDawda committed Aug 28, 2024
1 parent 4b64b6a commit 8a5dd01
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper;
import com.newrelic.api.agent.security.instrumentation.helpers.URLMappingsHelper;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.utils.logging.LogLevel;

import jakarta.servlet.ServletContext;
Expand Down Expand Up @@ -37,6 +38,10 @@ private static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if (StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper;
import com.newrelic.api.agent.security.instrumentation.helpers.URLMappingsHelper;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.utils.logging.LogLevel;

import javax.servlet.ServletContext;
Expand Down Expand Up @@ -36,6 +37,10 @@ private static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if (StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.HttpRequest;
import com.newrelic.api.agent.security.schema.SecurityMetaData;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.schema.exceptions.NewRelicSecurityException;
import com.newrelic.api.agent.security.schema.operation.RXSSOperation;
import com.newrelic.api.agent.security.schema.policy.AgentPolicy;
Expand Down Expand Up @@ -222,6 +223,10 @@ private static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if (StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.HttpRequest;
import com.newrelic.api.agent.security.schema.SecurityMetaData;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.schema.exceptions.NewRelicSecurityException;
import com.newrelic.api.agent.security.schema.operation.RXSSOperation;
import com.newrelic.api.agent.security.schema.policy.AgentPolicy;
Expand Down Expand Up @@ -224,6 +225,10 @@ private static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if (StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newrelic.api.agent.security.schema.AgentMetaData;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.HttpRequest;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.schema.policy.AgentPolicy;
import com.newrelic.api.agent.security.utils.logging.LogLevel;

Expand All @@ -13,7 +14,6 @@
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

public class HttpServletHelper {
Expand Down Expand Up @@ -142,6 +142,10 @@ public static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if ( StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper;
import com.newrelic.api.agent.security.instrumentation.helpers.URLMappingsHelper;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.utils.logging.LogLevel;

import javax.servlet.ServletContext;
Expand Down Expand Up @@ -36,6 +37,10 @@ public static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if ( StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newrelic.api.agent.security.schema.AgentMetaData;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.HttpRequest;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.schema.policy.AgentPolicy;
import com.newrelic.api.agent.security.utils.logging.LogLevel;
import jakarta.servlet.ServletContext;
Expand Down Expand Up @@ -142,6 +143,10 @@ public static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if ( StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newrelic.api.agent.security.schema.AgentMetaData;
import com.newrelic.api.agent.security.schema.ApplicationURLMapping;
import com.newrelic.api.agent.security.schema.HttpRequest;
import com.newrelic.api.agent.security.schema.StringUtils;
import com.newrelic.api.agent.security.schema.policy.AgentPolicy;
import com.newrelic.api.agent.security.utils.logging.LogLevel;
import jakarta.servlet.ServletContext;
Expand Down Expand Up @@ -142,6 +143,10 @@ public static void getJSPMappings(ServletContext servletContext, String dir) {
if(dir.endsWith(SEPARATOR)){
Collection<String> resourcePaths = servletContext.getResourcePaths(dir);
for (String path : resourcePaths) {
String entry = StringUtils.removeStart(StringUtils.removeEnd(path, SEPARATOR), StringUtils.SEPARATOR);
if ( StringUtils.equalsAny(entry, "META-INF", "WEB-INF")) {
continue;
}
if(path.endsWith(SEPARATOR)) {
getJSPMappings(servletContext, path);
}
Expand Down

0 comments on commit 8a5dd01

Please sign in to comment.