github-vet / github-vet/rangeloop-pointer-findings
noironetworks/aci-containers: pkg/controller/network_policy.go; 9 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [noironetworks/aci-containers](https://www.github.com/noironetworks/aci-containers) at [pkg/controller/network_policy.go](https://github.com/noironetworks/aci-containers/blob/ec89d772eef758e2917500fda6e45019f288b063/pkg/controller/network_policy.go#L1445-L1453)
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 endpointPort is reassigned at line 1449
[Click here to see the code in its original context.](https://github.com/noironetworks/aci-containers/blob/ec89d772eef758e2917500fda6e45019f288b063/pkg/controller/network_policy.go#L1445-L1453)
Click here to show the 9 line(s) of Go which triggered the analyzer.
```go
for _, endpointPort := range endpointSlices.Ports {
if *endpointPort.Name == svcPort.Name ||
(len(service.Spec.Ports) == 1 &&
*endpointPort.Name == "") {
foundEpPort = &endpointPort
cont.log.Debug("Found EpPort: ", foundEpPort)
break
}
}
```
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: ec89d772eef758e2917500fda6e45019f288b063
Contributor guide
No contributing guide indexed for this repository
Research direction
Read pkg/controller/network_policy.go around lines 1445-1453 and inspect how endpointSlices.Ports and foundEpPort are used after the loop. Determine whether taking a reference to the range variable can select or retain the wrong endpoint port, then check the surrounding controller behavior and relevant tests to establish whether this is a bug, mitigated behavior, or desirable behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100