-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from newrelic/release/v1.3.0
Release CSEC Java Agent Version 1.3.0
- Loading branch information
Showing
269 changed files
with
6,676 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...security/apache/struts2/StrutsHelper.java → ...entation/apache/struts2/StrutsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
dependencies { | ||
implementation(project(":newrelic-security-api")) | ||
implementation("com.newrelic.agent.java:newrelic-weaver-api:${nrAPIVersion}") | ||
implementation("com.newrelic.agent.java:newrelic-api:${nrAPIVersion}") | ||
implementation("org.apache.tomcat.embed:tomcat-embed-core:10.0.0") | ||
implementation("org.apache.tomcat:tomcat-juli:10.0.0") | ||
} | ||
|
||
jar { | ||
manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.security.apache-tomcat-10' } | ||
} | ||
|
||
verifyInstrumentation { | ||
passesOnly('org.apache.tomcat.embed:tomcat-embed-core:[10.0.0-M1,)') | ||
fails('org.apache.tomcat.embed:tomcat-embed-core:[7.0.0,10.0.0-M1)') | ||
excludeRegex '.*-(b|gfa|beta|RC)[0-9]*' | ||
} | ||
|
||
site { | ||
title 'Tomcat' | ||
type 'Appserver' | ||
} |
53 changes: 53 additions & 0 deletions
53
...n/java/com/newrelic/agent/security/instrumentation/apache/tomcat10/HttpServletHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.newrelic.agent.security.instrumentation.apache.tomcat10; | ||
|
||
import com.newrelic.api.agent.security.NewRelicSecurity; | ||
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.utils.logging.LogLevel; | ||
|
||
import jakarta.servlet.ServletContext; | ||
import jakarta.servlet.ServletRegistration; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
public class HttpServletHelper { | ||
private static final String EMPTY = ""; | ||
private static final String WILDCARD = "*"; | ||
private static final String SEPARATOR = "/"; | ||
public static final String APACHE_TOMCAT_10 = "APACHE-TOMCAT-10"; | ||
|
||
public static void gatherURLMappings(ServletContext servletContext) { | ||
try { | ||
Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations(); | ||
getJSPMappings(servletContext, SEPARATOR); | ||
|
||
for (ServletRegistration servletRegistration : servletRegistrations.values()) { | ||
for (String mapping : servletRegistration.getMappings()) { | ||
String path = (mapping.startsWith(SEPARATOR) ? EMPTY : SEPARATOR) + mapping; | ||
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(WILDCARD, path, servletRegistration.getClassName())); | ||
} | ||
} | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, APACHE_TOMCAT_10, e.getMessage()), e, HttpServletHelper.class.getName()); | ||
} | ||
} | ||
|
||
private static void getJSPMappings(ServletContext servletContext, String dir) { | ||
try { | ||
if(dir.endsWith(SEPARATOR)){ | ||
Collection<String> resourcePaths = servletContext.getResourcePaths(dir); | ||
for (String path : resourcePaths) { | ||
if(path.endsWith(SEPARATOR)) { | ||
getJSPMappings(servletContext, path); | ||
} | ||
else if(path.endsWith(".jsp") || path.endsWith(".jspx") || path.endsWith(".JSP") || path.endsWith(".JSPX")) { | ||
URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(WILDCARD, (path.startsWith(SEPARATOR) ? EMPTY : SEPARATOR) + path)); | ||
} | ||
} | ||
} | ||
} catch (Exception e){ | ||
NewRelicSecurity.getAgent().log(LogLevel.WARNING, String.format(GenericHelper.ERROR_WHILE_GETTING_APP_ENDPOINTS, APACHE_TOMCAT_10, e.getMessage()), e, HttpServletHelper.class.getName()); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...relic/agent/security/instrumentation/apache/tomcat10/StandardContext_Instrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.newrelic.agent.security.instrumentation.apache.tomcat10; | ||
|
||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
import org.apache.catalina.LifecycleException; | ||
|
||
import jakarta.servlet.ServletContext; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "org.apache.catalina.core.StandardContext") | ||
public abstract class StandardContext_Instrumentation { | ||
|
||
public abstract ServletContext getServletContext(); | ||
|
||
protected synchronized void startInternal() throws LifecycleException { | ||
try { | ||
Weaver.callOriginal(); | ||
} finally { | ||
HttpServletHelper.gatherURLMappings(getServletContext()); | ||
} | ||
} | ||
} |
Oops, something went wrong.