mirror of
https://github.com/coredns/coredns.git
synced 2025-12-31 14:01:22 -05:00
chore(lint): enable gosec (#7792)
Enable "gosec" linter.
Exclude:
- All G115 (integer overflow) findings, to be fixed separately.
Add targeted gosec annotations for:
- non-crypto math/rand usage
- md5 used only for file change detection
- G114 ("net/http serve with no timeout settings"), to be fixed
separately.
Other findings fixed.
Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -3,7 +3,7 @@ package loadbalance
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"crypto/md5" // #nosec G501 -- used only as a checksum for file change detection (not for security).
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -52,7 +52,7 @@ type randomUint struct {
|
||||
}
|
||||
|
||||
func (r *randomUint) randInit() {
|
||||
r.rn = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
r.rn = rand.New(rand.NewSource(time.Now().UnixNano())) // #nosec G404 -- non-cryptographic randomness for load balancing.
|
||||
}
|
||||
|
||||
func (r *randomUint) randUint(limit uint) uint {
|
||||
@@ -245,7 +245,7 @@ func (w *weightedRR) updateWeights() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
md5sum := md5.Sum(bytes)
|
||||
md5sum := md5.Sum(bytes) // #nosec G401 -- used only as a checksum for file change detection (not for security).
|
||||
if md5sum == w.md5sum {
|
||||
// file contents has not changed
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user