Blame SOURCES/flatpak-builder-source-archive-source-file-Deprecate-MD5-and-SHA1-ha.patch

4bf950
From dfcc0717abaf30d1c0ac76becbe7e334b6a31a3e Mon Sep 17 00:00:00 2001
4bf950
From: Debarshi Ray <debarshir@gnome.org>
4bf950
Date: Mon, 31 Jan 2022 15:16:12 +0100
4bf950
Subject: [PATCH] source-archive, source-file: Deprecate MD5 and SHA1 hashes
4bf950
4bf950
... because of their weaknesses, and show a warning suggesting SHA256
4bf950
instead.
4bf950
4bf950
The new test cases were removed from this commit to simplify the
4bf950
downstream build.
4bf950
4bf950
https://github.com/flatpak/flatpak-builder/pull/459
4bf950
https://bugzilla.redhat.com/show_bug.cgi?id=1935509
4bf950
---
4bf950
 src/builder-source-archive.c | 12 ++++++++++++
4bf950
 src/builder-source-file.c    | 12 ++++++++++++
4bf950
 2 files changed, 24 insertions(+)
4bf950
4bf950
diff --git a/src/builder-source-archive.c b/src/builder-source-archive.c
4bf950
index c93f84efc84c..04eafe44cd01 100644
4bf950
--- a/src/builder-source-archive.c
4bf950
+++ b/src/builder-source-archive.c
4bf950
@@ -230,11 +230,23 @@ builder_source_archive_set_property (GObject      *object,
4bf950
     case PROP_MD5:
4bf950
       g_free (self->md5);
4bf950
       self->md5 = g_value_dup_string (value);
4bf950
+      if (self->md5 != NULL && self->md5[0] != '\0')
4bf950
+        {
4bf950
+          g_printerr ("The \"md5\" source property is deprecated due to the weakness of MD5 hashes.\n");
4bf950
+          g_printerr ("Use the \"sha256\" property for the more secure SHA256 hash.\n");
4bf950
+        }
4bf950
+
4bf950
       break;
4bf950
 
4bf950
     case PROP_SHA1:
4bf950
       g_free (self->sha1);
4bf950
       self->sha1 = g_value_dup_string (value);
4bf950
+      if (self->sha1 != NULL && self->sha1[0] != '\0')
4bf950
+        {
4bf950
+          g_printerr ("The \"sha1\" source property is deprecated due to the weakness of SHA1 hashes.\n");
4bf950
+          g_printerr ("Use the \"sha256\" property for the more secure SHA256 hash.\n");
4bf950
+        }
4bf950
+
4bf950
       break;
4bf950
 
4bf950
     case PROP_SHA256:
4bf950
diff --git a/src/builder-source-file.c b/src/builder-source-file.c
4bf950
index 715803d510bb..8a4077246cda 100644
4bf950
--- a/src/builder-source-file.c
4bf950
+++ b/src/builder-source-file.c
4bf950
@@ -154,11 +154,23 @@ builder_source_file_set_property (GObject      *object,
4bf950
     case PROP_MD5:
4bf950
       g_free (self->md5);
4bf950
       self->md5 = g_value_dup_string (value);
4bf950
+      if (self->md5 != NULL && self->md5[0] != '\0')
4bf950
+        {
4bf950
+          g_printerr ("The \"md5\" source property is deprecated due to the weakness of MD5 hashes.\n");
4bf950
+          g_printerr ("Use the \"sha256\" property for the more secure SHA256 hash.\n");
4bf950
+        }
4bf950
+
4bf950
       break;
4bf950
 
4bf950
     case PROP_SHA1:
4bf950
       g_free (self->sha1);
4bf950
       self->sha1 = g_value_dup_string (value);
4bf950
+      if (self->sha1 != NULL && self->sha1[0] != '\0')
4bf950
+        {
4bf950
+          g_printerr ("The \"sha1\" source property is deprecated due to the weakness of SHA1 hashes.\n");
4bf950
+          g_printerr ("Use the \"sha256\" property for the more secure SHA256 hash.\n");
4bf950
+        }
4bf950
+
4bf950
       break;
4bf950
 
4bf950
     case PROP_SHA256:
4bf950
-- 
4bf950
2.34.1
4bf950