Permalink
Browse files

introducing sha-256 checksum support (#625)

introducing sha-256 checksum support
  • Loading branch information...
gaboraranyossy-da authored and alexarchambault committed Aug 4, 2017
1 parent 56b6f57 commit dd3e8be410fc908790a036ac136d1946ef1f8ad1
@@ -871,8 +871,8 @@ object Cache {
parseChecksumLine(lines) orElse parseChecksumAlternative(lines)
}
// matches md5 or sha1
private val checksumPattern = Pattern.compile("^[0-9a-f]{32}([0-9a-f]{8})?")
// matches md5 or sha1 or sha-256
private val checksumPattern = Pattern.compile("^[0-9a-f]{32}([0-9a-f]{8})?([0-9a-f]{24})?")
private def findChecksum(elems: Seq[String]): Option[BigInteger] =
elems.collectFirst {
@@ -267,7 +267,7 @@ object TermDisplay {
.toVector
.filter {
case (url, _) =>
!url.endsWith(".sha1") && !url.endsWith(".md5") && !url.endsWith("/")
!url.endsWith(".sha1") && !url.endsWith(".sha256") && !url.endsWith(".md5") && !url.endsWith("/")
}
.sortBy { case (url, _) => url }
@@ -24,7 +24,8 @@ object Repository {
def withDefaultChecksums: Artifact =
underlying.copy(checksumUrls = underlying.checksumUrls ++ Seq(
"MD5" -> (underlying.url + ".md5"),
"SHA-1" -> (underlying.url + ".sha1")
"SHA-1" -> (underlying.url + ".sha1"),
"SHA-256" -> (underlying.url + ".sha256")
))
def withDefaultSignature: Artifact =
underlying.copy(extra = underlying.extra ++ Seq(
@@ -133,7 +133,7 @@ final case class MavenSource(
.map(artifactWithExtra)
}
private val types = Map("sha1" -> "SHA-1", "md5" -> "MD5", "asc" -> "sig")
private val types = Map("sha1" -> "SHA-1", "sha256" -> "SHA-256", "md5" -> "MD5", "asc" -> "sig")
private def artifactsKnownPublications(
dependency: Dependency,
@@ -327,7 +327,7 @@ final case class MavenSource(
object MavenSource {
private val checksumTypes = Set("MD5", "SHA-1")
private val checksumTypes = Set("MD5", "SHA-1", "SHA-256")
val typeExtensions: Map[String, String] = Map(
"eclipse-plugin" -> "jar",
@@ -248,7 +248,7 @@ class Launcher(
def globalLock = DummyGlobalLock
// See https://github.com/sbt/ivy/blob/2cf13e211b2cb31f0d3b317289dca70eca3362f6/src/java/org/apache/ivy/util/ChecksumHelper.java
def checksums: Array[String] = Array("sha1", "md5")
def checksums: Array[String] = Array("sha1", "sha256", "md5")
def app(id: xsbti.ApplicationID, version: String): xsbti.AppProvider =
app(ApplicationID(id).copy(version = version))
@@ -0,0 +1 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
@@ -0,0 +1 @@
df2bc197a6cf76f8086ef746e8af05ff07c2fbec8122ed474ffd341e1cf13307
@@ -0,0 +1 @@
401737ef38d6c6dd387f208123b3ec096f98899191311815596d8c79a6e5ae03
@@ -52,6 +52,12 @@ object ChecksumTests extends TestSuite {
assert(res.nonEmpty)
}
'binarySha256 - {
val content = Platform.readFullySync(getClass.getResource("/empty.sha256").openStream())
val res = Cache.parseRawChecksum(content)
assert(res.nonEmpty)
}
'binaryMd5 - {
val content = Platform.readFullySync(getClass.getResource("/empty.md5").openStream())
val res = Cache.parseRawChecksum(content)
@@ -77,7 +83,8 @@ object ChecksumTests extends TestSuite {
url,
Map(
"MD5" -> (url + ".md5"),
"SHA-1" -> (url + ".sha1")
"SHA-1" -> (url + ".sha1"),
"SHA-256" -> (url + ".sha256")
),
Map.empty,
Attributes("jar"),
@@ -98,6 +105,7 @@ object ChecksumTests extends TestSuite {
}
'sha1 - validateAll("SHA-1")
'sha256 - validateAll("SHA-256")
'md5 - validateAll("MD5")
}
}

0 comments on commit dd3e8be

Please sign in to comment.