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

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

Open
#16,654 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#L140-L162)

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#L140-L162)

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

```go
for _, pending := range gasReclaimPending {
ethBalance := EthWrapper.CheckETHBalance(eth_gateway.StringToAddress(pending.TreasureETHAddr))
if ethBalance.Int64() > 0 {
gasNeededToReclaimETH, err := EthWrapper.CalculateGasNeeded(eth_gateway.GasLimitETHSend)
if err != nil {
fmt.Println("Could not calculate gas needed to retrieve ETH from " + pending.TreasureETHAddr +
" in CheckProcessingGasReclaims() in claim_treasure_for_webnode")
continue
}
if gasNeededToReclaimETH.Int64() > ethBalance.Int64() {
fmt.Println("Not enough ETH to retrieve leftover ETH from " + pending.TreasureETHAddr +
" in CheckOngoingGasReclaims() in claim_treasure_for_webnode, setting to success")
/* won't be able to reclaim whatever is left, just set to success */
pending.GasStatus = models.GasTransferLeftoversReclaimSuccess
models.DB.ValidateAndUpdate(&pending)
}
} else {
fmt.Println("Finished reclaiming gas from " + pending.TreasureETHAddr + " in CheckOngoingGasReclaims() " +
"in claim_treasure_for_webnode")
pending.GasStatus = models.GasTransferLeftoversReclaimSuccess
models.DB.ValidateAndUpdate(&pending)
}
}

```

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

Start with jobs/claim_treasure_for_webnode.go at lines 140-162 in commit c2b050a0e8543a3338db8af7b904b3f07535ba57. Inspect the range-loop variable pending and its use in models.DB.ValidateAndUpdate, then determine whether the analyzer finding is a bug, mitigated, or desirable behavior. Done means leaving the corresponding reaction classification.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
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.