Add more test to cover more use cases for G115 rule

Change-Id: Icb60fe14ae12439c1ee0e507a407a23ce4c64c85
Signed-off-by: Cosmin Cojocar <ccojocar@google.com>
This commit is contained in:
Cosmin Cojocar 2024-08-21 12:36:33 +00:00 committed by Cosmin Cojocar
parent 81cda2f91f
commit 8467f012e0

View file

@ -176,6 +176,36 @@ func main() {
`
package main
import (
"fmt"
)
func main() {
var a byte = '\xff'
b := int64(a)
fmt.Println(b)
}
`,
}, 0, gosec.NewConfig()},
{[]string{
`
package main
import (
"fmt"
)
func main() {
var a int8 = -1
b := int64(a)
fmt.Println(b)
}
`,
}, 0, gosec.NewConfig()},
{[]string{
`
package main
import (
"fmt"
"math"
@ -187,6 +217,21 @@ func main() {
var a uint = math.MaxUint
b := CustomType(a)
fmt.Println(b)
}
`,
}, 1, gosec.NewConfig()},
{[]string{
`
package main
import (
"fmt"
)
func main() {
a := []int{1,2,3}
b := uint32(len(a))
fmt.Println(b)
}
`,
}, 1, gosec.NewConfig()},