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

davidddw/packer-builder-cloud: src/github.com/mitchellh/packer/builder/amazon/common/step_modify_ami_attributes.go; 20 LoC

Open
#11,446 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 [davidddw/packer-builder-cloud](https://www.github.com/davidddw/packer-builder-cloud) at [src/github.com/mitchellh/packer/builder/amazon/common/step_modify_ami_attributes.go](https://github.com/davidddw/packer-builder-cloud/blob/0d733c5ea51135e6d335bcb7ae73c6c5821624db/src/github.com/mitchellh/packer/builder/amazon/common/step_modify_ami_attributes.go#L90-L109)

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 ami is reassigned at line 100

[Click here to see the code in its original context.](https://github.com/davidddw/packer-builder-cloud/blob/0d733c5ea51135e6d335bcb7ae73c6c5821624db/src/github.com/mitchellh/packer/builder/amazon/common/step_modify_ami_attributes.go#L90-L109)

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

```go
for region, ami := range amis {
ui.Say(fmt.Sprintf("Modifying attributes on AMI (%s)...", ami))
awsConfig := aws.Config{
Credentials: ec2conn.Config.Credentials,
Region: aws.String(region),
}
session := session.New(&awsConfig)
regionconn := ec2.New(session)
for name, input := range options {
ui.Message(fmt.Sprintf("Modifying: %s", name))
input.ImageId = &ami
_, err := regionconn.ModifyImageAttribute(input)
if err != nil {
err := fmt.Errorf("Error modify AMI attributes: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}
}

```

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: 0d733c5ea51135e6d335bcb7ae73c6c5821624db

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/github.com/mitchellh/packer/builder/amazon/common/step_modify_ami_attributes.go around lines 90-109 and review the analyzer report about the reassigned ami reference. Trace how the range variables and ModifyImageAttribute input are used, then determine whether the finding represents a bug, mitigated behavior, or desirable behavior. Done means leaving the appropriate classification reaction with supporting context.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.