[
https://issues.apache.org/jira/browse/SENTRY-563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14237615#comment-14237615
]
Xiaomeng Huang commented on SENTRY-563:
---------------------------------------
Hi [~lskuff]
We certainly can fix it in "setupSentryAuthorizable" via add below:
{code}
public static TSentryAuthorizable setupSentryAuthorizable(
List<? extends Authorizable> authorizable) {
+ if (authorizable == null || authorizable.isEmpty()) {
+ return null;
+ }
...
{code}
But I think we'd better add a empty check in listPrivilegesByRoleName. The
meaning of this interface is that if we have no authorizable(both null and
empty), request.authorizableHierarchy should be null. Otherwise, we should do
"setupSentryAuthorizable" to set request.authorizableHierarchy.
Before this patch, if authorizable is empty, it will also do
setupSentryAuthorizable, than request.authorizableHierarchy will be
{server:null}, but server couldn't be null in TSentryAuthorizable, so it will
throw thrift exception.
> The interface listPrivilegesByRoleName may throw thrift exception if
> Authorizable is empty
> ------------------------------------------------------------------------------------------
>
> Key: SENTRY-563
> URL: https://issues.apache.org/jira/browse/SENTRY-563
> Project: Sentry
> Issue Type: Bug
> Reporter: Xiaomeng Huang
> Assignee: Xiaomeng Huang
> Attachments: SENTRY-563.001.patch
>
>
> {code}
> public Set<TSentryPrivilege> listPrivilegesByRoleName(String
> requestorUserName,
> String roleName, List<? extends Authorizable> authorizable)
> throws SentryUserException {
> TListSentryPrivilegesRequest request = new TListSentryPrivilegesRequest();
>
> request.setProtocol_version(ThriftConstants.TSENTRY_SERVICE_VERSION_CURRENT);
> request.setRequestorUserName(requestorUserName);
> request.setRoleName(roleName);
> if (authorizable != null) { ==> we should add check empty of
> authorizable here.
> TSentryAuthorizable tSentryAuthorizable =
> setupSentryAuthorizable(authorizable);
> request.setAuthorizableHierarchy(tSentryAuthorizable);
> }
> ...
> {code}
> Please see my test cases in this patch, before this patch, it will throw
> exception.
> Sentry client interface should be robustness, it also blocks SHOW GRANT DDL
> of V2 feature.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)