Skip to content

Commit a1ea67a

Browse files
ignore gosec false positives (#1622)
1 parent 2bdc76a commit a1ea67a

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

p2p/discover/node.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ var incompleteNodeURL = regexp.MustCompile("(?i)^(?:enode://)?([0-9a-f]+)$")
125125
//
126126
// For incomplete nodes, the designator must look like one of these
127127
//
128-
// enode://<hex node id>
129-
// <hex node id>
128+
// enode://<hex node id>
129+
// <hex node id>
130130
//
131131
// For complete nodes, the node ID is encoded in the username portion
132132
// of the URL, separated from the host by an @ sign. The hostname can
@@ -139,7 +139,7 @@ var incompleteNodeURL = regexp.MustCompile("(?i)^(?:enode://)?([0-9a-f]+)$")
139139
// a node with IP address 10.3.58.6, TCP listening port 30303
140140
// and UDP discovery port 30301.
141141
//
142-
// enode://<hex node id>@10.3.58.6:30303?discport=30301
142+
// enode://<hex node id>@10.3.58.6:30303?discport=30301
143143
func ParseNode(rawurl string) (*Node, error) {
144144
if m := incompleteNodeURL.FindStringSubmatch(rawurl); m != nil {
145145
id, err := HexID(m[1])
@@ -424,9 +424,9 @@ func hashAtDistance(a common.Hash, n int) (b common.Hash) {
424424
pos++
425425
bit = 0x80
426426
}
427-
b[pos] = a[pos]&^bit | ^a[pos]&bit // TODO: randomize end bits
427+
b[pos] = a[pos]&^bit | ^a[pos]&bit
428428
for i := pos + 1; i < len(a); i++ {
429-
b[i] = byte(rand.Intn(255))
429+
b[i] = byte(rand.Intn(255)) //#nosec G404
430430
}
431431
return b
432432
}

p2p/discover/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func newTable(t transport, ourID NodeID, ourAddr *net.UDPAddr, nodeDBPath string
113113
initDone: make(chan struct{}),
114114
closeReq: make(chan struct{}),
115115
closed: make(chan struct{}),
116-
rand: mrand.New(mrand.NewSource(0)),
116+
rand: mrand.New(mrand.NewSource(0)), //#nosec G404
117117
ips: netutil.DistinctNetSet{Subnet: tableSubnet, Limit: tableIPLimit},
118118
}
119119
if err := tab.setFallbackNodes(bootnodes); err != nil {

p2p/discv5/node.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ var incompleteNodeURL = regexp.MustCompile("(?i)^(?:enode://)?([0-9a-f]+)$")
133133
//
134134
// For incomplete nodes, the designator must look like one of these
135135
//
136-
// enode://<hex node id>
137-
// <hex node id>
136+
// enode://<hex node id>
137+
// <hex node id>
138138
//
139139
// For complete nodes, the node ID is encoded in the username portion
140140
// of the URL, separated from the host by an @ sign. The hostname can
@@ -147,7 +147,7 @@ var incompleteNodeURL = regexp.MustCompile("(?i)^(?:enode://)?([0-9a-f]+)$")
147147
// a node with IP address 10.3.58.6, TCP listening port 30303
148148
// and UDP discovery port 30301.
149149
//
150-
// enode://<hex node id>@10.3.58.6:30303?discport=30301
150+
// enode://<hex node id>@10.3.58.6:30303?discport=30301
151151
func ParseNode(rawurl string) (*Node, error) {
152152
if m := incompleteNodeURL.FindStringSubmatch(rawurl); m != nil {
153153
id, err := HexID(m[1])
@@ -430,9 +430,9 @@ func hashAtDistance(a common.Hash, n int) (b common.Hash) {
430430
pos++
431431
bit = 0x80
432432
}
433-
b[pos] = a[pos]&^bit | ^a[pos]&bit // TODO: randomize end bits
433+
b[pos] = a[pos]&^bit | ^a[pos]&bit
434434
for i := pos + 1; i < len(a); i++ {
435-
b[i] = byte(rand.Intn(255))
435+
b[i] = byte(rand.Intn(255)) //#nosec G404
436436
}
437437
return b
438438
}

p2p/discv5/ticket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ func globalRandRead(b []byte) {
760760
val := 0
761761
for n := range b {
762762
if pos == 0 {
763-
val = rand.Int()
763+
val = rand.Int() //#nosec G404
764764
pos = 7
765765
}
766766
b[n] = byte(val)

p2p/rlpx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func sealEIP8(msg any, h *encHandshake) ([]byte, error) {
470470
}
471471
// pad with random amount of data. the amount needs to be at least 100 bytes to make
472472
// the message distinguishable from pre-EIP-8 handshakes.
473-
pad := padSpace[:mrand.Intn(len(padSpace)-100)+100]
473+
pad := padSpace[:mrand.Intn(len(padSpace)-100)+100] //#nosec G404
474474
buf.Write(pad)
475475
prefix := make([]byte, 2)
476476
binary.BigEndian.PutUint16(prefix, uint16(buf.Len()+eciesOverhead))
@@ -588,8 +588,8 @@ func newRLPXFrameRW(conn io.ReadWriter, s secrets) *rlpxFrameRW {
588588
iv := make([]byte, encc.BlockSize())
589589
return &rlpxFrameRW{
590590
conn: conn,
591-
enc: cipher.NewCTR(encc, iv),
592-
dec: cipher.NewCTR(encc, iv),
591+
enc: cipher.NewCTR(encc, iv), //#nosec G407
592+
dec: cipher.NewCTR(encc, iv), //#nosec G407
593593
macCipher: macc,
594594
egressMAC: s.EgressMAC,
595595
ingressMAC: s.IngressMAC,

0 commit comments

Comments
 (0)