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

karthikpanicker/automatictactoe: etsy_synchronizer.go; 42 LoC

Open
#18,134 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 [karthikpanicker/automatictactoe](https://www.github.com/karthikpanicker/automatictactoe) at [etsy_synchronizer.go](https://github.com/karthikpanicker/automatictactoe/blob/5f0882b457ed5191a76074fc8d8ce96516201ff2/etsy_synchronizer.go#L28-L69)

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.

> function call at line 58 passes reference to userDetails to third-party code

[Click here to see the code in its original context.](https://github.com/karthikpanicker/automatictactoe/blob/5f0882b457ed5191a76074fc8d8ce96516201ff2/etsy_synchronizer.go#L28-L69)

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

```go
for _, userDetails := range userList {
//Need to fetch transactions for the user only if he has linked any of the apps
if userDetails.TrelloDetails.IsLinked == false &&
userDetails.GTasksDetails.IsLinked == false &&
userDetails.TodoistDetails.IsLinked == false {
continue
}
response, err := edm.GetAppData(&userDetails, apps.EtsyTransactionListRequest, nil)
if err != nil {
common.Error(err)
continue
}
//
orderList := response.(*common.EtsyTransactionResponse)
sort.Slice(orderList.Results[:], func(i, j int) bool {
return orderList.Results[i].PaidTime < orderList.Results[j].PaidTime
})
for i := 0; i < len(orderList.Results); i++ {
etsyTransaction := orderList.Results[i]
if etsyTransaction.ShippedTime == 0 {
reqParamsMap := make(map[string]interface{})
reqParamsMap[apps.EtsyReceiptIdKey] = strconv.Itoa(etsyTransaction.ReceiptID)
response, _ := edm.GetAppData(&userDetails, apps.EtsyReceiptDetailsRequest, reqParamsMap)
receiptDetails := response.(*common.EtsyReceiptDetails)
time.Sleep(time.Second * 1)
var lastTransactionIndex = 0
if i > 0 {
lastTransactionIndex = i - 1
}
if userDetails.TrelloDetails.IsLinked {
es.postTransactionToTrello(edm, etsyTransaction, &userDetails, receiptDetails, orderList.Results[lastTransactionIndex])
}
if userDetails.GTasksDetails.IsLinked {
es.postTransactionToGTasks(etsyTransaction, &userDetails, receiptDetails)
}
if userDetails.TodoistDetails.IsLinked {
es.postTransactionToTodoist(etsyTransaction, &userDetails, receiptDetails)
}
}
}
es.dCache.SaveDetailsToCache(userDetails.UserID, userDetails)
}

```

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.

The following graphviz dot graph describes paths through the callgraph that could lead to a function which passes a pointer to third-party code:
digraph G {
"(postTransactionToTrello, 5)" -> {"(GetAppData, 3)";}
"(GetAppData, 3)" -> {"(getBoardLists, 2)";}
"(getBoardLists, 2)" -> {}
}

```

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: 5f0882b457ed5191a76074fc8d8ce96516201ff2

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with etsy_synchronizer.go lines 28-69 and trace the mentioned calls through postTransactionToTrello, GetAppData, and getBoardLists. Determine whether passing the range-loop variable pointer can cause an issue in third-party code, then classify the finding as Bug, Mitigated, or Desirable Behavior as described in the issue.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.