github-vet / github-vet/rangeloop-pointer-findings
oysterprotocol/brokernode: jobs/claim_unused_prls.go; 34 LoC
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 0
- Forks
- 0
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne in jobs/claim_unused_prls.go etwa bei den Zeilen 359–392 und untersuche die Range-Schleife, insbesondere den an models.DB.ValidateAndUpdate übergebenen Pointer. Verfolge, ob dieser Pointer über die Iteration hinaus aufbewahrt oder verwendet wird, überprüfe anschließend das Verhalten des umgebenden Jobs und bestimme, ob der Befund ein Bug, mitigiert oder ein erwünschtes Verhalten ist. Erfasse die entsprechende Klassifizierung, sobald die Lebensdauer des Pointers festgestellt wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- go
- Bereich
- backend, blockchain
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100