github-vet / github-vet/rangeloop-pointer-findings
cilium/cilium: test/helpers/kubectl.go; 18 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cilium/cilium](https://www.github.com/cilium/cilium) at [test/helpers/kubectl.go](https://github.com/cilium/cilium/blob/dc01471fdabccb8ba3ebdcaf6c3b6bcc4354d465/test/helpers/kubectl.go#L1812-L1829)
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 port is reassigned at line 1816
[Click here to see the code in its original context.](https://github.com/cilium/cilium/blob/dc01471fdabccb8ba3ebdcaf6c3b6bcc4354d465/test/helpers/kubectl.go#L1812-L1829)
Click here to show the 18 line(s) of Go which triggered the analyzer.
```go
for _, port := range serviceObj.Spec.Ports {
var foundPort *v1.ServicePort
for _, realizedService := range realizedServices {
if port.Port == int32(realizedService.FrontendAddress.Port) {
foundPort = &port
break
}
}
if foundPort == nil {
return fmt.Errorf("port %d of service %s (%s) not found in cilium pod %s",
port.Port, fullName, serviceObj.Spec.ClusterIP, ciliumPod)
}
if _, ok := lbMap[net.JoinHostPort(serviceObj.Spec.ClusterIP, fmt.Sprintf("%d", port.Port))]; !ok {
return fmt.Errorf("port %d of service %s (%s) not found in cilium bpf lb list of pod %s",
port.Port, fullName, serviceObj.Spec.ClusterIP, ciliumPod)
}
}
```
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: dc01471fdabccb8ba3ebdcaf6c3b6bcc4354d465
Contributor guide
No contributing guide indexed for this repository
Research direction
Read test/helpers/kubectl.go around lines 1812-1829 and inspect the analyzer's range-loop finding in the shown service-port lookup. Determine whether the referenced port can become invalid or point to another iteration, then validate the behavior with the relevant test coverage; done means the finding is resolved or documented as safe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100