mirror of
https://github.com/securego/gosec.git
synced 2025-07-07 00:35:35 +02:00
Fix the bind rule to handle the case when the arguments of the net.Listen are returned by a function call
This commit is contained in:
committed by
Cosmin Cojocar
parent
f14f17fb1d
commit
9b32fcac16
@ -98,6 +98,42 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer l.Close()
|
||||
}`}, 1},
|
||||
// Bind to all networks indirectly through a parsing function
|
||||
{[]string{`
|
||||
package main
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
)
|
||||
func parseListenAddr(listenAddr string) (network string, addr string) {
|
||||
return "", ""
|
||||
}
|
||||
func main() {
|
||||
addr := ":2000"
|
||||
l, err := net.Listen(parseListenAddr(addr))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer l.Close()
|
||||
}`}, 1},
|
||||
// Bind to all networks indirectly through a parsing function
|
||||
{[]string{`
|
||||
package main
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
)
|
||||
const addr = ":2000"
|
||||
func parseListenAddr(listenAddr string) (network string, addr string) {
|
||||
return "", ""
|
||||
}
|
||||
func main() {
|
||||
l, err := net.Listen(parseListenAddr(addr))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer l.Close()
|
||||
}`}, 1},
|
||||
}
|
||||
// SampleCodeG103 find instances of unsafe blocks for auditing purposes
|
||||
|
Reference in New Issue
Block a user