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

qingqingjia26/flannelLearn: backend/awsvpc/awsvpc.go; 27 LoC

Open
#14,559 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 [qingqingjia26/flannelLearn](https://www.github.com/qingqingjia26/flannelLearn) at [backend/awsvpc/awsvpc.go](https://github.com/qingqingjia26/flannelLearn/blob/1e3c4a3d0be6eb635311efcc0b207dc678fcb9d1/backend/awsvpc/awsvpc.go#L154-L180)

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

[Click here to see the code in its original context.](https://github.com/qingqingjia26/flannelLearn/blob/1e3c4a3d0be6eb635311efcc0b207dc678fcb9d1/backend/awsvpc/awsvpc.go#L154-L180)

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

```go
for _, routeTableID := range tables {
err = be.cleanupBlackholeRoutes(routeTableID, networkConfig.Network, ec2c)
if err != nil {
log.Errorf("Error cleaning up blackhole routes: %v", err)
}

matchingRouteFound, err := be.checkMatchingRoutes(routeTableID, l.Subnet.String(), eni.NetworkInterfaceId, ec2c)
if err != nil {
log.Errorf("Error describing route tables: %v", err)
}

if !matchingRouteFound {
cidrBlock := l.Subnet.String()
deleteRouteInput := &ec2.DeleteRouteInput{RouteTableId: &routeTableID, DestinationCidrBlock: &cidrBlock}
if _, err := ec2c.DeleteRoute(deleteRouteInput); err != nil {
if ec2err, ok := err.(awserr.Error); !ok || ec2err.Code() != "InvalidRoute.NotFound" {
// an error other than the route not already existing occurred
return nil, fmt.Errorf("error deleting existing route for %s: %v", l.Subnet.String(), err)
}
}

// Add the route for this machine's subnet
if err := be.createRoute(routeTableID, l.Subnet.String(), eni.NetworkInterfaceId, ec2c); err != nil {
return nil, fmt.Errorf("unable to add route %s: %v", l.Subnet.String(), 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: 1e3c4a3d0be6eb635311efcc0b207dc678fcb9d1

Contributor guide

No contributing guide indexed for this repository

Research direction

Read backend/awsvpc/awsvpc.go at lines 154-180 and inspect the range-loop reference to routeTableID in the DeleteRouteInput literal. Reproduce or analyze the reported finding, then check related route cleanup behavior and available tests. Done means the finding is classified and the route deletion path is verified as safe, with coverage if the issue is confirmed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.