Add more tests samples to increase coverage

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
Cosmin Cojocar 2020-06-15 12:26:56 +02:00 committed by Cosmin Cojocar
parent fe07fcf276
commit 0c1a71b8a1

View file

@ -1891,13 +1891,15 @@ import "crypto/rand"
func main() { func main() {
good, _ := rand.Read(nil) good, _ := rand.Read(nil)
println(good) println(good)
}`}, 0, gosec.NewConfig()}, {[]string{` }`}, 0, gosec.NewConfig()},
{[]string{`
package main package main
import "math/rand" import "math/rand"
func main() { func main() {
bad := rand.Int() bad := rand.Int()
println(bad) println(bad)
}`}, 1, gosec.NewConfig()}, {[]string{` }`}, 1, gosec.NewConfig()},
{[]string{`
package main package main
import ( import (
"crypto/rand" "crypto/rand"
@ -1908,6 +1910,25 @@ func main() {
println(good) println(good)
bad := mrand.Int31() bad := mrand.Int31()
println(bad) println(bad)
}`}, 1, gosec.NewConfig()},
{[]string{`
package main
import (
"math/rand"
)
func main() {
gen := rand.New(rand.NewSource(10.4))
bad := gen.Int()
println(bad)
}`}, 1, gosec.NewConfig()},
{[]string{`
package main
import (
"math/rand"
)
func main() {
bad := rand.Intn(10)
println(bad)
}`}, 1, gosec.NewConfig()}} }`}, 1, gosec.NewConfig()}}
// SampleCodeG501 - Blacklisted import MD5 // SampleCodeG501 - Blacklisted import MD5