Skip to content

Commit f96f661

Browse files
Merge remote-tracking branch 'origin/master' into malvarez/api-10-redirect-support
2 parents 4ba4ebf + e5c8728 commit f96f661

File tree

8 files changed

+360
-22
lines changed

8 files changed

+360
-22
lines changed

.github/workflows/analyze-changes.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
submodules: 'recursive'
2222
- name: Cache Gradle dependencies
23-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
23+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
2424
with:
2525
path: |
2626
~/.gradle/caches
@@ -30,7 +30,7 @@ jobs:
3030
${{ runner.os }}-gradle-
3131
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
33+
uses: github/codeql-action/init@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
3434
with:
3535
languages: 'java'
3636
build-mode: 'manual'
@@ -49,7 +49,7 @@ jobs:
4949
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
5050
5151
- name: Perform CodeQL Analysis and upload results to GitHub Security tab
52-
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
52+
uses: github/codeql-action/analyze@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
5353

5454
trivy:
5555
name: Analyze changes with Trivy
@@ -66,7 +66,7 @@ jobs:
6666
submodules: 'recursive'
6767

6868
- name: Cache Gradle dependencies
69-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
69+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
7070
with:
7171
path: |
7272
~/.gradle/caches
@@ -114,7 +114,7 @@ jobs:
114114
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
115115

116116
- name: Upload Trivy scan results to GitHub Security tab
117-
uses: github/codeql-action/upload-sarif@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
117+
uses: github/codeql-action/upload-sarif@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
118118
if: always()
119119
with:
120120
sarif_file: 'trivy-results.sarif'

.github/workflows/run-system-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
fetch-depth: 0
3232

3333
- name: Cache Gradle dependencies
34-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
34+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
3535
with:
3636
path: |
3737
~/.gradle/caches
@@ -54,7 +54,7 @@ jobs:
5454
--build-cache --parallel --stacktrace --no-daemon --max-workers=4
5555
5656
- name: Upload artifact
57-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
57+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
5858
with:
5959
name: binaries
6060
path: workspace/dd-java-agent/build/libs/

dd-trace-core/src/test/groovy/datadog/trace/core/database/SharedDBCommenterTest.groovy renamed to dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/dbm/SharedDBCommenterForkedTest.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
package datadog.trace.core.database
1+
package datadog.trace.bootstrap.instrumentation.dbm
22

3-
import datadog.trace.bootstrap.instrumentation.dbm.SharedDBCommenter
43
import spock.lang.Specification
54

