Skip to content

Commit

Permalink
chore: Fix gosec g401 in a handful of spots (#10446)
Browse files Browse the repository at this point in the history
* fix g401 in ruler

* Suppress shard.go
  • Loading branch information
alexweav authored Jan 15, 2025
1 parent 6dedf22 commit 709316b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions pkg/ruler/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package ruler

import (
"crypto/md5"
"bytes"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -156,11 +156,9 @@ func (m *mapper) writeRuleGroupsIfNewer(groups []rulefmt.RuleGroup, filename str
if err != nil {
return false, err
}
newHash := md5.New()
currentHash := md5.New()

// bailout if there is no update
if string(currentHash.Sum(current)) == string(newHash.Sum(d)) {
if bytes.Equal(current, d) {
return false, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
// ShuffleShardSeed returns seed for random number generator, computed from provided identifier.
func ShuffleShardSeed(identifier, zone string) int64 {
// Use the identifier to compute an hash we'll use to seed the random.
hasher := md5.New()
hasher := md5.New() //nolint:gosec
hasher.Write(YoloBuf(identifier)) // nolint:errcheck
if zone != "" {
hasher.Write(seedSeparator) // nolint:errcheck
Expand Down

0 comments on commit 709316b

Please sign in to comment.