oidc icon indicating copy to clipboard operation
oidc copied to clipboard

fix: nil pointer dereference on UserInfoAddress

Open muhlemmer opened this issue 3 years ago • 2 comments

When the Address field in userinfo is nil, an empty instance of userInfoAddress is now returned. This allows for safe chaining of Get methods. All of an empty userInfoAddress' Get methods will return empty strings.

Fixes #203

muhlemmer avatar Aug 22 '22 10:08 muhlemmer

Codecov Report

Merging #207 (9b63a93) into main (1535ea4) will increase coverage by 0.08%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
+ Coverage   39.49%   39.58%   +0.08%     
==========================================
  Files          74       74              
  Lines        5907     5912       +5     
==========================================
+ Hits         2333     2340       +7     
+ Misses       3323     3321       -2     
  Partials      251      251              
Impacted Files Coverage Δ
pkg/oidc/userinfo.go 53.65% <100.00%> (+2.71%) :arrow_up:

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

codecov[bot] avatar Aug 22 '22 10:08 codecov[bot]

I've updated this PR to catch the nil in userinfo.UnmarshalJSON and set a new empty value to the userinfo.Address field. The original change in userinfo.GetAddress() is reverted. And the tests now use actual json.

muhlemmer avatar Sep 16 '22 12:09 muhlemmer

@livio-a I've rebased, because the test were failing with my old branch. Comments are resolved.

muhlemmer avatar Feb 03 '23 08:02 muhlemmer