sonatype-lift[bot] commented on code in PR #890: URL: https://github.com/apache/solr/pull/890#discussion_r888018935
########## solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java: ########## @@ -595,7 +595,20 @@ protected JWTAuthenticationResponse authenticate(String authorizationHeader) { } else { // Pull roles from separate claim, either as whitespace separated list or as JSON // array - Object rolesObj = jwtClaims.getClaimValue(rolesClaim); + Object rolesObj = null; + if (rolesClaim.contains(".")) { + // support map resolution of nested values + String[] nestedKeys = rolesClaim.split("\\."); Review Comment: *[StringSplitter](https://errorprone.info/bugpattern/StringSplitter):* String.split(String) has surprising behavior ```suggestion List<String> nestedKeys = Splitter.on('.').splitToList(rolesClaim); ``` (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`) --- Was this a good recommendation? [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=260914170&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=260914170&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260914170&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260914170&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=260914170&lift_comment_rating=5) ] ########## solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java: ########## @@ -595,7 +595,20 @@ protected JWTAuthenticationResponse authenticate(String authorizationHeader) { } else { // Pull roles from separate claim, either as whitespace separated list or as JSON // array - Object rolesObj = jwtClaims.getClaimValue(rolesClaim); + Object rolesObj = null; + if (rolesClaim.contains(".")) { + // support map resolution of nested values + String[] nestedKeys = rolesClaim.split("\\."); + Map<?, ?> entry = (Map) jwtClaims.getClaimValue(nestedKeys[0]); + for (int i = 1; i < nestedKeys.length - 1; i++) { + String key = nestedKeys[i]; + entry = (Map) entry.get(key); + } + rolesObj = entry.get(nestedKeys[nestedKeys.length - 1]); Review Comment: *NULL_DEREFERENCE:* object `entry` last assigned on line 602 could be null and is dereferenced at line 607. (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`) --- Was this a good recommendation? [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=260915360&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=260915360&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260915360&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260915360&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=260915360&lift_comment_rating=5) ] ########## solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTAuthPlugin.java: ########## @@ -595,7 +595,20 @@ protected JWTAuthenticationResponse authenticate(String authorizationHeader) { } else { // Pull roles from separate claim, either as whitespace separated list or as JSON // array - Object rolesObj = jwtClaims.getClaimValue(rolesClaim); + Object rolesObj = null; + if (rolesClaim.contains(".")) { + // support map resolution of nested values + String[] nestedKeys = rolesClaim.split("\\."); + Map<?, ?> entry = (Map) jwtClaims.getClaimValue(nestedKeys[0]); + for (int i = 1; i < nestedKeys.length - 1; i++) { + String key = nestedKeys[i]; + entry = (Map) entry.get(key); Review Comment: *NULL_DEREFERENCE:* object `entry` last assigned on line 602 could be null and is dereferenced at line 605. (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`) --- Was this a good recommendation? [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=260916139&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=260916139&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260916139&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=260916139&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=260916139&lift_comment_rating=5) ] -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org