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

trek10inc/awsets: lister/codedeploy_application.go; 45 LoC

Open
#13,208 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 [trek10inc/awsets](https://www.github.com/trek10inc/awsets) at [lister/codedeploy_application.go](https://github.com/trek10inc/awsets/blob/92e0054d69b0d5bd0c17536cb00404848a45f0b6/lister/codedeploy_application.go#L38-L82)

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 app 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/codedeploy_application.go#L38-L82)

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

```go
for _, app := range res.Applications {
appRes, err := svc.GetApplication(ctx.Context, &codedeploy.GetApplicationInput{
ApplicationName: &app,
})
if err != nil {
return nil, fmt.Errorf("failed to get codedeploy application %s: %w", app, err)
}
v := appRes.Application
if v == nil {
continue
}
r := resource.New(ctx, resource.CodeDeployApplication, v.ApplicationId, v.ApplicationName, v)

// CodeDeploy Deployment Groups
err = Paginator(func(nt2 *string) (*string, error) {
depGroups, err := svc.ListDeploymentGroups(ctx.Context, &codedeploy.ListDeploymentGroupsInput{
ApplicationName: &app,
NextToken: nt2,
})
if err != nil {
return nil, fmt.Errorf("failed to list codedeploy deployment groups for app %s: %w", app, err)
}
groups := depGroups.DeploymentGroups
if len(groups) > 0 {
groupsRes, err := svc.BatchGetDeploymentGroups(ctx.Context, &codedeploy.BatchGetDeploymentGroupsInput{
ApplicationName: &app,
DeploymentGroupNames: groups,
})
if err != nil {
return nil, fmt.Errorf("failed to get codedeploy deployment groups for app %s: %w", app, err)
}
for _, group := range groupsRes.DeploymentGroupsInfo {
groupR := resource.New(ctx, resource.CodeDeployDeploymentGroup, group.DeploymentGroupId, group.DeploymentGroupName, group)
groupR.AddRelation(resource.CodeDeployApplication, app, "")
groupR.AddARNRelation(resource.IamRole, group.ServiceRoleArn)
groupR.AddRelation(resource.CodeDeployDeploymentConfig, group.DeploymentConfigName, "")
// TODO: add relationships for ECS, ELB, etc
rg.AddResource(groupR)
}
}

return depGroups.NextToken, nil
})
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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.