Skip to content

Commit

Permalink
security: changed sha1 calls to sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
pacificcode committed Jul 18, 2024
1 parent 1e4cdc8 commit 02b00e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/🔒 Security-20240718-081820.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: "\U0001F512 Security"
body: Changed sha1 function calls to sha256
time: 2024-07-18T08:18:20.013668-07:00
8 changes: 4 additions & 4 deletions commands/secret.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"crypto/sha1"
"crypto/sha256"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -1014,12 +1014,12 @@ func getSecretFromServer(vcli vaultcli.CLI, secretType string, path string, id s

func getSecretCachePrefix() string {
profile := viper.GetString(cst.Profile)
return fmt.Sprintf("%s-%x", cst.SecretRoot, sha1.Sum([]byte(profile)))
return fmt.Sprintf("%s-%x", cst.SecretRoot, sha256.Sum256([]byte(profile)))
}

func getSecretDescCachePrefix() string {
profile := viper.GetString(cst.Profile)
return fmt.Sprintf("%s-%x", cst.SecretDescriptionRoot, sha1.Sum([]byte(profile)))
return fmt.Sprintf("%s-%x", cst.SecretDescriptionRoot, sha256.Sum256([]byte(profile)))
}

func getSecretCacheKey(path string, id string, requestSuffix string) string {
Expand All @@ -1037,7 +1037,7 @@ func getSecretCacheKey(path string, id string, requestSuffix string) string {
cacheKey = id
}
cacheKey = strings.ReplaceAll(cacheKey, ":", "/")
cacheKey = fmt.Sprintf("%s-%x", prefix, sha1.Sum([]byte(cacheKey)))
cacheKey = fmt.Sprintf("%s-%x", prefix, sha256.Sum256([]byte(cacheKey)))
return cacheKey
}

Expand Down

0 comments on commit 02b00e9

Please sign in to comment.