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

pennmanor/kayako-mattermost-bot: kayako-mattermost-notifier.go; 6 LoC

Open
#15,676 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 [pennmanor/kayako-mattermost-bot](https://www.github.com/pennmanor/kayako-mattermost-bot) at [kayako-mattermost-notifier.go](https://github.com/pennmanor/kayako-mattermost-bot/blob/eccdcec0dccb7072c3541b15217e121af39b481d/kayako-mattermost-notifier.go#L97-L102)

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

[Click here to see the code in its original context.](https://github.com/pennmanor/kayako-mattermost-bot/blob/eccdcec0dccb7072c3541b15217e121af39b481d/kayako-mattermost-notifier.go#L97-L102)

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

```go
for key, t := range newTickets {
if _, found := oldTickets[key]; !found {
msg := gomm.IncomingWebhookRequest{Text: fmt.Sprintf("Opened %v", buildTicketString(&client, &t)), Username: "kayako"}
c <- msg
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read kayako-mattermost-notifier.go around lines 97-102 and inspect the range over newTickets. Determine whether passing &t to buildTicketString can reference the range variable incorrectly, then leave the requested reaction classifying the finding as Bug, Mitigated, or Desirable Behavior.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.