Skip to content

Commit 52c5cb8

Browse files
committed
Split jetty-appsec-9.3 [9.3,12) into three clean modules: 9.3, 9.4, 11.0
Eliminates all reflection from the multipart filename instrumentation by creating version-specific modules with compile-time type safety: - jetty-appsec-9.3 [9.3,9.4): javax.servlet, uses _multiPartInputStream field - jetty-appsec-9.4 [9.4,11.0): javax.servlet, uses _multiParts field - jetty-appsec-11.0 [11.0,12.0): jakarta.servlet, uses _multiParts field Each module uses muzzle references as version discriminators instead of runtime reflection, and delegates filename extraction to a testable MultipartHelper class with 8 Spock unit tests each. Server test modules updated to reference the correct appsec module per Jetty version range.
1 parent 398ea51 commit 52c5cb8

File tree

20 files changed

+1100
-76
lines changed

20 files changed

+1100
-76
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
muzzle {
2+
pass {
3+
group = 'org.eclipse.jetty'
4+
module = 'jetty-server'
5+
versions = '[11.0,12.0)'
6+
assertInverse = true
7+
javaVersion = 11
8+
}
9+
}
10+
11+
apply from: "$rootDir/gradle/java.gradle"
12+
13+
dependencies {
14+
compileOnly(group: 'org.eclipse.jetty', name: 'jetty-server', version: '11.0.0') {
15+
exclude group: 'org.slf4j', module: 'slf4j-api'
16+
}
17+
testImplementation(group: 'org.eclipse.jetty.toolchain', name: 'jetty-jakarta-servlet-api', version: '5.0.1')
18+
}
19+
20+
tasks.withType(JavaCompile).configureEach {
21+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
22+
}
23+
24+
// testing happens in the jetty-* modules
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
cafe.cryptography:curve25519-elisabeth:0.1.0=testRuntimeClasspath
5+
cafe.cryptography:ed25519-elisabeth:0.1.0=testRuntimeClasspath
6+
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
7+
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
8+
com.blogspot.mydailyjava:weak-lock-free:0.17=buildTimeInstrumentationPlugin,compileClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9+
com.datadoghq.okhttp3:okhttp:3.12.15=testCompileClasspath,testRuntimeClasspath
10+
com.datadoghq.okio:okio:1.17.6=testCompileClasspath,testRuntimeClasspath
11+
com.datadoghq:dd-instrument-java:0.0.3=buildTimeInstrumentationPlugin,compileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
12+
com.datadoghq:dd-javac-plugin-client:0.2.2=buildTimeInstrumentationPlugin,compileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
13+
com.datadoghq:java-dogstatsd-client:4.4.3=testRuntimeClasspath
14+
com.datadoghq:sketches-java:0.8.3=testRuntimeClasspath
15+
com.github.javaparser:javaparser-core:3.25.6=codenarc
16+
com.github.jnr:jffi:1.3.14=testRuntimeClasspath
17+
com.github.jnr:jnr-a64asm:1.0.0=testRuntimeClasspath
18+
com.github.jnr:jnr-constants:0.10.4=testRuntimeClasspath
19+
com.github.jnr:jnr-enxio:0.32.19=testRuntimeClasspath
20+
com.github.jnr:jnr-ffi:2.2.18=testRuntimeClasspath
21+
com.github.jnr:jnr-posix:3.1.21=testRuntimeClasspath
22+
com.github.jnr:jnr-unixsocket:0.38.24=testRuntimeClasspath
23+
com.github.jnr:jnr-x86asm:1.0.2=testRuntimeClasspath
24+
com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
25+
com.github.spotbugs:spotbugs:4.9.8=spotbugs
26+
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
27+
com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compileClasspath,testAnnotationProcessor,testCompileClasspath
28+
com.google.auto.service:auto-service:1.1.1=annotationProcessor,testAnnotationProcessor
29+
com.google.auto:auto-common:1.2.1=annotationProcessor,testAnnotationProcessor
30+
com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
31+
com.google.code.gson:gson:2.13.2=spotbugs
32+
com.google.errorprone:error_prone_annotations:2.18.0=annotationProcessor,testAnnotationProcessor
33+
com.google.errorprone:error_prone_annotations:2.41.0=spotbugs
34+
com.google.guava:failureaccess:1.0.1=annotationProcessor,testAnnotationProcessor
35+
com.google.guava:guava:20.0=testCompileClasspath,testRuntimeClasspath
36+
com.google.guava:guava:32.0.1-jre=annotationProcessor,testAnnotationProcessor
37+
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,testAnnotationProcessor
38+
com.google.j2objc:j2objc-annotations:2.8=annotationProcessor,testAnnotationProcessor
39+
com.google.re2j:re2j:1.7=testRuntimeClasspath
40+
com.squareup.moshi:moshi:1.11.0=testCompileClasspath,testRuntimeClasspath
41+
com.squareup.okhttp3:logging-interceptor:3.12.12=testCompileClasspath,testRuntimeClasspath
42+
com.squareup.okhttp3:okhttp:3.12.12=testCompileClasspath,testRuntimeClasspath
43+
com.squareup.okio:okio:1.17.5=testCompileClasspath,testRuntimeClasspath
44+
com.thoughtworks.qdox:qdox:1.12.1=codenarc
45+
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testRuntimeClasspath
46+
commons-io:commons-io:2.11.0=testCompileClasspath,testRuntimeClasspath
47+
commons-io:commons-io:2.20.0=spotbugs
48+
de.thetaphi:forbiddenapis:3.10=compileClasspath
49+
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
50+
io.sqreen:libsqreen:17.3.0=testRuntimeClasspath
51+
javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath
52+
jaxen:jaxen:2.0.0=spotbugs
53+
junit:junit:4.13.2=testRuntimeClasspath
54+
net.bytebuddy:byte-buddy-agent:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
55+
net.bytebuddy:byte-buddy:1.18.3=buildTimeInstrumentationPlugin,compileClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
56+
net.java.dev.jna:jna-platform:5.8.0=testRuntimeClasspath
57+
net.java.dev.jna:jna:5.8.0=testRuntimeClasspath
58+
net.sf.saxon:Saxon-HE:12.9=spotbugs
59+
org.apache.ant:ant-antlr:1.10.14=codenarc
60+
org.apache.ant:ant-junit:1.10.14=codenarc
61+
org.apache.bcel:bcel:6.11.0=spotbugs
62+
org.apache.commons:commons-lang3:3.19.0=spotbugs
63+
org.apache.commons:commons-text:1.14.0=spotbugs
64+
org.apache.logging.log4j:log4j-api:2.25.2=spotbugs
65+
org.apache.logging.log4j:log4j-core:2.25.2=spotbugs
66+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
67+
org.checkerframework:checker-qual:3.33.0=annotationProcessor,testAnnotationProcessor
68+
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
69+
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
70+
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
71+
org.codehaus.groovy:groovy-json:3.0.23=codenarc
72+
org.codehaus.groovy:groovy-json:3.0.25=testCompileClasspath,testRuntimeClasspath
73+
org.codehaus.groovy:groovy-templates:3.0.23=codenarc
74+
org.codehaus.groovy:groovy-xml:3.0.23=codenarc
75+
org.codehaus.groovy:groovy:3.0.23=codenarc
76+
org.codehaus.groovy:groovy:3.0.25=testCompileClasspath,testRuntimeClasspath
77+
org.codenarc:CodeNarc:3.7.0=codenarc
78+
org.dom4j:dom4j:2.2.0=spotbugs
79+
org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.1=compileClasspath,testCompileClasspath,testRuntimeClasspath
80+
org.eclipse.jetty:jetty-http:11.0.0=compileClasspath
81+
org.eclipse.jetty:jetty-io:11.0.0=compileClasspath
82+
org.eclipse.jetty:jetty-server:11.0.0=compileClasspath
83+
org.eclipse.jetty:jetty-util:11.0.0=compileClasspath
84+
org.gmetrics:GMetrics:2.1.0=codenarc
85+
org.hamcrest:hamcrest-core:1.3=testRuntimeClasspath
86+
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
87+
org.jctools:jctools-core-jdk11:4.0.6=testRuntimeClasspath
88+
org.jctools:jctools-core:4.0.6=testRuntimeClasspath
89+
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testRuntimeClasspath
90+
org.junit.jupiter:junit-jupiter-engine:5.14.1=testRuntimeClasspath
91+
org.junit.jupiter:junit-jupiter-params:5.14.1=testCompileClasspath,testRuntimeClasspath
92+
org.junit.jupiter:junit-jupiter:5.14.1=testCompileClasspath,testRuntimeClasspath
93+
org.junit.platform:junit-platform-commons:1.14.1=testCompileClasspath,testRuntimeClasspath
94+
org.junit.platform:junit-platform-engine:1.14.1=testCompileClasspath,testRuntimeClasspath
95+
org.junit.platform:junit-platform-launcher:1.14.1=testRuntimeClasspath
96+
org.junit.platform:junit-platform-runner:1.14.1=testRuntimeClasspath
97+
org.junit.platform:junit-platform-suite-api:1.14.1=testRuntimeClasspath
98+
org.junit.platform:junit-platform-suite-commons:1.14.1=testRuntimeClasspath
99+
org.junit:junit-bom:5.14.0=spotbugs
100+
org.junit:junit-bom:5.14.1=testCompileClasspath,testRuntimeClasspath
101+
org.mockito:mockito-core:4.4.0=testRuntimeClasspath
102+
org.objenesis:objenesis:3.3=testCompileClasspath,testRuntimeClasspath
103+
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
104+
org.ow2.asm:asm-analysis:9.7.1=testRuntimeClasspath
105+
org.ow2.asm:asm-analysis:9.9=spotbugs
106+
org.ow2.asm:asm-commons:9.9=spotbugs
107+
org.ow2.asm:asm-commons:9.9.1=testRuntimeClasspath
108+
org.ow2.asm:asm-tree:9.9=spotbugs
109+
org.ow2.asm:asm-tree:9.9.1=testRuntimeClasspath
110+
org.ow2.asm:asm-util:9.7.1=testRuntimeClasspath
111+
org.ow2.asm:asm-util:9.9=spotbugs
112+
org.ow2.asm:asm:9.9=spotbugs
113+
org.ow2.asm:asm:9.9.1=buildTimeInstrumentationPlugin,compileClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
114+
org.slf4j:jcl-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
115+
org.slf4j:jul-to-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
116+
org.slf4j:log4j-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
117+
org.slf4j:slf4j-api:1.7.30=buildTimeInstrumentationPlugin,compileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath
118+
org.slf4j:slf4j-api:1.7.32=testCompileClasspath,testRuntimeClasspath
119+
org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
120+
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
121+
org.snakeyaml:snakeyaml-engine:2.9=buildTimeInstrumentationPlugin,muzzleTooling,runtimeClasspath,testRuntimeClasspath
122+
org.spockframework:spock-bom:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
123+
org.spockframework:spock-core:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
124+
org.tabletest:tabletest-junit:1.2.1=testCompileClasspath,testRuntimeClasspath
125+
org.tabletest:tabletest-parser:1.2.0=testCompileClasspath,testRuntimeClasspath
126+
org.xmlresolver:xmlresolver:5.3.3=spotbugs
127+
empty=spotbugsPlugins
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package datadog.trace.instrumentation.jetty11;
2+
3+
import jakarta.servlet.http.Part;
4+
import java.util.ArrayList;
5+
import java.util.Collection;
6+
import java.util.Collections;
7+
import java.util.List;
8+
9+
public class MultipartHelper {
10+
11+
private MultipartHelper() {}
12+
13+
/**
14+
* Extracts non-null, non-empty filenames from a collection of multipart {@link Part}s using
15+
* {@link Part#getSubmittedFileName()} (Servlet 5.0+, Jetty 11.x).
16+
*
17+
* @return list of filenames; never {@code null}, may be empty
18+
*/
19+
public static List<String> extractFilenames(Collection<Part> parts) {
20+
if (parts == null || parts.isEmpty()) {
21+
return Collections.emptyList();
22+
}
23+
List<String> filenames = new ArrayList<>();
24+
for (Part part : parts) {
25+
String name = part.getSubmittedFileName();
26+
if (name != null && !name.isEmpty()) {
27+
filenames.add(name);
28+
}
29+
}
30+
return filenames;
31+
}
32+
}

0 commit comments

Comments
 (0)