github-vet / github-vet/rangeloop-pointer-findings
jessfraz/netscan: pkg/scanner/scanner.go; 24 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [jessfraz/netscan](https://www.github.com/jessfraz/netscan) at [pkg/scanner/scanner.go](https://github.com/jessfraz/netscan/blob/b4572329b98932e441bf759e165e0d703defa3b1/pkg/scanner/scanner.go#L107-L130)
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.
> range-loop variable port used in defer or goroutine at line 123
[Click here to see the code in its original context.](https://github.com/jessfraz/netscan/blob/b4572329b98932e441bf759e165e0d703defa3b1/pkg/scanner/scanner.go#L107-L130)
Click here to show the 24 line(s) of Go which triggered the analyzer.
```go
for _, port := range s.ports {
for _, proto := range s.protocols {
addr := fmt.Sprintf("%s:%d", ip, port)
wg.Add(1)
go func(proto, addr string) {
defer wg.Done()
guard <- struct{}{}
c, err := net.DialTimeout(proto, addr, s.timeout)
<-guard
if err == nil {
c.Close()
resultsMutex.Lock()
results = append(results, AddressSet{
IP: copyIP(ip),
Port: port,
Protocol: proto,
})
resultsMutex.Unlock()
}
}(proto, addr)
}
}
```
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: b4572329b98932e441bf759e165e0d703defa3b1
Contributor guide
No contributing guide indexed for this repository
Research direction
Read pkg/scanner/scanner.go at lines 107-130 and inspect the referenced commit. Check how the goroutine uses the range-loop variable port and whether the analyzer finding is valid, then leave the appropriate Bug, Mitigated, or Desirable Behavior reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100