diff --git a/analyzers/conversion_overflow.go b/analyzers/conversion_overflow.go index 11cfaf5..c5d6a59 100644 --- a/analyzers/conversion_overflow.go +++ b/analyzers/conversion_overflow.go @@ -76,7 +76,7 @@ type integer struct { } func parseIntType(intType string) (integer, error) { - re := regexp.MustCompile(`(?Pu?int)(?P\d{2})?`) + re := regexp.MustCompile(`(?Pu?int)(?P\d{1,2})?`) matches := re.FindStringSubmatch(intType) if matches == nil { return integer{}, fmt.Errorf("no integer type match found for %s", intType) diff --git a/testutils/g115_samples.go b/testutils/g115_samples.go index 29f992f..b8d1099 100644 --- a/testutils/g115_samples.go +++ b/testutils/g115_samples.go @@ -235,4 +235,34 @@ func main() { } `, }, 1, gosec.NewConfig()}, + {[]string{ + ` +package main + +import ( + "fmt" +) + +func main() { + a := "A\xFF" + b := int64(a[0]) + fmt.Printf("%d\n", b) +} + `, + }, 0, gosec.NewConfig()}, + {[]string{ + ` +package main + +import ( + "fmt" +) + +func main() { + var a uint8 = 13 + b := int(a) + fmt.Printf("%d\n", b) +} + `, + }, 0, gosec.NewConfig()}, }