github-advanced-security[bot] commented on code in PR #3592:
URL: https://github.com/apache/dubbo-go/pull/3592#discussion_r3709166703
##########
remoting/getty/pool.go:
##########
@@ -173,11 +173,16 @@
if c.sessions == nil {
return nil
}
- count := len(c.sessions)
- if count == 0 {
+ available := make([]getty.Session, 0, len(c.sessions))
+ for _, s := range c.sessions {
+ if s != nil && s.session != nil && !s.session.IsClosed() {
+ available = append(available, s.session)
+ }
+ }
+ if len(available) == 0 {
return nil
}
- return c.sessions[rand.Int31n(int32(count))].session
+ return available[rand.Int31n(int32(len(available)))]
Review Comment:
## SonarCloud / Pseudorandom number generators (PRNGs) should not be used in
security contexts
<!--SONAR_ISSUE_KEY:AZ_Kv7m4nTNtJqMtbCUU-->Make sure that using this
pseudorandom number generator is safe here. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache_dubbo-go&issues=AZ_Kv7m4nTNtJqMtbCUU&open=AZ_Kv7m4nTNtJqMtbCUU&pullRequest=3592">SonarQube
Cloud</a></p>
[Show more
details](https://github.com/apache/dubbo-go/security/code-scanning/76)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]