github-vet / github-vet/rangeloop-pointer-findings
sensu/sensu-aws: plugins/rds/check-rds-events/main.go; 49 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sensu/sensu-aws](https://www.github.com/sensu/sensu-aws) at [plugins/rds/check-rds-events/main.go](https://github.com/sensu/sensu-aws/blob/74db29abe13d69389d8d27e65b7532fb561de5cb/plugins/rds/check-rds-events/main.go#L100-L148)
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 cluster is reassigned at line 103
[Click here to see the code in its original context.](https://github.com/sensu/sensu-aws/blob/74db29abe13d69389d8d27e65b7532fb561de5cb/plugins/rds/check-rds-events/main.go#L100-L148)
Click here to show the 49 line(s) of Go which triggered the analyzer.
```go
for _, cluster := range clusters {
eventInput := &rds.DescribeEventsInput{}
eventInput.SourceType = aws.String("db-instance")
eventInput.SourceIdentifier = &cluster
eventInput.StartTime = aws.Time(time.Now().Add(time.Duration(-24*60) * time.Minute))
eventOutput, err := rdsClient.DescribeEvents(eventInput)
if err != nil {
fmt.Println("Error occurred while getting rds event details for db instance -", cluster, ",Error -", err)
return
}
if eventOutput == nil || eventOutput.Events == nil || len(eventOutput.Events) == 0 {
continue
}
for _, event := range eventOutput.Events {
// we will need to filter out non-disruptive/basic operation events.
//ie. the regular backup operations
match, _ := regexp.MatchString("Backing up DB instance", *event.Message)
if match {
continue
}
match, _ = regexp.MatchString("Finished DB Instance backup", *event.Message)
if match {
continue
}
match, _ = regexp.MatchString("Restored from snapshot", *event.Message)
if match {
continue
}
match, _ = regexp.MatchString("DB instance created", *event.Message)
if match {
continue
}
// ie. Replication resumed
match, _ = regexp.MatchString("Replication for the Read Replica resumed", *event.Message)
if match {
continue
}
// you can add more filters to skip more events.
// draft the messages
criticalClusters = append(criticalClusters, fmt.Sprintf("%s : %s \n", cluster, *event.Message))
}
}
```
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: 74db29abe13d69389d8d27e65b7532fb561de5cb
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.