github-vet / github-vet/rangeloop-pointer-findings

hub-kubernetes/kubernetes-federation: src/github.com/kubernetes-sigs/federation-v2/pkg/kubefed2/federate/util.go; 19 LoC

Open
#15,371 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [hub-kubernetes/kubernetes-federation](https://www.github.com/hub-kubernetes/kubernetes-federation) at [src/github.com/kubernetes-sigs/federation-v2/pkg/kubefed2/federate/util.go](https://github.com/hub-kubernetes/kubernetes-federation/blob/015c60e07d9fac0a205a9768080a4c6c4b63b753/src/github.com/kubernetes-sigs/federation-v2/pkg/kubefed2/federate/util.go#L101-L119)

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 resource is reassigned at line 112

[Click here to see the code in its original context.](https://github.com/hub-kubernetes/kubernetes-federation/blob/015c60e07d9fac0a205a9768080a4c6c4b63b753/src/github.com/kubernetes-sigs/federation-v2/pkg/kubefed2/federate/util.go#L101-L119)

Click here to show the 19 line(s) of Go which triggered the analyzer.

```go
for _, resource := range resourceList.APIResources {
if lowerKey == resource.Name ||
lowerKey == resource.SingularName ||
lowerKey == strings.ToLower(resource.Kind) ||
lowerKey == fmt.Sprintf("%s.%s", resource.Name, gv.Group) {

targetResource = &resource
break
}
for _, shortName := range resource.ShortNames {
if lowerKey == strings.ToLower(shortName) {
targetResource = &resource
break
}
}
if targetResource != nil {
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: 015c60e07d9fac0a205a9768080a4c6c4b63b753

Contributor guide

No contributing guide indexed for this repository

Research direction

Read src/github.com/kubernetes-sigs/federation-v2/pkg/kubefed2/federate/util.go at lines 101-119 and inspect how targetResource is used after the loop. Determine whether taking the address of the range variable changes the selected resource, then classify the finding as Bug, Mitigated, or Desirable Behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.