1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-25 22:22:17 +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

@@ -3,8 +3,9 @@ package testutils
import "github.com/securego/gosec/v2"
// SampleCodeG501 - Blocklisted import MD5
var SampleCodeG501 = []CodeSample{
{[]string{`
var (
SampleCodeG501 = []CodeSample{
{[]string{`
package main
import (
@@ -19,4 +20,27 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
}
// SampleCodeG501BuildTag provides a reportable file if a build tag is
// supplied.
SampleCodeG501BuildTag = []CodeSample{
{[]string{`
//go:build tag
package main
import (
"crypto/md5"
"fmt"
"os"
)
func main() {
for _, arg := range os.Args {
fmt.Printf("%x - %s\n", md5.Sum([]byte(arg)), arg)
}
}
`}, 2, gosec.NewConfig()},
}
)