mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
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:
parent
81cda2f91f
commit
8467f012e0
1 changed files with 45 additions and 0 deletions
|
@ -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()},
|
||||
|
|
Loading…
Reference in a new issue