mirror of
https://github.com/securego/gosec.git
synced 2025-11-29 22:37:59 +02:00
Recognize struct field in G601
Signed-off-by: futuretea <1913508671@qq.com>
This commit is contained in:
committed by
Cosmin Cojocar
parent
1457921142
commit
bd58600acf
@@ -3444,6 +3444,70 @@ func main() {
|
||||
fmt.Println(sampleString)
|
||||
}
|
||||
}`}, 0, 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"},
|
||||
{name: "b"},
|
||||
}
|
||||
for _, sample := range samples {
|
||||
fmt.Println(&sample.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)
|
||||
}
|
||||
}`}, 1, gosec.NewConfig()},
|
||||
}
|
||||
|
||||
// SampleCodeBuildTag - G601 build tags
|
||||
|
||||
Reference in New Issue
Block a user