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

oysterprotocol/brokernode: jobs/claim_treasure_for_webnode.go; 35 LoC

Open
#16,646 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 [oysterprotocol/brokernode](https://www.github.com/oysterprotocol/brokernode) at [jobs/claim_treasure_for_webnode.go](https://github.com/oysterprotocol/brokernode/blob/c2b050a0e8543a3338db8af7b904b3f07535ba57/jobs/claim_treasure_for_webnode.go#L318-L352)

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/oysterprotocol/brokernode/blob/c2b050a0e8543a3338db8af7b904b3f07535ba57/jobs/claim_treasure_for_webnode.go#L318-L352)

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

```go
for _, completedClaim := range completedClaims {
worthReclaimingGas, gasToReclaim, err := EthWrapper.CheckIfWorthReclaimingGas(
eth_gateway.StringToAddress(completedClaim.TreasureETHAddr), eth_gateway.GasLimitETHSend)
if err != nil {
fmt.Println("Error determining if it's worth it to retrieve leftover ETH from " +
completedClaim.TreasureETHAddr +
" in RetrieveLeftoverETHFromTreasureClaiming() in claim_treasure_for_webnode.")
continue
} else if !worthReclaimingGas {
fmt.Println("Not enough ETH to retrieve leftover ETH from " + completedClaim.TreasureETHAddr +
" in RetrieveLeftoverETHFromTreasureClaiming() in claim_treasure_for_webnode, setting to success")
/* won't be able to reclaim whatever is left, just set to success */
completedClaim.GasStatus = models.GasTransferLeftoversReclaimSuccess
models.DB.ValidateAndUpdate(&completedClaim)
continue
}

privateKey, err := eth_gateway.StringToPrivateKey(completedClaim.DecryptTreasureEthKey())

_, _, _, err = EthWrapper.SendETH(
eth_gateway.StringToAddress(completedClaim.TreasureETHAddr),
privateKey,
eth_gateway.MainWalletAddress,
gasToReclaim)
if err != nil {
fmt.Println("Could not reclaim leftover ETH from " + completedClaim.TreasureETHAddr +
" in RetrieveLeftoverETH in claim_treasure_for_webnode")
} else {
fmt.Println("Reclaiming leftover ETH from " + completedClaim.TreasureETHAddr + " in RetrieveLeftoverETHFromTreasureClaiming " +
"in claim_treasure_for_webnode")
completedClaim.GasStatus = models.GasTransferLeftoversReclaimProcessing
models.DB.ValidateAndUpdate(&completedClaim)
}

}

```

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 {ValidateAndUpdate 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: c2b050a0e8543a3338db8af7b904b3f07535ba57

Contributor guide

No contributing guide indexed for this repository

Research direction

Read jobs/claim_treasure_for_webnode.go around lines 318-352 at commit c2b050a0e8543a3338db8af7b904b3f07535ba57, then inspect the analyzer context for ValidateAndUpdate and the completedClaim range variable. Determine whether the reported pointer or range-loop behavior is a real bug, mitigated, or desirable behavior. Done means leaving the appropriate classification reaction with a rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.