From 98f018f333e59a862bb1f48963c1efabfe09c7fc Mon Sep 17 00:00:00 2001 From: lovesh-ap Date: Thu, 19 Sep 2024 14:19:23 +0530 Subject: [PATCH] Add uri in all http request objects --- gradle.properties | 2 +- .../api/agent/security/schema/HttpRequest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9971d5819..14ae4b751 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # The agent version. agentVersion=1.4.1 -jsonVersion=1.2.5 +jsonVersion=1.2.9 # Updated exposed NR APM API version. nrAPIVersion=8.12.0 diff --git a/newrelic-security-api/src/main/java/com/newrelic/api/agent/security/schema/HttpRequest.java b/newrelic-security-api/src/main/java/com/newrelic/api/agent/security/schema/HttpRequest.java index 4d6c8069a..02bbf3378 100644 --- a/newrelic-security-api/src/main/java/com/newrelic/api/agent/security/schema/HttpRequest.java +++ b/newrelic-security-api/src/main/java/com/newrelic/api/agent/security/schema/HttpRequest.java @@ -10,6 +10,8 @@ public class HttpRequest { @JsonIgnore public static final int MAX_ALLOWED_REQUEST_BODY_LENGTH = 500000; + @JsonIgnore + public static final String QUESTION_MARK = "?"; private StringBuilder body; @@ -38,6 +40,7 @@ public class HttpRequest { private boolean isRequestParsed; private boolean isGrpc; private String route; + private String requestURI; public HttpRequest() { this.clientIP = StringUtils.EMPTY; @@ -54,6 +57,7 @@ public HttpRequest() { this.isRequestParsed = false; this.isGrpc = false; this.route = StringUtils.EMPTY; + this.requestURI = StringUtils.EMPTY; } public HttpRequest(HttpRequest servletInfo) { @@ -71,6 +75,7 @@ public HttpRequest(HttpRequest servletInfo) { this.isRequestParsed = servletInfo.isRequestParsed; this.isGrpc = servletInfo.isGrpc; this.route = servletInfo.route; + this.requestURI = servletInfo.requestURI; } public String getMethod() { @@ -87,6 +92,7 @@ public String getUrl() { public void setUrl(String url) { this.url = url; + this.requestURI = StringUtils.substringBefore(url, QUESTION_MARK); } public Map getHeaders() { @@ -223,6 +229,14 @@ public void setRoute(String route){ this.route = StringUtils.removeEnd(StringUtils.prependIfMissing(route, StringUtils.SEPARATOR), StringUtils.SEPARATOR); } + public String getRequestURI() { + return requestURI; + } + + public void setRequestURI(String requestURI) { + this.requestURI = requestURI; + } + public void setRoute(String segment, boolean isAlreadyServlet) { // remove servlet detected route if another framework detected; if (isAlreadyServlet) {