Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a rule for net.ErrClosed suggestion [go 1.16] #14

Closed
jimen0 opened this issue Oct 18, 2020 · 2 comments
Closed

Consider adding a rule for net.ErrClosed suggestion [go 1.16] #14

jimen0 opened this issue Oct 18, 2020 · 2 comments

Comments

@jimen0
Copy link

jimen0 commented Oct 18, 2020

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

@jimen0
Copy link
Author

jimen0 commented Oct 18, 2020

Self-closing as I just saw https://github.com/dgryski/semgrep-go/blob/master/errclosed.yml. I'm sorry.

@jimen0 jimen0 closed this as completed Oct 18, 2020
@dgryski
Copy link
Owner

dgryski commented Oct 18, 2020

👍 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants