Skip to content

Commit 68e07c2

Browse files
Merge branch 'master' into alexeyk/protocol-v1-1
2 parents 882350a + 99d47ca commit 68e07c2

60 files changed

Lines changed: 1307 additions & 223 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/analyze-changes.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
${{ runner.os }}-gradle-
3131
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
33+
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
3434
with:
3535
languages: 'java'
3636
build-mode: 'manual'
@@ -43,7 +43,7 @@ jobs:
4343
./gradlew clean :dd-java-agent:shadowJar --build-cache --parallel --stacktrace --no-daemon --max-workers=4
4444
4545
- name: Perform CodeQL Analysis and upload results to GitHub Security tab
46-
uses: github/codeql-action/analyze@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
46+
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
4747

4848
trivy:
4949
name: Analyze changes with Trivy
@@ -89,7 +89,7 @@ jobs:
8989
ls -laR "./workspace/.trivy"
9090
9191
- name: Run Trivy security scanner
92-
uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # v0.34.2
92+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
9393
with:
9494
scan-type: rootfs
9595
scan-ref: './workspace/.trivy/'
@@ -102,7 +102,7 @@ jobs:
102102
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
103103

104104
- name: Upload Trivy scan results to GitHub Security tab
105-
uses: github/codeql-action/upload-sarif@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
105+
uses: github/codeql-action/upload-sarif@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
106106
if: always()
107107
with:
108108
sarif_file: 'trivy-results.sarif'

