github-vet / github-vet/rangeloop-pointer-findings
trek10inc/awsets: lister/guardduty_detector.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [trek10inc/awsets](https://www.github.com/trek10inc/awsets) at [lister/guardduty_detector.go](https://github.com/trek10inc/awsets/blob/92e0054d69b0d5bd0c17536cb00404848a45f0b6/lister/guardduty_detector.go#L38-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.
> reference to id was used in a composite literal at line 40
[Click here to see the code in its original context.](https://github.com/trek10inc/awsets/blob/92e0054d69b0d5bd0c17536cb00404848a45f0b6/lister/guardduty_detector.go#L38-L72)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for _, id := range res.DetectorIds {
v, err := svc.GetDetector(ctx.Context, &guardduty.GetDetectorInput{
DetectorId: &id,
})
if err != nil {
return nil, fmt.Errorf("failed to get guard duty detector %s: %w", id, err)
}
r := resource.New(ctx, resource.GuardDutyDetector, id, id, v)
// Members
err = Paginator(func(nt2 *string) (*string, error) {
members, err := svc.ListMembers(ctx.Context, &guardduty.ListMembersInput{
DetectorId: &id,
MaxResults: 100,
NextToken: nt2,
OnlyAssociated: nil,
})
if err != nil {
return nil, fmt.Errorf("failed to get members for guard duty detector %s: %w", id, err)
}
for _, m := range members.Members {
mR := resource.New(ctx, resource.GuardDutyMember, m.AccountId, m.AccountId, m)
mR.AddRelation(resource.GuardDutyDetector, id, "")
rg.AddResource(mR)
}
return members.NextToken, nil
})
if err != nil {
return nil, err
}
rg.AddResource(r)
}
```
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: 92e0054d69b0d5bd0c17536cb00404848a45f0b6
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in lister/guardduty_detector.go at lines 38-72 and inspect the range over res.DetectorIds, the GetDetectorInput construction, and the member-listing callback. Check the analyzer's reported reference to id against the surrounding behavior, then determine whether the finding is a bug, mitigated, or desirable behavior. No test file is mentioned, so completion is a justified classification based on this code path.
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
- 25/100