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

oysterprotocol/brokernode: jobs/claim_unused_prls.go; 34 LoC

Aperta
#16,653 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
fresh small
Lingua principale
Nessun dato sulla lingua
Stelle
0
Fork
0
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Found a possible issue in [oysterprotocol/brokernode](https://www.github.com/oysterprotocol/brokernode) at [jobs/claim_unused_prls.go](https://github.com/oysterprotocol/brokernode/blob/c2b050a0e8543a3338db8af7b904b3f07535ba57/jobs/claim_unused_prls.go#L359-L392)

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_unused_prls.go#L359-L392)

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

```go
for _, upload := range uploadsWithUnclaimedPRLs {
balance := EthWrapper.CheckPRLBalance(eth_gateway.StringToAddress(upload.ETHAddr))
if balance.Int64() == -1 {
fmt.Println("Error getting balance of address " + upload.ETHAddr)
continue
}

privateKey := upload.DecryptSessionEthKey()

ecdsaPrivateKey, err := eth_gateway.StringToPrivateKey(privateKey)

if err != nil {
oyster_utils.LogIfError(err, nil)
continue
}
callMsg, err := EthWrapper.CreateSendPRLMessage(eth_gateway.StringToAddress(upload.ETHAddr),
ecdsaPrivateKey, eth_gateway.MainWalletAddress, *balance)

if err != nil {
oyster_utils.LogIfError(err, nil)
continue
}
sendSuccess, txHash, nonce := EthWrapper.SendPRLFromOyster(callMsg)
if sendSuccess {
fmt.Println("InitiatePRLClaim processing from " + upload.ETHAddr + " claim_unused_prls")
upload.PRLStatus = models.PRLClaimProcessing
upload.PRLTxHash = txHash
upload.PRLTxNonce = nonce
models.DB.ValidateAndUpdate(&upload)
} else {
err := errors.New("error claiming unused prls from addresss: " + upload.ETHAddr)
oyster_utils.LogIfError(err, nil)
}
}

```

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in jobs/claim_unused_prls.go intorno alle righe 359-392 e analizza il ciclo range, in particolare il puntatore passato a models.DB.ValidateAndUpdate. Verifica se quel puntatore viene conservato o utilizzato oltre l’iterazione, quindi esamina il comportamento del job circostante e determina se il rilievo è un bug, è mitigato oppure è un comportamento desiderabile. Registra la classificazione appropriata una volta stabilita la durata del puntatore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
backend, blockchain
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.