6-
class SharedDBCommenterTest extends Specification {
5+
class SharedDBCommenterForkedTest extends Specification {
76
def setup() {
87
System.setProperty("dd.service.name", "test-service")
98
System.setProperty("dd.env", "test-env")

dd-java-agent/instrumentation/jsp-2.3/src/main/java/datadog/trace/instrumentation/jsp/JSPDecorator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
66
import datadog.trace.bootstrap.instrumentation.decorator.BaseDecorator;
77
import java.net.URI;
8-
import java.net.URISyntaxException;
98
import javax.servlet.RequestDispatcher;
109
import javax.servlet.http.HttpServletRequest;
11-
import javax.servlet.jsp.HttpJspPage;
1210
import org.apache.jasper.JspCompilationContext;
13-
import org.slf4j.LoggerFactory;
1411

1512
public class JSPDecorator extends BaseDecorator {
1613
public static final CharSequence JSP_COMPILE = UTF8BytesString.create("jsp.compile");
@@ -68,11 +65,14 @@ public void onRender(final AgentSpan span, final HttpServletRequest req) {
6865
// HttpServletRequest#getRequestURL(),
6966
// normalizing the URL should remove those symbols for readability and consistency
7067
try {
71-
span.setTag(
72-
"jsp.requestURL", (new URI(req.getRequestURL().toString())).normalize().toString());
73-
} catch (final URISyntaxException uriSE) {
74-
LoggerFactory.getLogger(HttpJspPage.class)
75-
.debug("Failed to get and normalize request URL: {}", uriSE.getMessage());
68+
// note: getRequestURL is supposed to always be nonnull - however servlet wrapping can happen
69+
// and we never know if ever this can happen
70+
final StringBuffer requestURL = req.getRequestURL();
71+
if (requestURL != null && requestURL.length() > 0) {
72+
span.setTag("jsp.requestURL", (new URI(requestURL.toString())).normalize().toString());
73+
}
74+
} catch (final Throwable ignored) {
75+
// logging here will be too verbose
7676
}
7777
}
7878
}

dd-java-agent/instrumentation/spring/spring-messaging-4.0/src/main/java/datadog/trace/instrumentation/springmessaging/SpringMessageExtractAdapter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Map;
1111
import java.util.function.Function;
1212
import org.springframework.messaging.Message;
13+
import org.springframework.messaging.MessageHeaders;
1314

1415
public final class SpringMessageExtractAdapter
1516
implements AgentPropagation.ContextVisitor<Message<?>> {
@@ -33,7 +34,12 @@ public String apply(String key) {
3334

3435
@Override
3536
public void forEachKey(Message<?> carrier, AgentPropagation.KeyClassifier classifier) {
36-
for (Map.Entry<String, ?> header : carrier.getHeaders().entrySet()) {
37+
final MessageHeaders messageHeaders = carrier.getHeaders();
38+
if (messageHeaders == null || messageHeaders.isEmpty()) {
39+
return;
40+
}
41+
42+
for (Map.Entry<String, ?> header : messageHeaders.entrySet()) {
3743
Object headerValue = header.getValue();
3844
if ("_datadog".equals(header.getKey())) {
3945
if (headerValue instanceof String) {

dd-java-agent/instrumentation/tomcat/tomcat-9.0/src/main/java/datadog/trace/instrumentation/tomcat9/WebappClassLoaderInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void onContextAvailable(
4141
@Advice.This final WebappClassLoaderBase classLoader,
4242
@Advice.Argument(0) final WebResourceRoot webResourceRoot) {
4343
// at this moment we have the context set in this classloader, hence its name
44-
final Context context = webResourceRoot.getContext();
44+
final Context context = webResourceRoot != null ? webResourceRoot.getContext() : null;
4545
if (context == null) {
4646
return;
4747
}

remote-config/remote-config-core/src/main/java/datadog/remoteconfig/state/ProductState.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public boolean apply(
5858
errors = null;
5959

6060
List<ParsedConfigKey> configBeenUsedByProduct = new ArrayList<>();
61+
List<ParsedConfigKey> changedKeys = new ArrayList<>();
6162
boolean changesDetected = false;
6263

64+
// Step 1: Detect all changes
6365
for (ParsedConfigKey configKey : relevantKeys) {
6466
try {
6567
RemoteConfigResponse.Targets.ConfigTarget target =
@@ -68,14 +70,28 @@ public boolean apply(
6870

6971
if (isTargetChanged(configKey, target)) {
7072
changesDetected = true;
71-
byte[] content = getTargetFileContent(fleetResponse, configKey);
72-
callListenerApplyTarget(fleetResponse, hinter, configKey, content);
73+
changedKeys.add(configKey);
7374
}
7475
} catch (ReportableException e) {
7576
recordError(e);
7677
}
7778
}
7879

80+
// Step 2: For products other than ASM_DD, apply changes immediately
81+
if (product != Product.ASM_DD) {
82+
for (ParsedConfigKey configKey : changedKeys) {
83+
try {
84+
byte[] content = getTargetFileContent(fleetResponse, configKey);
85+
callListenerApplyTarget(fleetResponse, hinter, configKey, content);
86+
} catch (ReportableException e) {
87+
recordError(e);
88+
}
89+
}
90+
}
91+
92+
// Step 3: Remove obsolete configurations (for all products)
93+
// For ASM_DD, this is critical: removes MUST happen before applies to prevent
94+
// duplicate rule warnings from the ddwaf rule parser and causing memory spikes.
7995
List<ParsedConfigKey> keysToRemove =
8096
cachedTargetFiles.keySet().stream()
8197
.filter(configKey -> !configBeenUsedByProduct.contains(configKey))
@@ -86,6 +102,22 @@ public boolean apply(
86102
callListenerRemoveTarget(hinter, configKey);
87103
}
88104

105+
// Step 4: For ASM_DD, apply changes AFTER removes
106+
// TODO: This is a temporary solution. The proper fix requires better synchronization
107+
// between remove and add/update operations. This should be discussed
108+
// with the guild to determine the best long-term design approach.
109+
if (product == Product.ASM_DD) {
110+
for (ParsedConfigKey configKey : changedKeys) {
111+
try {
112+
byte[] content = getTargetFileContent(fleetResponse, configKey);
113+
callListenerApplyTarget(fleetResponse, hinter, configKey, content);
114+
} catch (ReportableException e) {
115+
recordError(e);
116+
}
117+
}
118+
}
119+
120+
// Step 5: Commit if there were changes
89121
if (changesDetected) {
90122
try {
91123
callListenerCommit(hinter);

0 commit comments

Comments
 (0)