github-vet / github-vet/rangeloop-pointer-findings
hydroscan/hydroscan-api: task/token_stats.go; 15 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [hydroscan/hydroscan-api](https://www.github.com/hydroscan/hydroscan-api) at [task/token_stats.go](https://github.com/hydroscan/hydroscan-api/blob/a8882653a5aaf2dd2f9fa397400c160cef0488b3/task/token_stats.go#L102-L116)
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/hydroscan/hydroscan-api/blob/a8882653a5aaf2dd2f9fa397400c160cef0488b3/task/token_stats.go#L102-L116)
Click here to show the 15 line(s) of Go which triggered the analyzer.
```go
for _, token := range tokens {
result := QueryResult{}
models.DB.Raw("SELECT sum(volume_usd) AS volume1m FROM trades WHERE date > ? AND date <= ? AND (base_token_address = ? OR quote_token_address = ?)",
time1mAgo, timeNow, token.Address, token.Address).Scan(&result)
models.DB.Raw("SELECT sum(volume_usd) AS volume1m_last FROM trades WHERE date > ? AND date <= ? AND (base_token_address = ? OR quote_token_address = ?)",
time2mAgo, time1mAgo, token.Address, token.Address).Scan(&result)
var change float32 = -2
if !result.Volume1mLast.Equal(decimal.NewFromFloat32(0)) {
changeFloat64, _ := result.Volume1m.Sub(result.Volume1mLast).Div(result.Volume1mLast).Float64()
change = float32(changeFloat64)
}
models.DB.Model(&token).Updates(map[string]interface{}{"volume_1m": result.Volume1m, "volume_1m_change": change})
}
```
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 {Model 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: a8882653a5aaf2dd2f9fa397400c160cef0488b3
Contributor guide
No contributing guide indexed for this repository
Research direction
Open task/token_stats.go at lines 102-116 and inspect the range loop, the analyzer output, and surrounding call sites. Decide whether the reported pointer usage is a bug, mitigated, or desirable behavior, then leave the corresponding reaction on this issue. Done means the finding has been classified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100