gosec fixes and added #nosec where necassary

This commit is contained in:
2025-07-06 00:33:50 -05:00
parent ffb3c3d4f4
commit b9aebc8406
19 changed files with 109 additions and 55 deletions

View File

@@ -266,9 +266,13 @@ func NewAnnouncePacket(destHash []byte, identity *identity.Identity, appData []b
// Create random hash (10 bytes) - 5 bytes random + 5 bytes time
randomHash := make([]byte, 10)
rand.Read(randomHash[:5])
_, err := rand.Read(randomHash[:5]) // #nosec G104
if err != nil {
log.Printf("[DEBUG-6] Failed to read random bytes for hash: %v", err)
return nil, err // Or handle the error appropriately
}
timeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(timeBytes, uint64(time.Now().Unix()))
binary.BigEndian.PutUint64(timeBytes, uint64(time.Now().Unix())) // #nosec G115
copy(randomHash[5:], timeBytes[:5])
log.Printf("[DEBUG-6] Generated random hash: %x", randomHash)