Consider adding a rule for net.ErrClosed suggestion [go 1.16]
jimen0 opened this issue · 2 comments
Hi,
Go 1.16 closes an issue that caused many programs to be forced to use substring error matching in order to identify the usage of a closed network connection. The new net.ErrClosed
error allows programs to properly check for this error.
I think this is a rule that fits well in semgrep-go
, perhaps just as a suggestion? Something like this:
severity:error rule:.rules.use-net-errclosed: did you want errors.Is(err, net.ErrClosed) instead?
10: if !strings.Contains(err.Error(), "use of closed network connection") {
What do you think? Would it make sense for you? If you agree, I could try to contribute this rule (still learning how semgrep works) to the repository once Go 1.16 is released.
Best,
Miguel
Self-closing as I just saw https://github.com/dgryski/semgrep-go/blob/master/errclosed.yml. I'm sorry.
👍 Thanks for the suggestion (but yes, I added the rule as soon as I saw the commit land on master).
Please let me know if you have any other rule suggestions. I find thinking about comments from code review a good place for potential checks.