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

banzaicloud/bank-vaults: pkg/kv/hsm/hsm.go; 19 LoC

Open
#12,135 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 [banzaicloud/bank-vaults](https://www.github.com/banzaicloud/bank-vaults) at [pkg/kv/hsm/hsm.go](https://github.com/banzaicloud/bank-vaults/blob/1b60156c61515842d6c51f80ba37ae3006226876/pkg/kv/hsm/hsm.go#L81-L99)

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 s is reassigned at line 84

[Click here to see the code in its original context.](https://github.com/banzaicloud/bank-vaults/blob/1b60156c61515842d6c51f80ba37ae3006226876/pkg/kv/hsm/hsm.go#L81-L99)

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

```go
for _, s := range slots {
if config.TokenLabel == "" {
if s.ID() == config.SlotID {
slot = &s // nolint:gosec
log.Infof("found HSM slot %d in HSM by slot ID", slot.ID())
break
}
} else {
tokenInfo, err := s.TokenInfo()
if err != nil {
return nil, errors.WrapIf(err, "can't query token info from slot")
}
if tokenInfo.Label == config.TokenLabel {
slot = &s // nolint:gosec
log.Infof("found HSM slot %d in HSM by token label", slot.ID())
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: 1b60156c61515842d6c51f80ba37ae3006226876

Contributor guide

No contributing guide indexed for this repository

Research direction

Read pkg/kv/hsm/hsm.go around lines 81-99 and inspect how the selected HSM slot is retained after the range loop. Determine whether the analyzer's finding represents a real bug, then classify the issue as Bug, Mitigated, or Desirable Behavior using the requested reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
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.