github-vet / github-vet/rangeloop-pointer-findings
nezorflame/lazytranslate-tg-bot: bot.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [nezorflame/lazytranslate-tg-bot](https://www.github.com/nezorflame/lazytranslate-tg-bot) at [bot.go](https://github.com/nezorflame/lazytranslate-tg-bot/blob/221336dfde768ce0d989e22554ff7656035081a4/bot.go#L33-L72)
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.
>
[Click here to see the code in its original context.](https://github.com/nezorflame/lazytranslate-tg-bot/blob/221336dfde768ce0d989e22554ff7656035081a4/bot.go#L33-L72)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for u := range updates {
// ignore any non-Message updates
if u.Message == nil {
continue
}
// TODO: remove later
log.Printf("%s %d", u.Message.From.UserName, u.Message.From.ID)
// we need only messages directed to the bot
if !strings.HasPrefix(u.Message.Text, "@"+b.tgClient.Self.UserName) {
continue
}
// only accept messages of the users from the whitelist
if !intInStringSlice(u.Message.From.ID, b.cfg.GetStringSlice("whitelist")) {
continue
}
select {
case <-ctx.Done():
return errors.Wrap(ctx.Err(), "exiting the program")
default:
go func(u *tgbotapi.Update) {
errChan := make(chan error)
updateCtx, cancel := context.WithTimeout(ctx, b.cfg.GetDuration("ctx_timeout"))
defer cancel()
go b.parseUpdate(updateCtx, errChan, u.Message)
select {
case err := <-errChan:
if err != nil {
log.Printf("Failed to parse update: %v", err)
}
case <-updateCtx.Done():
log.Printf("Failed to parse update: %v", updateCtx.Err())
}
}(&u)
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature { 1} was not found in the callgraph; reference was passed directly to third-party code
```
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: 221336dfde768ce0d989e22554ff7656035081a4
Contributor guide
No contributing guide indexed for this repository
Research direction
Read bot.go lines 33-72, focusing on the range over updates and the pointer passed into the goroutine. Compare the analyzer details with the linked source context, then classify the finding as Bug, Mitigated, or Desirable Behavior by leaving the corresponding reaction on this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100