1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-23 22:15:04 +02:00

fix: build tag parsing. (#1413)

* fix: build tag parsing.

* chore: lint fixes.
This commit is contained in:
Matthew Hartstonge
2025-11-05 22:46:27 +13:00
committed by GitHub
parent d2d734859c
commit 10cf58a4a4
8 changed files with 218 additions and 56 deletions

View File

@@ -2,10 +2,9 @@ package testutils
import "github.com/securego/gosec/v2"
var (
// SampleCodeG601 - Implicit aliasing over range statement
SampleCodeG601 = []CodeSample{
{[]string{`
// SampleCodeG601 - Implicit aliasing over range statement
var SampleCodeG601 = []CodeSample{
{[]string{`
package main
import "fmt"
@@ -40,7 +39,7 @@ func main() {
fmt.Printf("%d %v %s", zero, c_star, c)
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
// see: github.com/securego/gosec/issues/475
package main
@@ -56,7 +55,7 @@ func main() {
}
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -77,7 +76,7 @@ func main() {
}
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -98,7 +97,7 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -119,7 +118,7 @@ func main() {
}
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -140,7 +139,7 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -165,7 +164,7 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -190,7 +189,7 @@ func main() {
}
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
@@ -205,17 +204,4 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
}
// SampleCodeBuildTag - G601 build tags
SampleCodeBuildTag = []CodeSample{
{[]string{`
// +build tag
package main
func main() {
fmt.Println("no package imported error")
}
`}, 1, gosec.NewConfig()},
}
)