fimugdha opened a new pull request, #1335: URL: https://github.com/apache/ranger/pull/1335
## What changes were proposed in this pull request? Ranger Admin UI doesn't reliably validate the policyType in the policy URLs against what the service definition supports. **Problem :** PolicyFormContext (create-policy route) used a counter to decide whether policyType was valid. It incremented once for each of dataMaskDef and rowFilterDef, then checked +policyType > count. That only works if the supported types are contiguous from 0. For a service def that has only rowFilterDef, the valid types are 0 and 2, but the check treated 0 and 1 as valid. The valid 2 was rejected. PolicyListingTabView (policy listing route, /service/:serviceId/policies/:policyType) had no validation. For example, /service/5/policies/1 on a row-filter-only service showed a blank page and did not redirect. A value like /service/5/policies/6 only reached /pageNotFound through a backend error. **Fix :** Added a shared helper, getSupportedPolicyTypes(serviceDef), in XAUtils.js. It returns Access (0), plus Masking (1) if dataMaskDef is supported and Row Filter (2) if rowFilterDef is supported. PolicyFormContext and PolicyListingTabView now check Number(policyType) against that list and navigate to /pageNotFound if it isn't in it. The create route is validated only when policyType is present in the URL. The edit route (/service/:serviceId/policies/:policyId/edit) has no policyType param and is not affected. ## How was this patch tested? Tested manually with service defs that have access only, masking, row filter, and both. - A supported type loads on the listing and create routes. - An unsupported, out-of-range or non-numeric type, such as 1, 3, 6 or abc, redirects to /pageNotFound. - The edit route and the policy tab navigation still work. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
