From 87664a382418f1c94ec98c4a412df11a4e5a6aa1 Mon Sep 17 00:00:00 2001 From: benthecarman <15256660+benthecarman@users.noreply.github.com> Date: Fri, 23 Sep 2022 06:19:25 -0500 Subject: [PATCH] Error on invalid download of binaries (#4798) --- bitcoind-rpc/bitcoind-rpc.sbt | 26 ++++++++++++-------------- clightning-rpc/clightning-rpc.sbt | 6 ++++++ eclair-rpc/eclair-rpc.sbt | 7 ++++++- lnd-rpc/lnd-rpc.sbt | 7 ++++++- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/bitcoind-rpc/bitcoind-rpc.sbt b/bitcoind-rpc/bitcoind-rpc.sbt index 95c7a4307c..2df61d79fe 100644 --- a/bitcoind-rpc/bitcoind-rpc.sbt +++ b/bitcoind-rpc/bitcoind-rpc.sbt @@ -23,13 +23,7 @@ TaskKeys.downloadBitcoind := { } val versions = - List("23.0", - "22.0", - "0.21.1", - "0.20.1", - "0.19.0.1", - "0.18.1", - "0.17.0.1") + List("23.0", "22.0", "0.21.1", "0.20.1", "0.19.0.1", "0.18.1", "0.17.0.1") logger.debug( s"(Maybe) downloading Bitcoin Core binaries for versions: ${versions.mkString(",")}") @@ -38,7 +32,8 @@ TaskKeys.downloadBitcoind := { if (Properties.isLinux) ("x86_64-linux-gnu", "tar.gz") else if (Properties.isMac) version match { - case "23.0" if System.getProperty("os.arch") == "aarch64" => ("arm64-apple-darwin", "tar.gz") + case "23.0" if System.getProperty("os.arch") == "aarch64" => + ("arm64-apple-darwin", "tar.gz") case "23.0" => ("x86_64-apple-darwin", "tar.gz") case _ => ("osx64", "tar.gz") } @@ -110,11 +105,10 @@ TaskKeys.downloadBitcoind := { ) else if (Properties.isMac) Map( - "23.0" -> ( - if (System.getProperty("os.arch") == "aarch64") - "7c8bc63731aa872b7b334a8a7d96e33536ad77d49029bad179b09dca32cd77ac" - else - "c816780583009a9dad426dc0c183c89be9da98906e1e2c7ebae91041c1aaaaf3"), + "23.0" -> (if (System.getProperty("os.arch") == "aarch64") + "7c8bc63731aa872b7b334a8a7d96e33536ad77d49029bad179b09dca32cd77ac" + else + "c816780583009a9dad426dc0c183c89be9da98906e1e2c7ebae91041c1aaaaf3"), "22.0" -> "2744d199c3343b2d94faffdfb2c94d75a630ba27301a70e47b0ad30a7e0155e9", "0.21.1" -> "1ea5cedb64318e9868a66d3ab65de14516f9ada53143e460d50af428b5aec3c7", "0.20.1" -> "b9024dde373ea7dad707363e07ec7e265383204127539ae0c234bff3a61da0d1", @@ -134,7 +128,8 @@ TaskKeys.downloadBitcoind := { ) else sys.error(s"Unsupported OS: ${Properties.osName}") - if (hash.equalsIgnoreCase(expectedHash(version))) { + val success = hash.equalsIgnoreCase(expectedHash(version)) + if (success) { logger.info(s"Download complete and verified, unzipping result") val extractCommand = @@ -148,6 +143,9 @@ TaskKeys.downloadBitcoind := { logger.info(s"Deleting archive") Files.delete(archiveLocation) + + if (!success) + throw new RuntimeException(s"Failed to download bitcoind v$version") } } diff --git a/clightning-rpc/clightning-rpc.sbt b/clightning-rpc/clightning-rpc.sbt index 0f831010c8..7cd7efd87a 100644 --- a/clightning-rpc/clightning-rpc.sbt +++ b/clightning-rpc/clightning-rpc.sbt @@ -56,6 +56,7 @@ TaskKeys.downloadCLightning := { "de61bb1dec0f656e192f896de7dcb08f4b07cf9c2bdaef8c78d860cd80ea6776" else sys.error(s"Unsupported OS: ${Properties.osName}") + val success = hash.equalsIgnoreCase(expectedHash) if (hash.equalsIgnoreCase(expectedHash)) { logger.info(s"Download complete and verified, unzipping result") @@ -69,5 +70,10 @@ TaskKeys.downloadCLightning := { logger.info(s"Deleting archive") Files.delete(archiveLocation) + + if (!success) { + throw new RuntimeException( + s"Failed to download and verify clightning v$version") + } } } diff --git a/eclair-rpc/eclair-rpc.sbt b/eclair-rpc/eclair-rpc.sbt index b7f57e68f9..66b6d46736 100644 --- a/eclair-rpc/eclair-rpc.sbt +++ b/eclair-rpc/eclair-rpc.sbt @@ -50,7 +50,8 @@ TaskKeys.downloadEclair := { val expectedHash = "482a00cc597fd4cc471a1b4035c72a440a9ab336ef5b9006629d2fd717b223b4" - if (hash.equalsIgnoreCase(expectedHash)) { + val success = hash.equalsIgnoreCase(expectedHash) + if (success) { logger.info(s"Download complete and verified, unzipping result") val extractCommand = s"unzip $archiveLocation -d $versionDir" @@ -64,6 +65,10 @@ TaskKeys.downloadEclair := { logger.info(s"Deleting archive") Files.delete(archiveLocation) + if (!success) { + throw new RuntimeException(s"Failed to download eclair v$version") + } + logger.info(s"Download complete") } } diff --git a/lnd-rpc/lnd-rpc.sbt b/lnd-rpc/lnd-rpc.sbt index 51b70fa924..68015df8e6 100644 --- a/lnd-rpc/lnd-rpc.sbt +++ b/lnd-rpc/lnd-rpc.sbt @@ -83,7 +83,8 @@ TaskKeys.downloadLnd := { "74c16854292ca27b335309d7b37a44baec4df402e16b203df393ebece6570ad3" else sys.error(s"Unsupported OS: ${Properties.osName}") - if (hash.equalsIgnoreCase(expectedHash)) { + val success = hash.equalsIgnoreCase(expectedHash) + if (success) { logger.info(s"Download complete and verified, unzipping result") val extractCommand = s"tar -xzf $archiveLocation --directory $binaryDir" @@ -96,5 +97,9 @@ TaskKeys.downloadLnd := { logger.info(s"Deleting archive") Files.delete(archiveLocation) + + if (!success) { + throw new RuntimeException(s"Failed to lnd eclair v$version") + } } }