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

ProfessorBeekums/PbStockResearcher: PbStockParser.go; 45 LoC

Open
#16,714 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 [ProfessorBeekums/PbStockResearcher](https://www.github.com/ProfessorBeekums/PbStockResearcher) at [PbStockParser.go](https://github.com/ProfessorBeekums/PbStockResearcher/blob/13330ff7170f214b640e5b051b8d80de653f1a77/PbStockParser.go#L53-L97)

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 64 passes reference to reportFile to third-party code

[Click here to see the code in its original context.](https://github.com/ProfessorBeekums/PbStockResearcher/blob/13330ff7170f214b640e5b051b8d80de653f1a77/PbStockParser.go#L53-L97)

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

```go
for _, reportFile := range *unparsedFiles {
if reportFile.CIK == 0 {
return
}
filePath := reportFile.Filepath
if !strings.Contains(filePath, "10-Q") &&
!strings.Contains(filePath, "10-K") &&
!strings.Contains(filePath, "10-K_A") &&
!strings.Contains(filePath, "10-Q_A") {
reportFile.Parsed = true

mysqlPersister.InsertUpdateReportFile(&reportFile)
continue
}

rawReport := &filings.FinancialReportRaw{CIK: reportFile.CIK, Year: reportFile.Year, Quarter: reportFile.Quarter}
// TODO this is not optimal
rawReport.RawFields = make(map[string]int64)

frp := parser.NewFinancialReportParser(reportFile.Filepath,
rawReport, mysqlPersister, &filings.BasicRawFieldNameList{})

frp.Parse()

fr := frp.GetFinancialReport()

frValid := fr.IsValid()

if frValid == nil {
log.Println("Parsed report for CIK <", fr.CIK, "> year <", fr.Year, "> quarter <", fr.Quarter, ">")
mysqlPersister.InsertUpdateFinancialReport(fr)
numValid++
} else {
log.Error("Invalid financial report <", reportFile, "> with error: ", frValid)
reportFile.ParseError = true

// TODO temporary while I figure out what my parsing code is missing
//break
numInvalid++
}

reportFile.Parsed = true

mysqlPersister.InsertUpdateReportFile(&reportFile)
}

```

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 {
"(InsertUpdateReportFile, 1)" -> {}
}

```

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: 13330ff7170f214b640e5b051b8d80de653f1a77

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect PbStockParser.go lines 53-97 in the referenced commit, focusing on the range loop and calls to InsertUpdateReportFile. Determine whether passing the loop variable by reference creates a real bug, then classify the finding as Bug, Mitigated, or Desirable Behavior using the linked project guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.