mirror of
https://github.com/securego/gosec.git
synced 2025-11-23 22:15:04 +02:00
Resolve underlying type to detect overflows in type aliases
This commit is contained in:
committed by
Cosmin Cojocar
parent
4487a0c5a2
commit
08b94f9392
@@ -154,4 +154,40 @@ func ExampleFunction() {
|
||||
}
|
||||
`,
|
||||
}, 0, gosec.NewConfig()},
|
||||
{[]string{
|
||||
`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
type Uint uint
|
||||
|
||||
func main() {
|
||||
var a uint8 = math.MaxUint8
|
||||
b := Uint(a)
|
||||
fmt.Println(b)
|
||||
}
|
||||
`,
|
||||
}, 0, gosec.NewConfig()},
|
||||
{[]string{
|
||||
`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
type CustomType int
|
||||
|
||||
func main() {
|
||||
var a uint = math.MaxUint
|
||||
b := CustomType(a)
|
||||
fmt.Println(b)
|
||||
}
|
||||
`,
|
||||
}, 1, gosec.NewConfig()},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user