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

patrobinson/go-fish: monitoring.go; 37 LoC

Open
#18,398 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 [patrobinson/go-fish](https://www.github.com/patrobinson/go-fish) at [monitoring.go](https://github.com/patrobinson/go-fish/blob/c682be1adba3223adb9e941c77f72b0883ab55d9/monitoring.go#L145-L181)

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

[Click here to see the code in its original context.](https://github.com/patrobinson/go-fish/blob/c682be1adba3223adb9e941c77f72b0883ab55d9/monitoring.go#L145-L181)

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

```go
for pipeline, metric := range cw.pipelineMetrics {
metric.Lock()
metricTimestamp := time.Now()
_, err := cw.svc.PutMetricData(&cloudwatch.PutMetricDataInput{
Namespace: aws.String(cw.Namespace),
MetricData: []*cloudwatch.MetricDatum{
&cloudwatch.MetricDatum{
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("Pipeline"),
Value: &pipeline,
},
},
MetricName: aws.String("Pipelines"),
Unit: aws.String("Count"),
Timestamp: &metricTimestamp,
Value: aws.Float64(metric.pipelines),
},
&cloudwatch.MetricDatum{
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("Pipeline"),
Value: &pipeline,
},
},
MetricName: aws.String("EventsReceived"),
Unit: aws.String("Count"),
Timestamp: &metricTimestamp,
Value: aws.Float64(metric.eventsReceived),
},
},
})
metric.Unlock()
if err != nil {
log.Errorln("Error sending logs to CloudWatch", err)
}
}

```

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: c682be1adba3223adb9e941c77f72b0883ab55d9

Contributor guide

No contributing guide indexed for this repository

Research direction

Read monitoring.go lines 145-181 at commit c682be1 and inspect how pipelineMetrics is populated and consumed. Determine whether taking a pointer to the range variable changes the CloudWatch Pipeline dimension across iterations, then classify the finding as a bug, mitigated, or desirable behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go
Domain
cloud, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.