From 97f995af1cbd0e9ff411b0ae309e02c019c10a6d Mon Sep 17 00:00:00 2001 From: lovesh-ap Date: Mon, 9 Oct 2023 11:40:52 +0530 Subject: [PATCH] Add parent-id header to outgoing http requests --- .../instrumentation/httpclient50/SecurityHelper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/instrumentation-security/httpclient-5.0/src/main/java/com/newrelic/agent/security/instrumentation/httpclient50/SecurityHelper.java b/instrumentation-security/httpclient-5.0/src/main/java/com/newrelic/agent/security/instrumentation/httpclient50/SecurityHelper.java index f5d516536..1dff2d2ad 100644 --- a/instrumentation-security/httpclient-5.0/src/main/java/com/newrelic/agent/security/instrumentation/httpclient50/SecurityHelper.java +++ b/instrumentation-security/httpclient-5.0/src/main/java/com/newrelic/agent/security/instrumentation/httpclient50/SecurityHelper.java @@ -65,6 +65,11 @@ public static AbstractOperation preprocessSecurityHook(HttpRequest request, Stri request.setHeader(ServletHelper.CSEC_IAST_FUZZ_REQUEST_ID, iastHeader); } + String csecParentId = getParentId(); + if(csecParentId!= null && !csecParentId.isEmpty()){ + request.setHeader(GenericHelper.CSEC_PARENT_ID, csecParentId); + } + SSRFOperation operation = new SSRFOperation(uri, className, methodName); try { NewRelicSecurity.getAgent().registerOperation(operation); @@ -84,4 +89,8 @@ public static AbstractOperation preprocessSecurityHook(HttpRequest request, Stri } return null; } + + public static String getParentId(){ + return NewRelicSecurity.getAgent().getSecurityMetaData().getCustomAttribute(GenericHelper.CSEC_PARENT_ID, String.class); + } }