Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Use MD5 instead of SHA256 for CRD Checksums #1653

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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