buildSrc/src/main/kotlin/datadog/gradle/plugin/muzzle/MuzzleAction.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ import java.net.URLClassLoader
99
abstract class MuzzleAction : WorkAction<MuzzleWorkParameters> {
1010
companion object {
1111
private val lock = Any()
12-
private var bootCL: ClassLoader? = null
13-
private var toolCL: ClassLoader? = null
12+
@Volatile
13+
private var lastBootCL: ClassLoader? = null
14+
@Volatile
15+
private var lastToolCL: ClassLoader? = null
1416
@Volatile
1517
private var lastBuildStamp: Long = 0
18+
@Volatile
19+
private var lastBuildPathCount: Int = 0
1620

1721
fun createClassLoader(cp: FileCollection, parent: ClassLoader = ClassLoader.getSystemClassLoader()): ClassLoader {
1822
val urls = cp.map { it.toURI().toURL() }.toTypedArray()
@@ -22,12 +26,21 @@ abstract class MuzzleAction : WorkAction<MuzzleWorkParameters> {
2226

2327
override fun execute() {
2428
val buildStamp = parameters.buildStartedTime.get()
25-
if (bootCL == null || toolCL == null || lastBuildStamp < buildStamp) {
29+
val buildPathCount = parameters.bootstrapClassPath.count() + parameters.toolingClassPath.count()
30+
var bootCL : ClassLoader? = lastBootCL
31+
var toolCL : ClassLoader? = lastToolCL
32+
// cache boot and tool classloaders for each run; rebuild if either class-path is extended mid-build
33+
if (bootCL == null || toolCL == null || lastBuildStamp < buildStamp || lastBuildPathCount < buildPathCount) {
2634
synchronized(lock) {
27-
if (bootCL == null || toolCL == null || lastBuildStamp < buildStamp) {
35+
bootCL = lastBootCL
36+
toolCL = lastToolCL
37+
if (bootCL == null || toolCL == null || lastBuildStamp < buildStamp || lastBuildPathCount < buildPathCount) {
2838
bootCL = createClassLoader(parameters.bootstrapClassPath)
2939
toolCL = createClassLoader(parameters.toolingClassPath, bootCL!!)
40+
lastBootCL = bootCL
41+
lastToolCL = toolCL
3042
lastBuildStamp = buildStamp
43+
lastBuildPathCount = buildPathCount
3144
}
3245
}
3346
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
5+
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
6+
com.github.javaparser:javaparser-core:3.25.6=codenarc
7+
com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
8+
com.github.spotbugs:spotbugs:4.9.8=spotbugs
9+
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
10+
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
11+
com.google.code.gson:gson:2.13.2=spotbugs
12+
com.google.errorprone:error_prone_annotations:2.41.0=spotbugs
13+
com.thoughtworks.qdox:qdox:1.12.1=codenarc
14+
commons-io:commons-io:2.20.0=spotbugs
15+
de.thetaphi:forbiddenapis:3.10=compileClasspath
16+
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
17+
jaxen:jaxen:2.0.0=spotbugs
18+
net.bytebuddy:byte-buddy-agent:1.12.8=testRuntimeClasspath
19+
net.bytebuddy:byte-buddy:1.12.8=testRuntimeClasspath
20+
net.sf.saxon:Saxon-HE:12.9=spotbugs
21+
org.apache.ant:ant-antlr:1.10.14=codenarc
22+
org.apache.ant:ant-junit:1.10.14=codenarc
23+
org.apache.bcel:bcel:6.11.0=spotbugs
24+
org.apache.commons:commons-lang3:3.19.0=spotbugs
25+
org.apache.commons:commons-text:1.14.0=spotbugs
26+
org.apache.logging.log4j:log4j-api:2.25.2=spotbugs
27+
org.apache.logging.log4j:log4j-core:2.25.2=spotbugs
28+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
29+
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
30+
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
31+
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
32+
org.codehaus.groovy:groovy-json:3.0.23=codenarc
33+
org.codehaus.groovy:groovy-json:3.0.25=testCompileClasspath,testRuntimeClasspath
34+
org.codehaus.groovy:groovy-templates:3.0.23=codenarc
35+
org.codehaus.groovy:groovy-xml:3.0.23=codenarc
36+
org.codehaus.groovy:groovy:3.0.23=codenarc
37+
org.codehaus.groovy:groovy:3.0.25=testCompileClasspath,testRuntimeClasspath
38+
org.codenarc:CodeNarc:3.7.0=codenarc
39+
org.dom4j:dom4j:2.2.0=spotbugs
40+
org.gmetrics:GMetrics:2.1.0=codenarc
41+
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
42+
org.jacoco:org.jacoco.agent:0.8.14=jacocoAgent,jacocoAnt
43+
org.jacoco:org.jacoco.ant:0.8.14=jacocoAnt
44+
org.jacoco:org.jacoco.core:0.8.14=jacocoAnt
45+
org.jacoco:org.jacoco.report:0.8.14=jacocoAnt
46+
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testRuntimeClasspath
47+
org.junit.jupiter:junit-jupiter-engine:5.14.1=testRuntimeClasspath
48+
org.junit.jupiter:junit-jupiter-params:5.14.1=testCompileClasspath,testRuntimeClasspath
49+
org.junit.jupiter:junit-jupiter:5.14.1=testCompileClasspath,testRuntimeClasspath
50+
org.junit.platform:junit-platform-commons:1.14.1=testCompileClasspath,testRuntimeClasspath
51+
org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testRuntimeClasspath
52+
org.junit.platform:junit-platform-launcher:1.14.1=testRuntimeClasspath
53+
org.junit:junit-bom:5.14.0=spotbugs
54+
org.junit:junit-bom:5.14.1=testCompileClasspath,testRuntimeClasspath
55+
org.mock-server:mockserver-junit-jupiter-no-dependencies:5.14.0=testFixturesCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
56+
org.mockito:mockito-core:4.4.0=testRuntimeClasspath
57+
org.objenesis:objenesis:3.3=testCompileClasspath,testRuntimeClasspath
58+
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
59+
org.ow2.asm:asm-analysis:9.9=spotbugs
60+
org.ow2.asm:asm-commons:9.9=jacocoAnt,spotbugs
61+
org.ow2.asm:asm-tree:9.9=jacocoAnt,spotbugs
62+
org.ow2.asm:asm-util:9.9=spotbugs
63+
org.ow2.asm:asm:9.9=jacocoAnt,spotbugs
64+
org.slf4j:jcl-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
65+
org.slf4j:jul-to-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
66+
org.slf4j:log4j-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
67+
org.slf4j:slf4j-api:1.7.32=testCompileClasspath,testRuntimeClasspath
68+
org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
69+
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
70+
org.spockframework:spock-bom:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
71+
org.spockframework:spock-core:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
72+
org.xmlresolver:xmlresolver:5.3.3=spotbugs
73+
empty=annotationProcessor,runtimeClasspath,spotbugsPlugins,testAnnotationProcessor,testFixturesAnnotationProcessor

components/json/gradle.lockfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,7 @@ org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
7575
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
7676
org.spockframework:spock-bom:2.4-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
7777
org.spockframework:spock-core:2.4-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
78+
org.tabletest:tabletest-junit:1.2.1=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
79+
org.tabletest:tabletest-parser:1.2.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
7880
org.xmlresolver:xmlresolver:5.3.3=spotbugs
7981
empty=annotationProcessor,jmhAnnotationProcessor,runtimeClasspath,spotbugsPlugins,testAnnotationProcessor

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTransformer.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ public byte[] transform(
275275
return null;
276276
}
277277
ClassNode classNode = parseClassFile(classFilePath, classfileBuffer);
278-
checkMethodParameters(classNode);
278+
if (!checkMethodParameters(classNode, definitions, fullyQualifiedClassName)) {
279+
return null;
280+
}
279281
if (!checkRecordTypeAnnotation(classNode, definitions, fullyQualifiedClassName)) {
280282
return null;
281283
}
@@ -306,10 +308,11 @@ public byte[] transform(
306308
* instrumented the class, we will retransform for removing the instrumentation and then the
307309
* attribute is stripped. That's why we are preventing it even at load time.
308310
*/
309-
private void checkMethodParameters(ClassNode classNode) {
311+
private boolean checkMethodParameters(
312+
ClassNode classNode, List<ProbeDefinition> definitions, String fullyQualifiedClassName) {
310313
if (JAVA_AT_LEAST_19) {
311314
// bug is fixed since JDK19, no need to perform check
312-
return;
315+
return true;
313316
}
314317
boolean isRecord = ASMHelper.isRecord(classNode);
315318
// capping scanning of methods to 100 to avoid generated class with thousand of methods
@@ -328,13 +331,17 @@ private void checkMethodParameters(ClassNode classNode) {
328331
if (methodNode.parameters != null
329332
&& !methodNode.parameters.isEmpty()
330333
&& SpringHelper.isSpringUsingOnlyMethodParameters(DebuggerAgent.getInstrumentation())) {
331-
throw new RuntimeException(
334+
reportInstrumentationFails(
335+
definitions,
336+
fullyQualifiedClassName,
332337
"Method Parameters attribute detected, instrumentation not supported");
338+
return false;
333339
} else {
334340
// we found at leat a method with one parameter if name is not present we can stop there
335341
break;
336342
}
337343
}
344+
return true;
338345
}
339346

340347
/*

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/DebuggerSink.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,11 @@ public void addDiagnostics(ProbeId probeId, List<DiagnosticMessage> messages) {
220220
for (DiagnosticMessage msg : messages) {
221221
switch (msg.getKind()) {
222222
case INFO:
223-
LOGGER.info(msg.getMessage());
224-
break;
225223
case WARN:
226-
LOGGER.warn(msg.getMessage());
224+
LOGGER.debug(msg.getMessage());
227225
break;
228226
case ERROR:
229-
LOGGER.error(msg.getMessage());
227+
LOGGER.debug(msg.getMessage());
230228
reportError(probeId, msg);
231229
break;
232230
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/symbol/SymbolExtractor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,24 @@ private static void extractScopesFromVariables(
390390
List<Symbol> varSymbols = new ArrayList<>();
391391
int minLine = Integer.MAX_VALUE;
392392
for (LocalVariableNode var : entry.getValue()) {
393-
int line = monotonicLineMap.get(var.start.getLabel());
393+
Integer line = monotonicLineMap.get(var.start.getLabel());
394+
if (line == null) {
395+
LOGGER.debug(
396+
"Cannot find the line for variable {} idx={} in local variables",
397+
var.name,
398+
var.index);
399+
continue;
400+
}
394401
minLine = Math.min(line, minLine);
395402
varSymbols.add(
396403
new Symbol(
397404
SymbolType.LOCAL, var.name, line, Type.getType(var.desc).getClassName(), null));
398405
}
399-
int endLine = monotonicLineMap.get(entry.getKey().getLabel());
406+
Integer endLine = monotonicLineMap.get(entry.getKey().getLabel());
407+
if (endLine == null) {
408+
LOGGER.debug("Cannot find the line from end label");
409+
continue;
410+
}
400411
Scope varScope =
401412
Scope.builder(ScopeType.LOCAL, sourceFile, minLine, endLine)
402413
.symbols(varSymbols)

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,7 +3059,7 @@ public void methodParametersAttribute() throws Exception {
30593059
verify(probeStatusSink, times(1)).addError(probeIdCaptor.capture(), strCaptor.capture());
30603060
assertEquals(PROBE_ID.getId(), probeIdCaptor.getAllValues().get(0).getId());
30613061
assertEquals(
3062-
"Instrumentation failed for CapturedSnapshot01: java.lang.RuntimeException: Method Parameters attribute detected, instrumentation not supported",
3062+
"Instrumentation failed for CapturedSnapshot01: Method Parameters attribute detected, instrumentation not supported",
30633063
strCaptor.getAllValues().get(0));
30643064
} else {
30653065
Snapshot snapshot = assertOneSnapshot(listener);
@@ -3069,9 +3069,17 @@ public void methodParametersAttribute() throws Exception {
30693069

30703070
@Test
30713071
@EnabledForJreRange(min = JRE.JAVA_17)
3072-
public void methodParametersAttributeRecord() throws IOException, URISyntaxException {
3072+
public void methodParametersAttributeRecord() throws Exception {
30733073
final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot29";
30743074
final String RECORD_NAME = "com.datadog.debugger.MyRecord1";
3075+
Config config = mock(Config.class);
3076+
when(config.isDebuggerCodeOriginEnabled()).thenReturn(false);
3077+
when(config.isDebuggerExceptionEnabled()).thenReturn(false);
3078+
when(config.isDynamicInstrumentationEnabled()).thenReturn(false);
3079+
Instrumentation inst = mock(Instrumentation.class);
3080+
Class<?> springClass = Class.forName("org.springframework.core.SpringVersion");
3081+
when(inst.getAllLoadedClasses()).thenReturn(new Class[] {springClass});
3082+
DebuggerAgent.run(config, inst, null);
30753083
TestSnapshotListener listener = installMethodProbeAtExit(RECORD_NAME, "<init>", null);
30763084
Map<String, byte[]> buffers =
30773085
compile(CLASS_NAME, SourceCompiler.DebugInfo.ALL, "17", Arrays.asList("-parameters"));
@@ -3089,7 +3097,7 @@ public void methodParametersAttributeRecord() throws IOException, URISyntaxExcep
30893097
verify(probeStatusSink, times(1)).addError(probeIdCaptor.capture(), strCaptor.capture());
30903098
assertEquals(PROBE_ID.getId(), probeIdCaptor.getAllValues().get(0).getId());
30913099
assertEquals(
3092-
"Instrumentation failed for com.datadog.debugger.MyRecord1: java.lang.RuntimeException: Method Parameters attribute detected, instrumentation not supported",
3100+
"Instrumentation failed for com.datadog.debugger.MyRecord1: Method Parameters attribute detected, instrumentation not supported",
30933101
strCaptor.getAllValues().get(0));
30943102
}
30953103
}

dd-java-agent/agent-otel/otel-bootstrap/gradle.lockfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
55
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
66
com.datadoghq:dd-instrument-java:0.0.3=compileClasspath
7-
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,runtimeClasspath,testRuntimeClasspath
7+
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath
88
com.github.javaparser:javaparser-core:3.25.6=codenarc
99
com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
1010
com.github.spotbugs:spotbugs:4.9.8=spotbugs
@@ -85,12 +85,11 @@ org.ow2.asm:asm:9.9=jacocoAnt,spotbugs
8585
org.slf4j:jcl-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
8686
org.slf4j:jul-to-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
8787
org.slf4j:log4j-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
88-
org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath
88+
org.slf4j:slf4j-api:1.7.30=compileClasspath
8989
org.slf4j:slf4j-api:1.7.32=testCompileClasspath,testRuntimeClasspath
9090
org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
9191
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
92-
org.snakeyaml:snakeyaml-engine:2.9=runtimeClasspath,testRuntimeClasspath
9392
org.spockframework:spock-bom:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
9493
org.spockframework:spock-core:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
9594
org.xmlresolver:xmlresolver:5.3.3=spotbugs
96-
empty=annotationProcessor,shadow,spotbugsPlugins,testAnnotationProcessor
95+
empty=annotationProcessor,runtimeClasspath,shadow,spotbugsPlugins,testAnnotationProcessor

dd-java-agent/agent-otel/otel-shim/src/main/java/datadog/opentelemetry/shim/OtelInstrumentationScope.java renamed to dd-java-agent/agent-otel/otel-bootstrap/src/main/java/datadog/trace/bootstrap/otel/common/OtelInstrumentationScope.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datadog.opentelemetry.shim;
1+
package datadog.trace.bootstrap.otel.common;
22

33
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
44
import java.util.Objects;

0 commit comments

Comments
 (0)