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

AshishJainRadicle/fissionJvm: pkg/fission-cli/cmd/spec/spec.go; 62 LoC

Open
#11,284 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 [AshishJainRadicle/fissionJvm](https://www.github.com/AshishJainRadicle/fissionJvm) at [pkg/fission-cli/cmd/spec/spec.go](https://github.com/AshishJainRadicle/fissionJvm/blob/e2f1f778f353af857e0b7323299a3962c264334b/pkg/fission-cli/cmd/spec/spec.go#L361-L422)

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.

>

[Click here to see the code in its original context.](https://github.com/AshishJainRadicle/fissionJvm/blob/e2f1f778f353af857e0b7323299a3962c264334b/pkg/fission-cli/cmd/spec/spec.go#L361-L422)

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

```go
for _, f := range fr.Functions {
functions[MapKey(&f.ObjectMeta)] = false

pkgMeta := &metav1.ObjectMeta{
Name: f.Spec.Package.PackageRef.Name,
Namespace: f.Spec.Package.PackageRef.Namespace,
}

// check package ref from function
packageRefExists := func() bool {
_, ok := packages[MapKey(pkgMeta)]
return ok
}

// check that the package referenced by each function is in the same ns as the function
packageRefInFuncNs := func(f *fv1.Function) bool {
return f.Spec.Package.PackageRef.Namespace == f.ObjectMeta.Namespace
}

if !packageRefInFuncNs(&f) {
result = multierror.Append(result, fmt.Errorf(
"%v: function '%v' references a package outside of its namespace %v/%v",
fr.SourceMap.Locations["Function"][f.ObjectMeta.Namespace][f.ObjectMeta.Name],
f.ObjectMeta.Name,
f.Spec.Package.PackageRef.Namespace,
f.Spec.Package.PackageRef.Name))
} else if !packageRefExists() {
result = multierror.Append(result, fmt.Errorf(
"%v: function '%v' references unknown package %v/%v",
fr.SourceMap.Locations["Function"][f.ObjectMeta.Namespace][f.ObjectMeta.Name],
f.ObjectMeta.Name,
pkgMeta.Namespace,
pkgMeta.Name))
} else {
packages[MapKey(pkgMeta)] = true
}

client, err := util.GetServer(input)
if err != nil {
return warnings, err
}
for _, cm := range f.Spec.ConfigMaps {
_, err := client.V1().Misc().ConfigMapGet(&metav1.ObjectMeta{
Name: cm.Name,
Namespace: cm.Namespace,
})
if k8serrors.IsNotFound(err) {
warnings = append(warnings, fmt.Sprintf("Configmap %s is referred in the spec but not present in the cluster", cm.Name))
}
}

for _, s := range f.Spec.Secrets {
_, err := client.V1().Misc().SecretGet(&metav1.ObjectMeta{
Name: s.Name,
Namespace: s.Namespace,
})
if k8serrors.IsNotFound(err) {
warnings = append(warnings, fmt.Sprintf("Secret %s is referred in the spec but not present in the cluster", s.Name))
}
}
result = multierror.Append(result, f.Validate())
}

```

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.

No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.

root signature {packageRefInFuncNs 1} was not found in the callgraph; reference was passed directly to third-party code
```

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

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.