golangci-lint/test/testdata/gosec.go

39 lines
710 B
Go
Raw Permalink Normal View History

//golangcitest:args -Egosec
2018-05-07 14:02:27 +03:00
package testdata
import (
"crypto/md5" // want "G501: Blocklisted import crypto/md5: weak cryptographic primitive"
2019-02-18 11:05:28 +03:00
"fmt"
"log"
2019-02-18 11:05:28 +03:00
"os"
"os/exec"
2018-05-07 14:02:27 +03:00
)
func Gosec() {
h := md5.New() // want "G401: Use of weak cryptographic primitive"
2018-05-07 14:02:27 +03:00
log.Print(h)
}
func GosecNolintGas() {
h := md5.New() //nolint:gas
log.Print(h)
}
func GosecNolintGosec() {
h := md5.New() //nolint:gosec
log.Print(h)
}
2019-02-18 11:05:28 +03:00
func GosecNoErrorCheckingByDefault() {
f, _ := os.Create("foo")
fmt.Println(f)
}
func GosecG204SubprocWithFunc() {
arg := func() string {
return "/tmp/dummy"
}
exec.Command("ls", arg()).Run() // want "G204: Subprocess launched with a potential tainted input or cmd arguments"
}