Skip to content

Commit

Permalink
Add more test to cover more use cases for G115 rule
Browse files Browse the repository at this point in the history
Change-Id: Icb60fe14ae12439c1ee0e507a407a23ce4c64c85
Signed-off-by: Cosmin Cojocar <ccojocar@google.com>
  • Loading branch information
ccojocar committed Aug 21, 2024
1 parent 81cda2f commit 8467f01
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions testutils/g115_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()},
Expand Down

0 comments on commit 8467f01

Please sign in to comment.