Skip to content

Commit c376140

Browse files
Merge pull request #3019 from jluhrsen/CORENET-7116
CORENET-7116: Fix security job - exclude vendor and upgrade to SHA256
2 parents 6dc1804 + 1aac2a7 commit c376140

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

.snyk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# References:
2+
# https://docs.snyk.io/scan-applications/snyk-code/using-snyk-code-from-the-cli/excluding-directories-and-files-from-the-snyk-code-cli-test
3+
# https://docs.snyk.io/snyk-cli/commands/ignore
4+
exclude:
5+
global:
6+
- 'vendor/**' # Upstream dependencies (not project code)

pkg/network/ovn_kubernetes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package network
22

33
import (
44
"context"
5-
"crypto/sha1"
5+
"crypto/sha256"
66
"encoding/hex"
77
"encoding/json"
88
"fmt"
@@ -483,7 +483,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
483483
// daemonsets need to know when those ConfigMaps change so they can
484484
// restart with the new options. Render those ConfigMaps first and
485485
// embed a hash of their data into the ovnkube-node daemonsets.
486-
h := sha1.New()
486+
h := sha256.New()
487487
for _, path := range cmPaths {
488488
manifests, err := render.RenderTemplate(path, &data)
489489
if err != nil {
@@ -505,7 +505,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
505505

506506
// Compute a separate hash for no-overlay node config (outboundSNAT).
507507
// This allows ovnkube-node to restart when outboundSNAT changes
508-
nodeNoOverlayHash := sha1.New()
508+
nodeNoOverlayHash := sha256.New()
509509
nodeNoOverlayHashData := fmt.Sprintf("outboundSNAT=%v", data.Data["NoOverlayOutboundSNAT"])
510510
if _, err := nodeNoOverlayHash.Write([]byte(nodeNoOverlayHashData)); err != nil {
511511
return nil, progressing, errors.Wrap(err, "failed to hash node no-overlay config")
@@ -515,7 +515,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
515515
// Compute a separate hash for control-plane config (bgpManagedConfig).
516516
// This allows ovnkube-control-plane to restart when bgpManagedConfig changes,
517517
// without restarting ovnkube-node pods.
518-
cpHash := sha1.New()
518+
cpHash := sha256.New()
519519
cpHashData := fmt.Sprintf("asNumber=%v,topology=%v",
520520
data.Data["NoOverlayManagedASNumber"],
521521
data.Data["NoOverlayManagedTopology"])

pkg/util/k8s/unstructured.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package k8s
22

33
import (
4-
"crypto/md5"
4+
"crypto/sha256"
55
"encoding/json"
66
"fmt"
77

@@ -25,13 +25,13 @@ func ToUnstructured(obj interface{}) (*uns.Unstructured, error) {
2525
return u, nil
2626
}
2727

28-
// CalculateHash computes MD5 sum of the JSONfied object passed as obj.
28+
// CalculateHash computes SHA256 sum of the JSONfied object passed as obj.
2929
func CalculateHash(obj interface{}) (string, error) {
3030
configStr, err := json.Marshal(obj)
3131
if err != nil {
3232
return "", err
3333
}
34-
configSum := md5.Sum(configStr)
34+
configSum := sha256.Sum256(configStr)
3535
return fmt.Sprintf("%x", configSum), nil
3636
}
3737

0 commit comments

Comments
 (0)