Skip to content

Commit

Permalink
Disable md5 publishing
Browse files Browse the repository at this point in the history
Currently all registered checksums are computed and published, but in
some cases it might be usefully to be able to verify a checksum but we
don't want to publish it.

This also includes disabling the md5 checksum, we publish sha-256 > 4
years and warn about md5 > 1 year now so it seems valid to stop
publishing it now at all.
  • Loading branch information
laeubi committed Nov 2, 2022
1 parent c0c3a2f commit aca6f29
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
algorithm="MD5"
id="md5"
priority="-2000"
publish="false"
warnInsecure="true">
</artifactChecksum>
</extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ Set to true if this algorithm is now considered as insecure. A warning will be l
</documentation>
</annotation>
</attribute>
<attribute name="publish" type="boolean" use="default" value="true">
<annotation>
<documentation>
Controls if this checksum should be published when assembling a repository.
</documentation>
</annotation>
</attribute>
</complexType>
</element>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static IStatus calculateChecksums(File pathOnDisk, Map<String, String> ch
for (IConfigurationElement checksumVerifierConfiguration : ChecksumUtilities
.getChecksumComparatorConfigurations()) {
String id = checksumVerifierConfiguration.getAttribute("id"); //$NON-NLS-1$
if (checksumsToSkip.contains(id))
if (checksumsToSkip.contains(id) || !shouldPublish(checksumVerifierConfiguration))
// don't calculate checksum if algo is disabled
continue;
String algorithm = checksumVerifierConfiguration.getAttribute("algorithm"); //$NON-NLS-1$
Expand Down Expand Up @@ -161,6 +161,14 @@ public static IStatus calculateChecksums(File pathOnDisk, Map<String, String> ch
return status;
}

private static boolean shouldPublish(IConfigurationElement checksumVerifierConfiguration) {
String attribute = checksumVerifierConfiguration.getAttribute("publish"); //$NON-NLS-1$
if (attribute == null || attribute.isBlank()) {
return true;
}
return Boolean.parseBoolean(attribute);
}

/**
* @param property either {@link IArtifactDescriptor#ARTIFACT_CHECKSUM} or {@link IArtifactDescriptor#DOWNLOAD_CHECKSUM}
* @param checksums
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -39,8 +40,7 @@ public void testChecksums() throws IOException {
Collections.emptyList());
assertTrue(status.toString(), status.isOK());
String md5sum = hashMap.get("md5");
assertNotNull("MD5 was not computed!", md5sum);
assertEquals("MD5 mismatch", "25b68bb92a7a77238bd60ad5e21bb91f", md5sum);
assertNull("MD5 was computed but should be disabled!", md5sum);
String sha256sum = hashMap.get("sha-256");
assertNotNull("SHA256 was not computed!", sha256sum);
assertEquals("SHA256 mismatch", "39d083c8c75eac51b2c4566cca299b41cc93d5b0313906f5979fbebf1104ff49", sha256sum);
Expand Down

0 comments on commit aca6f29

Please sign in to comment.