From 3a511c3fd793bd8a7546e4d7d34a29c635e7512b Mon Sep 17 00:00:00 2001 From: Adam Janikowski <12255597+ajanikow@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:49:26 +0200 Subject: [PATCH] [Bugfix] Use MD5 instead of SHA256 for CRD Checksums (#1653) --- CHANGELOG.md | 1 + pkg/crd/crds/crds.go | 4 ++-- pkg/util/checksum.go | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e186348..4b89f6737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - (Bugfix) Prevent unexpected rotation in case of SecurityContext change - (Bugfix) Ensure PDB is created - (Bugfix) Fix Schema Apply Checksum +- (Bugfix) Use MD5 instead of SHA256 for CRD Checksums ## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10) - (Feature) Add Core fields to the Scheduler Container Spec diff --git a/pkg/crd/crds/crds.go b/pkg/crd/crds/crds.go index e401280a6..ea7519ced 100644 --- a/pkg/crd/crds/crds.go +++ b/pkg/crd/crds/crds.go @@ -48,10 +48,10 @@ func (d DefinitionData) schemaDefinitionLoader() util.Loader[crdSchemas] { func (d DefinitionData) Checksum() (definition, schema string) { if len(d.definition) > 0 { - definition = util.SHA256(d.definition) + definition = util.MD5(d.definition) } if len(d.schemaDefinition) > 0 { - schema = util.SHA256(d.schemaDefinition) + schema = util.MD5(d.schemaDefinition) } return } diff --git a/pkg/util/checksum.go b/pkg/util/checksum.go index 27a692c6c..907516926 100644 --- a/pkg/util/checksum.go +++ b/pkg/util/checksum.go @@ -21,6 +21,7 @@ package util import ( + "crypto/md5" "crypto/sha256" "fmt" @@ -35,6 +36,14 @@ func SHA256(data []byte) string { return fmt.Sprintf("%0x", sha256.Sum256(data)) } +func MD5FromString(data string) string { + return MD5([]byte(data)) +} + +func MD5(data []byte) string { + return fmt.Sprintf("%0x", md5.Sum(data)) +} + func SHA256FromJSON[T interface{}](a T) (string, error) { d, err := json.Marshal(a) if err != nil {