Skip to content

Commit 31db6f1

Browse files
fix: use resolutionStrategy to enforce minimum versions for vulnerabilities (#376)
Replaces dependency constraints with resolutionStrategy.eachDependency to correctly rewrite transitive dependency versions in the submitted dependency graph, fixing stale versions showing in GitHub Insights. Also adds netty-codec-http2 and netty-codec-http3 to the netty upgrade rule. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7f906a3 commit 31db6f1

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

build.gradle

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ allprojects {
2323
}
2424

2525
subprojects {
26+
configurations.configureEach {
27+
resolutionStrategy.eachDependency {
28+
if (requested.group == 'tools.jackson.core' && requested.name == 'jackson-core'
29+
&& requested.version != null && requested.version < '3.1.1') {
30+
useVersion('3.1.1')
31+
because('GHSA-2m67-wjpj-xhg9: Jackson Core 3.0.0-3.1.0 maxDocumentLength bypass')
32+
}
33+
if (requested.group == 'org.apache.tomcat.embed' && requested.name == 'tomcat-embed-core'
34+
&& requested.version != null && requested.version < '11.0.22') {
35+
useVersion('11.0.22')
36+
because('GHSA-rv64-5gf8-9qq8 / GHSA-x4m4-345f-5h5g / GHSA-24j9-x2wg-9qv6 / GHSA-gx5v-xp9w-j4cg: Apache Tomcat < 11.0.22 vulnerabilities')
37+
}
38+
if (requested.group == 'io.netty' && requested.name in ['netty-codec-http', 'netty-codec-http2', 'netty-codec-http3']
39+
&& requested.version != null && requested.version < '4.2.13.Final') {
40+
useVersion('4.2.13.Final')
41+
because('GHSA-38f8-5428-x5cv: HTTP Request Smuggling in io.netty:netty-codec-http via malformed Transfer-Encoding headers')
42+
}
43+
}
44+
}
45+
2646
if(it.parent.name == 'examples') {
2747
apply plugin: 'java'
2848
} else {
@@ -59,28 +79,6 @@ subprojects {
5979
apply plugin: 'pmd'
6080

6181
dependencies {
62-
constraints {
63-
add('implementation', 'tools.jackson.core:jackson-core') {
64-
version {
65-
require '[3.1.1,)'
66-
}
67-
because('GHSA-2m67-wjpj-xhg9: Jackson Core 3.0.0-3.1.0 maxDocumentLength bypass')
68-
}
69-
add('implementation', 'org.apache.tomcat.embed:tomcat-embed-core') {
70-
version {
71-
require '[11.0.22,)'
72-
}
73-
because('GHSA-rv64-5gf8-9qq8 / GHSA-x4m4-345f-5h5g / GHSA-24j9-x2wg-9qv6 / GHSA-gx5v-xp9w-j4cg: Apache Tomcat < 11.0.22 vulnerabilities')
74-
}
75-
add('implementation', 'io.netty:netty-codec-http') {
76-
version {
77-
require '[4.2.13.Final,)'
78-
prefer '4.2.14.Final'
79-
}
80-
because('GHSA-38f8-5428-x5cv: HTTP Request Smuggling in io.netty:netty-codec-http via malformed Transfer-Encoding headers')
81-
}
82-
}
83-
8482
// Lombok annotations to reduce boilerplate code
8583
compileOnly(libs.lombok)
8684
annotationProcessor(libs.lombok)

0 commit comments

Comments
 (0)