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

vchain-us/kube-notary: pkg/watcher/watcher.go; 35 LoC

Open
#12,906 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 [vchain-us/kube-notary](https://www.github.com/vchain-us/kube-notary) at [pkg/watcher/watcher.go](https://github.com/vchain-us/kube-notary/blob/8aa5e2f79850d1165cf38d995410d836345a39b5/pkg/watcher/watcher.go#L143-L177)

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 status was used in a composite literal at line 160

[Click here to see the code in its original context.](https://github.com/vchain-us/kube-notary/blob/8aa5e2f79850d1165cf38d995410d836345a39b5/pkg/watcher/watcher.go#L143-L177)

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

```go
for _, status := range pod.Status.ContainerStatuses {
if status.State.Running == nil {
w.log.Infof(`Container "%s" in pod "%s" is not running: skipped`, status.Name, pod.Name)
continue
}
errors := make([]error, 0)
hash, verification, err := verify.ImageID(
status.ImageID,
opts...,
)

if err != nil {
errors = append(errors, err)
w.log.Errorf(`Cannot verify "%s" in pod "%s": %s`, status.ImageID, pod.Name, err)
} else {
metric := metrics.Metric{
Pod: &pod,
ContainerStatus: &status,
Verification: verification,
Hash: hash,
}

fields := metric.LogFields()
if verification.Trusted() {
w.log.WithFields(*fields).Info("Image is trusted")
} else {
w.log.WithFields(*fields).Warn("Image is NOT trusted")
}

w.rec.Record(metric)
}

// update or insert the result into tmp list
w.upsert(pod, status, hash, verification, errors)
}

```

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: 8aa5e2f79850d1165cf38d995410d836345a39b5

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.