Captain-P-Goldfish / SCIM-SDK

a scim implementation as described in RFC7643 and RFC7644
https://github.com/Captain-P-Goldfish/SCIM/wiki
BSD 3-Clause "New" or "Revised" License
122 stars 38 forks source link

With autoFiltering enabled, invalid compare operator causes Null Pointer Exception #650

Closed prthakre closed 5 months ago

prthakre commented 5 months ago

/scim/v2/Users/?filter=userType eq1 "unknown". Please note the invalid compare operator eq1 in the filter. Exception: Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "filterNode" is null at de.captaingoldfish.scim.sdk.server.filter.resources.FilterResourceResolver.isResourceMatchingFilter(FilterResourceResolver.java:88) at de.captaingoldfish.scim.sdk.server.filter.resources.FilterResourceResolver.isResourceMatchingFilter(FilterResourceResolver.java:112) at de.captaingoldfish.scim.sdk.server.filter.resources.FilterResourceResolver.lambda$getResourcePredicate$1(FilterResourceResolver.java:76) ... de.captaingoldfish.scim.sdk.server.filter.resources.FilterResourceResolver.lambda$filterResources$0(FilterResourceResolver.java:59) at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1456)

Captain-P-Goldfish commented 5 months ago

This seems to be a bug in antlr. The expression is not correctly resolved and everything from eq1 to the end is truncated from the string instead of throwing an InvalidFilterException. I will add a manual check to throw an appropriate error in this case

prthakre commented 5 months ago

Indeed. My bad, I should have shared the filterNode.toString() contents. Thanks a lot for the fix.