github-vet / github-vet/rangeloop-pointer-findings
ChatPlug/ChatPlug-go: core/mutation_resolver.go; 63 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ChatPlug/ChatPlug-go](https://www.github.com/ChatPlug/ChatPlug-go) at [core/mutation_resolver.go](https://github.com/ChatPlug/ChatPlug-go/blob/b1915907dd3ebd00f7fd6b414f345b44ea736b3d/core/mutation_resolver.go#L69-L131)
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/ChatPlug/ChatPlug-go/blob/b1915907dd3ebd00f7fd6b414f345b44ea736b3d/core/mutation_resolver.go#L69-L131)
Click here to show the 63 line(s) of Go which triggered the analyzer.
```go
for _, group := range groups {
rightGroup := false
var rightThreadID string
for _, thread := range group.Threads {
if thread.ServiceInstanceID == instance.ID && thread.OriginID == input.OriginThreadID {
rightGroup = true
rightThreadID = thread.ID
}
}
if rightGroup {
log.Println(group.Name)
var messageAuthor MessageAuthor
avatarURL := input.Author.AvatarURL
if avatarURL == "" {
avatarURL = "https://i.imgur.com/3yPh9fE.png"
}
r.App.db.Where("origin_id = ?", input.OriginID).FirstOrCreate(&messageAuthor,
MessageAuthor{
Username: input.Author.Username,
OriginID: input.Author.OriginID,
AvatarURL: avatarURL,
})
attachments := make([]Attachment, 0)
for _, attachment := range input.Attachments {
attachmentObj := Attachment{
Type: attachment.Type,
OriginID: attachment.OriginID,
SourceURL: attachment.SourceURL,
}
attachments = append(attachments, attachmentObj)
}
msg := &Message{
OriginID: input.OriginID,
Body: input.Body,
ThreadID: rightThreadID,
MessageAuthorID: messageAuthor.ID,
Attachments: attachments,
}
r.App.db.Model(&group).Association("Messages").Append(msg)
for _, thread := range group.Threads {
if thread.Readonly != nil && *thread.Readonly == true {
continue
}
if msg.ThreadID != thread.ID {
r.App.sm.FindLoadedInstance(thread.ServiceInstanceID).messageEventBroadcaster.Broadcast(&MessagePayload{
TargetThreadID: thread.OriginID,
Message: msg,
})
}
}
lastSentMsg = msg
}
}
```
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 {Model 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: b1915907dd3ebd00f7fd6b414f345b44ea736b3d
Contributor guide
No contributing guide indexed for this repository
Research direction
Review core/mutation_resolver.go at lines 69-131 and the analyzer context in this issue. Decide whether the reported range-loop pointer finding is a Bug, Mitigated, or Desirable Behavior, then leave the corresponding reaction; completion is a classification reaction on the 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
- Needs clarification
- Newbie friendliness
- 35/100