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

xrstf/kubermatic-old: api/pkg/provider/kubernetes/admin.go; 6 LoC

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

Description

Found a possible issue in [xrstf/kubermatic-old](https://www.github.com/xrstf/kubermatic-old) at [api/pkg/provider/kubernetes/admin.go](https://github.com/xrstf/kubermatic-old/blob/770154f0998b6bd980ce6d0c526bfa89e9d5e7e1/api/pkg/provider/kubernetes/admin.go#L64-L69)

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.

> function call which takes a reference to user at line 67 may start a goroutine

[Click here to see the code in its original context.](https://github.com/xrstf/kubermatic-old/blob/770154f0998b6bd980ce6d0c526bfa89e9d5e7e1/api/pkg/provider/kubernetes/admin.go#L64-L69)

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

```go
for _, user := range userList.Items {
if strings.EqualFold(user.Spec.Email, email) {
user.Spec.IsAdmin = isAdmin
return a.client.KubermaticV1().Users().Update(&user)
}
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(Update, 2)" -> {"(New, 1)";"(Get, 2)";}
"(createEncoderOfType, 2)" -> {"(_createEncoderOfType, 2)";}
"(decoderOfSlice, 2)" -> {"(append, 1)";}
"(describeStruct, 2)" -> {"(append, 1)";}
"(ExpandSchema, 3)" -> {"(ExpandSchemaWithBasePath, 3)";}
"(Do, 2)" -> {}
"(load, 1)" -> {"(parsePackageFiles, 2)";}
"(resolveRef, 3)" -> {"(load, 1)";}
"(Get, 2)" -> {"(Validate, 1)";}
"(Write, 1)" -> {"(Encode, 2)";}
"(get, 1)" -> {"(SetTransportDefaults, 1)";}
"(encoderOfMap, 2)" -> {"(append, 1)";}
"(NewSchemaValidator, 4)" -> {"(ExpandSchema, 3)";}
"(Resolve, 3)" -> {"(resolveRef, 3)";}
"(Search, 2)" -> {"(List, 1)";}
"(ExpandSchemaWithBasePath, 3)" -> {"(expandSchema, 4)";}
"(append, 1)" -> {}
"(parseFiles, 6)" -> {}
"(encoderOfMapKey, 2)" -> {"(encoderOfType, 2)";}
"(Encode, 2)" -> {"(encoderOfMapKey, 2)";}
"(encoderOfSlice, 2)" -> {"(append, 1)";}
"(createEncoderOfNative, 2)" -> {"(decoderOfSlice, 2)";}
"(encoderOfStruct, 2)" -> {"(describeStruct, 2)";}
"(Update, 1)" -> {"(Add, 1)";"(New, 1)";"(Update, 2)";}
"(List, 2)" -> {"(Do, 2)";}
"(copy, 2)" -> {"(get, 1)";}
"(addConnIfNeeded, 3)" -> {}
"(encoderOfArray, 2)" -> {"(append, 1)";}
"(Validate, 1)" -> {"(NewSchemaValidator, 4)";"(validatePatternProperty, 3)";}
"(expandSchema, 4)" -> {"(Resolve, 3)";}
"(Add, 1)" -> {"(Search, 2)";"(copy, 2)";"(New, 1)";}
"(New, 1)" -> {"(parse, 1)";"(get, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(parse, 1)" -> {"(Write, 1)";}
"(encoderOfType, 2)" -> {"(createEncoderOfType, 2)";}
"(_createEncoderOfType, 2)" -> {"(encoderOfSlice, 2)";"(encoderOfMap, 2)";"(createEncoderOfNative, 2)";"(encoderOfStruct, 2)";"(encoderOfArray, 2)";}
"(parsePackageFiles, 2)" -> {"(parseFiles, 6)";}
"(validatePatternProperty, 3)" -> {"(NewSchemaValidator, 4)";}
"(List, 1)" -> {"(List, 2)";}
}

```

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: 770154f0998b6bd980ce6d0c526bfa89e9d5e7e1

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with api/pkg/provider/kubernetes/admin.go lines 64-69 and inspect how the range variable user is passed to Users().Update. Determine whether the analyzer's possible goroutine and range-variable reference represent a real bug, a mitigated case, or desirable behavior. When decided, classify the finding with the requested reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.