Skip to content

Commit 20f10cd

Browse files
committed
Reintroduce some checksums
1 parent 1f34b28 commit 20f10cd

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

nmcp-tasks/src/main/kotlin/nmcp/transport/publishFileByFile.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ private fun publishGav(
155155

156156
val bytes = encodeToXml(versionMetadata).toByteArray()
157157
transport.put(versionMetadataPath, bytes)
158+
setOf("md5", "sha1", "sha512").forEach {
159+
transport.put("$versionMetadataPath.$it", bytes.digest(it.uppercase()))
160+
}
158161
} else {
159162
/**
160163
* Not a snapshot, plainly update all the files

nmcp/src/main/kotlin/nmcp/internal/utils.kt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,27 @@ internal fun Project.registerPublishToCentralPortalTasks(
9393
// See https://slack-chats.kotlinlang.org/t/16407246/anyone-tried-the-https-central-sonatype-org-publish-publish-#c8738fe5-8051-4f64-809f-ca67a645216e
9494
it.exclude()
9595
}
96-
!publishAllChecksums && (it.name.endsWith(".sha256") || it.name.endsWith(".sha512")) -> {
97-
// It's not clear if those are used, and it reduces the number of files in the deployment
96+
!publishAllChecksums && (it.name.endsWith(".sha256")) -> {
97+
/**
98+
* Stripping `.sha256` checksums leaves out:
99+
* - md5 and sha1 checksums:
100+
* - required by Maven Central checks
101+
* - used by Maven for "transport" verification
102+
* - sha512:
103+
* - secure way for Gradle to to "security verification"
104+
*
105+
* see also https://maven.apache.org/resolver/about-checksums.html:
106+
*
107+
* ```
108+
* Hence, the usual argument that "XXX algorithm is unsafe, deprecated, not secure anymore" does not stand in use case of Maven Resolver: there is nothing secure being involved with checksums. Moreover, this is true not only for SHA-1 algorithm, but even for its "elder brother" MD5. Both algorithms are still widely used today as "transport integrity validation" or "error detection" (aka "bit-rot detection").
109+
* ```
110+
*/
98111
it.exclude()
99112
}
100-
!publishAllChecksums && (it.name.endsWith(".asc.md5") || it.name.endsWith(".asc.sha1")) -> {
101-
// It's not clear if those are used, and it reduces the number of files in the deployment
113+
!publishAllChecksums && (it.name.endsWith(".asc.md5") || it.name.endsWith(".asc.sha1") || it.name.endsWith(".asc.sha256") || it.name.endsWith(".asc.sha512")) -> {
114+
/**
115+
* For signatures, we don't need checksums
116+
*/
102117
it.exclude()
103118
}
104119
}

0 commit comments

Comments
 (0)