29)
30
31func Server(ctx context.Context, cfg *config.Control) error {
32 rand.Seed(time.Now().UTC().UnixNano()) 33
34 if err := prepare(ctx, cfg); err != nil {
35 return errors.Wrap(err, "preparing server")
16)
17
18func Agent(ctx context.Context, nodeConfig *daemonconfig.Node, proxy proxy.Proxy) error {
19 rand.Seed(time.Now().UTC().UnixNano())20
21 logs.InitLogs()
22 defer logs.FlushLogs()
37}
38
39func main() {
40 rand.Seed(time.Now().UnixNano())41
42 command := cmd.NewDefaultKubectlCommand()
43 if err := cli.RunNoErrOutput(command); err != nil {
As math/rand
uses a statistical random number generator, using a low entropy
seed (such as constants and the current system time) may allow an attacker to
predict what the following number generated is.
package main
import (
"math/rand"
"time"
)
func main() {
rand.Seed(42) // constant seeds are bad
rand.Seed(time.Now().Unix()) // time based seeds don't have sufficient entropy
}