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

codeamp/circuit: plugins/codeamp/workflowreleaseextension_handler.go; 87 LoC

Open
#13,683 0 comments 0 reactions 0 assignees View on GitHub
fresh medium
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [codeamp/circuit](https://www.github.com/codeamp/circuit) at [plugins/codeamp/workflowreleaseextension_handler.go](https://github.com/codeamp/circuit/blob/06371150b7aaaf104d41907c6f432a795238bf3c/plugins/codeamp/workflowreleaseextension_handler.go#L202-L288)

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.

> function call at line 282 passes reference to releaseExtension to third-party code

[Click here to see the code in its original context.](https://github.com/codeamp/circuit/blob/06371150b7aaaf104d41907c6f432a795238bf3c/plugins/codeamp/workflowreleaseextension_handler.go#L202-L288)

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

```go
for _, releaseExtension := range releaseExtensions {
releaseExtensionAction := transistor.GetAction("create")
if releaseExtension.Type == plugins.GetType("deployment") {
_artifacts := artifacts

// Fail deployment if the release is in a failed state
if release.State == transistor.GetState("failed") {
releaseExtensionAction = transistor.GetAction("status")
releaseExtension.State = transistor.GetState("failed")
releaseExtension.StateMessage = release.StateMessage
}

projectExtension := model.ProjectExtension{}
if x.DB.Where("id = ?", releaseExtension.ProjectExtensionID).Find(&projectExtension).RecordNotFound() {
log.WarnWithFields("project extensions not found", log.Fields{
"id": releaseExtension.ProjectExtensionID,
"release_extension_id": releaseExtension.Model.ID,
})
return
}

extension := model.Extension{}
if x.DB.Where("id= ?", projectExtension.ExtensionID).Find(&extension).RecordNotFound() {
log.WarnWithFields("extension not found", log.Fields{
"id": projectExtension.Model.ID,
"release_extension_id": releaseExtension.Model.ID,
})
return
}

projectExtensionArtifacts, err := graphql_resolver.ExtractArtifacts(projectExtension, extension, x.DB)
if err != nil {
log.Error(err.Error())
}

for _, artifact := range projectExtensionArtifacts {
_artifacts = append(_artifacts, artifact)
}

releaseExtensionEvent := plugins.ReleaseExtension{
ID: releaseExtension.Model.ID.String(),
Release: plugins.Release{
ID: release.Model.ID.String(),
Environment: environment.Key,
HeadFeature: plugins.Feature{
Hash: headFeature.Hash,
ParentHash: headFeature.ParentHash,
User: headFeature.User,
Message: headFeature.Message,
Created: headFeature.Created,
},
TailFeature: plugins.Feature{
ID: tailFeature.Model.ID.String(),
Hash: tailFeature.Hash,
ParentHash: tailFeature.ParentHash,
User: tailFeature.User,
Message: tailFeature.Message,
Created: tailFeature.Created,
},
User: email,
Project: plugins.Project{
ID: project.Model.ID.String(),
Slug: project.Slug,
Repository: project.Repository,
},
Git: plugins.Git{
Url: project.GitUrl,
Branch: branch,
RsaPrivateKey: project.RsaPrivateKey,
},
Secrets: pluginSecrets,
Services: pluginServices,
IsRollback: release.IsRollback,
},
}

ev := transistor.NewEvent(transistor.EventName(fmt.Sprintf("release:%s", extension.Key)), releaseExtensionAction, releaseExtensionEvent)
ev.Artifacts = _artifacts

releaseExtension.Started = time.Now()
x.DB.Save(&releaseExtension)

x.Events <- ev

releaseExtensionDeploymentsCount++
}
}

```

Click here to show extra information the analyzer produced.

```
No path was found through the callgraph that could lead to a function which writes a pointer argument.

The following graphviz dot graph describes paths through the callgraph that could lead to a function which passes a pointer to third-party code:
digraph G {
"(Save, 1)" -> {}
}

```

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: 06371150b7aaaf104d41907c6f432a795238bf3c

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.