github-vet / github-vet/rangeloop-pointer-findings
spaceuptech/galaxy: runner/driver/istio/istio_helpers.go; 45 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [spaceuptech/galaxy](https://www.github.com/spaceuptech/galaxy) at [runner/driver/istio/istio_helpers.go](https://github.com/spaceuptech/galaxy/blob/af9d3063d8bcdde926c074b754bdef47226c38ae/runner/driver/istio/istio_helpers.go#L231-L275)
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 rule was used in a composite literal at line 262
[Click here to see the code in its original context.](https://github.com/spaceuptech/galaxy/blob/af9d3063d8bcdde926c074b754bdef47226c38ae/runner/driver/istio/istio_helpers.go#L231-L275)
Click here to show the 45 line(s) of Go which triggered the analyzer.
```go
for i, rule := range service.Expose.Rules {
// Prepare variables
var headers *networkingv1alpha3.Headers
retries := &networkingv1alpha3.HTTPRetry{Attempts: 3, PerTryTimeout: &types.Duration{Seconds: 90}}
destHost := fmt.Sprintf("%s.%s.svc.cluster.local", service.ID, getNamespaceName(service.ProjectID, service.Environment))
destPort := uint32(rule.Port)
// Redirect traffic to galaxy runner when no of replicas is equal to zero. The galaxy proxy will scale up the service
// to service incoming requests.
if service.Scale.Replicas == 0 {
headers = &networkingv1alpha3.Headers{
Request: &networkingv1alpha3.Headers_HeaderOperations{
Set: map[string]string{
"x-og-project": service.ProjectID,
"x-og-service": service.ID,
"x-og-host": destHost,
"x-og-port": strconv.Itoa(int(destPort)),
"x-og-env": service.Environment,
"x-og-version": service.Version,
},
},
}
retries = &networkingv1alpha3.HTTPRetry{Attempts: 1, PerTryTimeout: &types.Duration{Seconds: 180}}
destHost = "runner.galaxy.svc.cluster.local"
destPort = proxyPort
}
match := prepareHTTPMatch(&rule)
match[0].Gateways = []string{getGatewayName(service)}
httpRoutes = append(httpRoutes, &networkingv1alpha3.HTTPRoute{
Match: match,
Rewrite: prepareHTTPMatchRewrite(&rule),
Name: fmt.Sprintf("expose-%d-%d", i, rule.Port),
Retries: retries,
Route: []*networkingv1alpha3.HTTPRouteDestination{
{
Headers: headers,
Destination: &networkingv1alpha3.Destination{
Host: destHost,
Port: &networkingv1alpha3.PortSelector{Number: destPort},
},
},
},
})
}
```
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: af9d3063d8bcdde926c074b754bdef47226c38ae
Contributor guide
No contributing guide indexed for this repository
Research direction
Read runner/driver/istio/istio_helpers.go around lines 231-275, especially the range over service.Expose.Rules and the composite literal near line 262. Check whether the reported reference to the range variable can affect generated Istio routes, then classify the finding as a bug, mitigated, or desirable behavior using the linked project guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100