We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive when converting int to uint16 even with a guard
int
uint16
for i, port := range ports { if port < 0 || port > math.MaxUint16 { t.Fatalf("unexpected port %d returned, expecting range 0-%d", port, math.MaxUint16) } uports[i] = uint16(port) // #nosec G115 }
v2.20.1-0.20240822074752-ab3f6c1c83a0
go version go1.23.0 darwin/arm64
OS-X
I expect the range check to suppress the warning, I also expect an explicit bitmask to have the same effect, e.g. uports[i] = uint16(port & 0xffff)
uports[i] = uint16(port & 0xffff)
Both of these flag as G115 and require the // #nosec G115 comment to have the linter pass
// #nosec G115
The text was updated successfully, but these errors were encountered:
This issue should've been resolved by #1194 which was merged just now.
Sorry, something went wrong.
fixed by #1194
No branches or pull requests
Summary
False positive when converting
int
touint16
even with a guardSteps to reproduce the behavior
gosec version
v2.20.1-0.20240822074752-ab3f6c1c83a0
Go version (output of 'go version')
go version go1.23.0 darwin/arm64
Operating system / Environment
OS-X
Expected behavior
I expect the range check to suppress the warning, I also expect an explicit bitmask to have the same effect, e.g.
uports[i] = uint16(port & 0xffff)
Actual behavior
Both of these flag as G115 and require the
// #nosec G115
comment to have the linter passThe text was updated successfully, but these errors were encountered: