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

prune998/certmerge-operator: pkg/controller/certmerge/certmerge_controller.go; 9 LoC

Open
#15,394 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 [prune998/certmerge-operator](https://www.github.com/prune998/certmerge-operator) at [pkg/controller/certmerge/certmerge_controller.go](https://github.com/prune998/certmerge-operator/blob/6fd0733a7350139425102fc57d136298a6b140d8/pkg/controller/certmerge/certmerge_controller.go#L172-L180)

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 cm at line 173 may start a goroutine

[Click here to see the code in its original context.](https://github.com/prune998/certmerge-operator/blob/6fd0733a7350139425102fc57d136298a6b140d8/pkg/controller/certmerge/certmerge_controller.go#L172-L180)

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

```go
for _, cm := range cml.Items {
if secretInCertMergeList(&cm, instance) || secretInCertMergeLabels(&cm, instance) {
// trigger the CertMerge Reconcile
result = append(result, reconcile.Request{
NamespacedName: client.ObjectKey{Namespace: cm.Namespace, Name: cm.Name}})

log.Infof("CertMerge %s/%s added to Reconcile List", cm.Namespace, cm.Name)
}
}

```

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 {
"(Add, 2)" -> {"(Create, 2)";"(set, 4)";}
"(referrers, 1)" -> {"(globalReferrersPkgLevel, 3)";}
"(allPackages, 3)" -> {}
"(Get, 3)" -> {"(RoundTrip, 1)";}
"(RoundTripOpt, 2)" -> {"(roundTrip, 1)";}
"(secretInCertMergeLabels, 2)" -> {"(Add, 1)";"(Set, 1)";}
"(Count, 2)" -> {"(Run, 2)";}
"(insertCert, 4)" -> {"(New, 1)";}
"(NewCertSigner, 2)" -> {"(New, 1)";}
"(newClientTransport, 6)" -> {}
"(DialURL, 3)" -> {"(Dial, 3)";}
"(Do, 3)" -> {}
"(Create, 2)" -> {"(Decode, 2)";"(Create, 3)";}
"(Decode, 2)" -> {"(f, 2)";}
"(Dial, 3)" -> {"(NewClientConn, 3)";}
"(dial, 2)" -> {"(DialURL, 3)";}
"(read, 2)" -> {"(Get, 3)";}
"(Dial, 1)" -> {"(dial, 1)";"(dial, 2)";}
"(Add, 1)" -> {"(add, 1)";"(Add, 2)";"(insertCert, 4)";"(NewCertSigner, 2)";}
"(Build, 1)" -> {"(ForEachPackage, 2)";}
"(globalReferrersPkgLevel, 3)" -> {}
"(SetTransportDefaults, 1)" -> {"(ConfigureTransport, 1)";}
"(add, 1)" -> {"(New, 1)";}
"(RoundTrip, 1)" -> {"(Dial, 1)";"(ConnectWithRedirects, 5)";"(roundTrip, 1)";"(RoundTripOpt, 2)";}
"(dialWithoutProxy, 2)" -> {"(Dial, 3)";}
"(ConnectWithRedirects, 5)" -> {"(Dial, 1)";}
"(set, 4)" -> {"(Do, 3)";}
"(f, 2)" -> {}
"(implements, 1)" -> {"(Build, 1)";}
"(New, 1)" -> {"(get, 1)";"(Read, 2)";}
"(get, 1)" -> {"(SetTransportDefaults, 1)";}
"(awaitOpenSlotForRequest, 1)" -> {}
"(configureTransport, 1)" -> {"(addConnIfNeeded, 3)";}
"(ForEachPackage, 2)" -> {"(allPackages, 3)";}
"(roundTrip, 1)" -> {"(awaitOpenSlotForRequest, 1)";}
"(Read, 2)" -> {"(read, 2)";}
"(NewClientConn, 3)" -> {"(clientHandshake, 2)";}
"(Create, 3)" -> {"(Get, 3)";}
"(dial, 1)" -> {"(dialWithoutProxy, 2)";}
"(clientHandshake, 2)" -> {"(newClientTransport, 6)";}
"(Set, 1)" -> {"(Count, 2)";"(New, 1)";}
"(Run, 2)" -> {"(implements, 1)";"(referrers, 1)";}
"(ConfigureTransport, 1)" -> {"(configureTransport, 1)";}
"(addConnIfNeeded, 3)" -> {}
}

```

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: 6fd0733a7350139425102fc57d136298a6b140d8

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect pkg/controller/certmerge/certmerge_controller.go around lines 172-180, starting with the range over cml.Items and the secretInCertMergeList and secretInCertMergeLabels calls. Determine whether the referenced range variable can escape through a goroutine, then classify the finding as Bug, Mitigated, or Desirable Behavior using the issue's reaction instructions.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.