go-jwt-middleware icon indicating copy to clipboard operation
go-jwt-middleware copied to clipboard

Fix panic threat when using type-cast

Open osamingo opened this issue 3 years ago • 4 comments

Description

The threat of panicking should be curbed by receiving a second return value when executing the type-cast.

References

  • CodeReviewComments: https://github.com/golang/go/wiki/CodeReviewComments#dont-panic
  • Effective Go: https://go.dev/doc/effective_go#interface_conversions

Testing

  • [x] This change adds test coverage for new/changed/fixed functionality

Checklist

  • [x] I have read and agreed to the terms within the Auth0 Code of Conduct.
  • [x] I have read the Auth0 General Contribution Guidelines.
  • [x] I have reviewed my own code beforehand.
  • [x] I have added documentation for new/changed functionality in this PR.
  • [x] All active GitHub checks for tests, formatting, and security are passing.
  • [ ] The correct base branch is being used, if not master.

osamingo avatar Aug 04 '22 06:08 osamingo

I would appreciate it if you would approve running GitHub Actions for this PR when you have time.

osamingo avatar Aug 04 '22 07:08 osamingo

@Widcket ping

osamingo avatar Aug 16 '22 10:08 osamingo

@sergiught I fixed it, PTAL.

osamingo avatar Sep 01 '22 10:09 osamingo

Codecov Report

Base: 89.05% // Head: 89.09% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (2bc0d47) compared to base (e9dbfc6). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   89.05%   89.09%   +0.03%     
==========================================
  Files           7        7              
  Lines         274      275       +1     
==========================================
+ Hits          244      245       +1     
  Misses         23       23              
  Partials        7        7              
Impacted Files Coverage Δ
validator/validator.go 88.75% <100.00%> (+0.14%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Sep 01 '22 10:09 codecov-commenter

Hey @osamingo 👋🏻 thanks a lot for the changes and apologies it took so while to get back to you! Would you mind adding a test case for this as well in the validatior_test.go file? 🙏🏻

sergiught avatar Sep 29 '22 09:09 sergiught

Hey @osamingo 👋🏻 I had some time and went ahead and added the test cases missing. Thanks for the contribution again!

sergiught avatar Oct 28 '22 08:10 sergiught