Skip to content

Commit

Permalink
[Bugfix] Use MD5 instead of SHA256 for CRD Checksums (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored Apr 30, 2024
1 parent 2397c75 commit 3a511c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/crd/crds/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package util

import (
"crypto/md5"
"crypto/sha256"
"fmt"

Expand All @@ -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 {
Expand Down

0 comments on commit 3a511c3

Please sign in to comment.