You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import"fmt"funcmain() {
s:=make([]byte, 0)
iflen(s) >0 {
switchs[0] {
case0:
b:=trueifb==true {
// Should work for many-levels of nesting when the condition is not on the target slicefmt.Println(s[0])
}
returndefault:
fmt.Println(s[0])
return
}
}
}
Summary
Noticed that we're receiving errors for the G602 (slices out of bounds) rules when we have proper bound checks
Steps to reproduce the behavior
Code sample (inspired by the current unit tests):
gosec version
v2.20.1-0.20240826145712-bcec04e78483
Go version (output of 'go version')
go version go1.23.0 darwin/arm64
Operating system / Environment
Mac OS Sonoma 14.6.1 (M1/arm64)
Expected behavior
I'd expect these samples to not return any errors
Actual behavior
They all return errors since the bounds check does not look deeper into conditionals
The text was updated successfully, but these errors were encountered: