mirror of
https://github.com/securego/gosec.git
synced 2025-06-14 23:45:03 +02:00
Ignore struct pointers in G601 (#1003)
Updates https://github.com/securego/gosec/issues/966 Signed-off-by: Alexander Yastrebov <yastrebov.alex@gmail.com>
This commit is contained in:
committed by
GitHub
parent
85005c43d9
commit
21d13c9a9b
@ -1178,7 +1178,7 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
|
||||
@ -1199,7 +1199,7 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
|
||||
"time"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
|
||||
@ -1222,7 +1222,7 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
|
||||
"time"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
|
||||
@ -3623,6 +3623,46 @@ type sampleStruct struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func main() {
|
||||
samples := []*sampleStruct{
|
||||
{name: "a"},
|
||||
{name: "b"},
|
||||
}
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample)
|
||||
}
|
||||
}`}, 1, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type sampleStruct struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func main() {
|
||||
samples := []*sampleStruct{
|
||||
{name: "a"},
|
||||
{name: "b"},
|
||||
}
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample.name)
|
||||
}
|
||||
}`}, 0, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type sampleStruct struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func main() {
|
||||
samples := []sampleStruct{
|
||||
{name: "a"},
|
||||
@ -3655,6 +3695,44 @@ func main() {
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample.sub.name)
|
||||
}
|
||||
}`}, 1, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type subStruct struct {
|
||||
name string
|
||||
}
|
||||
|
||||
type sampleStruct struct {
|
||||
sub subStruct
|
||||
}
|
||||
|
||||
func main() {
|
||||
samples := []*sampleStruct{
|
||||
{sub: subStruct{name: "a"}},
|
||||
{sub: subStruct{name: "b"}},
|
||||
}
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample.sub.name)
|
||||
}
|
||||
}`}, 0, gosec.NewConfig()},
|
||||
{[]string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
one, two := 1, 2
|
||||
samples := []*int{&one, &two}
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample)
|
||||
}
|
||||
}`}, 1, gosec.NewConfig()},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user