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

jlandowner/kubernetes-route53-sync: pkg/route53/sync.go; 33 LoC

Open
#15,652 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 [jlandowner/kubernetes-route53-sync](https://www.github.com/jlandowner/kubernetes-route53-sync) at [pkg/route53/sync.go](https://github.com/jlandowner/kubernetes-route53-sync/blob/292cf685f6e46cb124d1b7fc311bc169b2c760e9/pkg/route53/sync.go#L36-L68)

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

[Click here to see the code in its original context.](https://github.com/jlandowner/kubernetes-route53-sync/blob/292cf685f6e46cb124d1b7fc311bc169b2c760e9/pkg/route53/sync.go#L36-L68)

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

```go
for _, dnsName := range dnsNames {
// get current ResourceRecordSet
recordSet, err := getResourceRecordSet(ctx,
r53.ListResourceRecordSetsRequest(&route53.ListResourceRecordSetsInput{HostedZoneId: &zoneID}), dnsName)
if err != nil {
// if not found, create new ResourceRecordSet
if err == ErrRecordSetNotFound {
recordSet = &route53.ResourceRecordSet{
Name: &dnsName,
Type: route53.RRTypeA,
TTL: &ttl,
}
} else {
return errors.Wrapf(err, "failed to get dns records for zone-id=%s name=%s",
zoneID, dnsName)
}
}

// change ResourceRecords to given ips
records := make([]route53.ResourceRecord, 0)
for _, ip := range ips {
value := ip
records = append(records, route53.ResourceRecord{Value: &value})
}
recordSet.ResourceRecords = records
recordSet.TTL = &ttl

// upsert Route53 RecordSets
if err := upsertResourceRecordSets(ctx, r53, zoneID, recordSet); err != nil {
return errors.Wrapf(err, "failed to upsert dns records for zone-id=%s name=%s",
zoneID, dnsName)
}
}

```

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: 292cf685f6e46cb124d1b7fc311bc169b2c760e9

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pkg/route53/sync.go at the loop over dnsNames and inspect the ResourceRecordSet composite literal around lines 36-68. Review the analyzer warning about the dnsName reference and determine whether the pointer escapes in a way that causes incorrect behavior; done is a justified classification of the finding.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.