github-vet / github-vet/rangeloop-pointer-findings
WeBankPartners/wecube-plugins-qcloud: plugins/clb_target.go; 24 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [WeBankPartners/wecube-plugins-qcloud](https://www.github.com/WeBankPartners/wecube-plugins-qcloud) at [plugins/clb_target.go](https://github.com/WeBankPartners/wecube-plugins-qcloud/blob/81fcf0e7b0d6bf733572823782d1bf6be7327663/plugins/clb_target.go#L460-L483)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to hostId was used in a composite literal at line 464
[Click here to see the code in its original context.](https://github.com/WeBankPartners/wecube-plugins-qcloud/blob/81fcf0e7b0d6bf733572823782d1bf6be7327663/plugins/clb_target.go#L460-L483)
Click here to show the 24 line(s) of Go which triggered the analyzer.
```go
for index, hostId := range newHostIds {
hostPort, _ := strconv.ParseInt(hostPorts[index], 10, 64)
describeInstancesParams := cvm.DescribeInstancesRequest{
InstanceIds: []*string{&hostId},
}
clientCvm, _ := createCvmClient(paramsMap["Region"], paramsMap["SecretID"], paramsMap["SecretKey"])
var describeInstancesResponse *cvm.DescribeInstancesResponse
describeInstancesResponse, err = describeInstancesFromCvm(clientCvm, describeInstancesParams)
if err != nil {
logrus.Errorf("describeInstancesFromCvm meet error=%v", err)
return
}
if len(describeInstancesResponse.Response.InstanceSet) == 0 {
logrus.Errorf("hostId=[%v] is not existed", hostId)
err = fmt.Errorf("hostId=[%v] is not existed", hostId)
return
}
if err = ensureDelListenerBackHost(client, input.LbId, listenerId, hostPort, hostId); err != nil {
logrus.Errorf("ensureDelListenerBackHost meet error=%v", err)
return
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 81fcf0e7b0d6bf733572823782d1bf6be7327663
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at plugins/clb_target.go lines 460-483, especially the range loop and the reference to hostId in the DescribeInstancesRequest composite literal. Check the referenced Go range-loop behavior and determine whether the analyzer finding is a bug, mitigated issue, or desirable behavior; done means leaving the corresponding reaction on this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100