Skip to content
New issue

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

Support the math/rand/v2 added in Go 1.22 #1109

Closed
hyorimitsu opened this issue Feb 21, 2024 · 4 comments
Closed

Support the math/rand/v2 added in Go 1.22 #1109

hyorimitsu opened this issue Feb 21, 2024 · 4 comments

Comments

@hyorimitsu
Copy link
Contributor

Summary

In Go 1.22, the math/rand/v2 package has been added. Is it necessary to change G404 or create a new G405?

math/rand math/rand/v2
Intn IntN
Int31 Int32
Int31n Int32N
Int63 Int64
Int64n Int64N
- Uint32
- Uint32N
- Uint64
- Uint64N
- Uint
- UintN
- N

Steps to reproduce the behavior

func RandomString(letters []byte, n int) string {
	b := make([]byte, n)
	for i := range n {
		b[i] = letters[rand.IntN(len(letters))]
	}
	return string(b)
}

gosec version

v2.19.0

Go version (output of 'go version')

go version go1.22.0

Operating system / Environment

Expected behavior

Raised a security fatal

Actual behavior

No error

@hyorimitsu hyorimitsu changed the title Support math/rand/v2 in Go 1.22 Support the math/rand/v2 added in Go 1.22 Feb 21, 2024
@ccojocar
Copy link
Member

ccojocar commented Mar 4, 2024

I would enhance the existing rule to support the rand v2.

@hyorimitsu
Copy link
Contributor Author

@ccojocar
Thank you for your suggestion! Would it be alright if I take care of implementing it on my end?

@ccojocar
Copy link
Member

ccojocar commented Mar 5, 2024

Yes, please go ahead!

@ccojocar
Copy link
Member

ccojocar commented Mar 8, 2024

fixed by #1112

@ccojocar ccojocar closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants