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

stelligent/mu: workflows/environment_upsert.go; 40 LoC

Open
#14,909 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 [stelligent/mu](https://www.github.com/stelligent/mu) at [workflows/environment_upsert.go](https://github.com/stelligent/mu/blob/cf4f7194ba5b2b53d9a03f1a9436e9085b03252c/workflows/environment_upsert.go#L66-L105)

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 e is reassigned at line 68

[Click here to see the code in its original context.](https://github.com/stelligent/mu/blob/cf4f7194ba5b2b53d9a03f1a9436e9085b03252c/workflows/environment_upsert.go#L66-L105)

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

```go
for _, e := range config.Environments {
if strings.EqualFold(e.Name, environmentName) {
workflow.environment = &e

workflow.rbacServices = make([]*subjectRoleBinding, 0)
workflow.rbacUsers = make([]*subjectRoleBinding, 0)
for _, binding := range config.RBAC {
if len(binding.Environments) > 0 {
found := false
for _, env := range binding.Environments {
if env == environmentName {
found = true
break
}
}

if !found {
log.Debugf("Skipping binding %v - unable to match env %v", binding, environmentName)
continue
}
}

for _, service := range binding.Services {
log.Debugf("Binding service %s to role %s", service, binding.Role)
workflow.rbacServices = append(workflow.rbacServices, &subjectRoleBinding{
Name: service,
Role: string(binding.Role),
})
}
for _, user := range binding.Users {
log.Debugf("Binding user %s to role %s", user, binding.Role)
workflow.rbacUsers = append(workflow.rbacUsers, &subjectRoleBinding{
Name: user,
Role: string(binding.Role),
})
}
}
return nil
}
}

```

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: cf4f7194ba5b2b53d9a03f1a9436e9085b03252c

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.