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

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