Skip to content

Commit 3ae65a3

Browse files
committed
chore: address gosec lints
1 parent ed6f359 commit 3ae65a3

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

core/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ func hashIPBlock(ip ipblock.IPBlock) uint32 {
3030
binary.BigEndian.PutUint64(buf[:], data)
3131

3232
hash := xxh3.Hash(buf[:])
33-
return uint32(hash) // #nosec G115 -- expected truncation
33+
return uint32(hash & 0xffffffff)
3434
}
3535

3636
func hashUUID(id uuid.UUID) uint32 {
3737
hash := xxh3.Hash(id[:])
38-
return uint32(hash) // #nosec G115 -- expected truncation
38+
return uint32(hash & 0xffffffff)
3939
}
4040

4141
type InstanceState struct {

internal/expiremap/expiremap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type ExpireMap[K comparable, V any] struct {
2828
// fastModulo calculates x % n without using the modulo operator (~4x faster).
2929
// Reference: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
3030
func fastModulo(x, n uint32) uint32 {
31-
return uint32((uint64(x) * uint64(n)) >> 32) //nolint:gosec
31+
return uint32((uint64(x) * uint64(n)) >> 32)
3232
}
3333

3434
func NewExpireMap[K comparable, V any](hash func(K) uint32) *ExpireMap[K, V] {

internal/ipblock/ipblock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (b IPBlock) ToIPNet(cfg Config) *net.IPNet {
7777

7878
ip := make(net.IP, 16)
7979
for i := range 8 {
80-
ip[7-i] = byte(b.data >> (8 * i))
80+
ip[7-i] = byte((b.data >> (8 * i)) & 0xff)
8181
}
8282
return &net.IPNet{
8383
IP: ip,

0 commit comments

Comments
 (0)