Skip to content

Commit cd7be64

Browse files
Copilotgygrobot
andauthored
fix: use safe netty version comparison
Agent-Logs-Url: https://github.com/getyourguide/openapi-validation-java/sessions/ff1748ca-2686-476c-8163-79fb3aaeb02d Co-authored-by: gygrobot <19344429+gygrobot@users.noreply.github.com>
1 parent e9eb411 commit cd7be64

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

build.gradle

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ allprojects {
2222
}
2323
}
2424

25+
def versionParts = { String version ->
26+
version.replace('.Final', '').tokenize('.').collect { it as int }
27+
}
28+
29+
def isVersionLowerThan = { String version, String minimumVersion ->
30+
def currentParts = versionParts(version)
31+
def minimumParts = versionParts(minimumVersion)
32+
def partsCount = Math.max(currentParts.size(), minimumParts.size())
33+
34+
for (int index = 0; index < partsCount; index++) {
35+
def current = index < currentParts.size() ? currentParts[index] : 0
36+
def minimum = index < minimumParts.size() ? minimumParts[index] : 0
37+
if (current != minimum) {
38+
return current < minimum
39+
}
40+
}
41+
42+
false
43+
}
44+
2545
subprojects {
2646
configurations.configureEach {
2747
resolutionStrategy.eachDependency {
@@ -31,7 +51,7 @@ subprojects {
3151
because('GHSA-2m67-wjpj-xhg9: Jackson Core 3.0.0-3.1.0 maxDocumentLength bypass')
3252
}
3353
if (requested.group == 'io.netty' && requested.name == 'netty-codec-compression'
34-
&& requested.version != null && requested.version < '4.2.13.Final') {
54+
&& requested.version != null && isVersionLowerThan(requested.version, '4.2.13.Final')) {
3555
useVersion('4.2.13.Final')
3656
because('GHSA-mj4r-2hfc-f8p6: Netty Codec Compression before 4.2.13.Final is vulnerable to resource exhaustion')
3757
}

0 commit comments

Comments
 (0)