From 06db3ee1a8a443316196e6d8f55f4d5fc0cac694 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Thu, 18 Apr 2019 15:46:07 +0300 Subject: [PATCH] Add MD5 verification for emoji pack source --- lib/mix/tasks/pleroma/emoji.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/mix/tasks/pleroma/emoji.ex b/lib/mix/tasks/pleroma/emoji.ex index 526b09b11..29c5d0c93 100644 --- a/lib/mix/tasks/pleroma/emoji.ex +++ b/lib/mix/tasks/pleroma/emoji.ex @@ -77,6 +77,16 @@ defmodule Mix.Tasks.Pleroma.Emoji do ) binary_archive = Tesla.get!(src_url).body + archive_md5 = :crypto.hash(:md5, binary_archive) |> Base.encode16() + + md5_status_text = ["MD5 of ", :bright, pack_name, :normal, " source file is ", :bright] + if archive_md5 == String.upcase(pack["src_md5"]) do + IO.puts(IO.ANSI.format(md5_status_text ++ [:green, "OK"])) + else + IO.puts(IO.ANSI.format(md5_status_text ++ [:red, "BAD"])) + + raise "Bad MD5 for #{pack_name}" + end # The url specified in files should be in the same directory files_url = Path.join(Path.dirname(manifest_url), pack["files"]) -- 2.45.2