Uploaded image for project: 'Sentry (Retired)'
  1. Sentry (Retired)
  2. SENTRY-1541

toSentryPrivilege() should not copy fields that are not set in the source

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 1.8.0, 2.0.0
    • None
    • Sentry
    • None

    Description

      The SentryStore.toSentryPrivilege() function:

        private TSentryPrivilege toSentryPrivilege(TSentryAuthorizable tAuthorizable)
            throws SentryInvalidInputException {
          TSentryPrivilege tSentryPrivilege = new TSentryPrivilege();
          tSentryPrivilege.setDbName(fromNULLCol(tAuthorizable.getDb()));
          tSentryPrivilege.setServerName(fromNULLCol(tAuthorizable.getServer()));
          tSentryPrivilege.setTableName(fromNULLCol(tAuthorizable.getTable()));
          tSentryPrivilege.setColumnName(fromNULLCol(tAuthorizable.getColumn()));
          tSentryPrivilege.setURI(fromNULLCol(tAuthorizable.getUri()));
          PrivilegeScope scope;
          if (!isNULL(tSentryPrivilege.getColumnName())) {
            scope = PrivilegeScope.COLUMN;
          } else if (!isNULL(tSentryPrivilege.getTableName())) {
            scope = PrivilegeScope.TABLE;
          } else if (!isNULL(tSentryPrivilege.getDbName())) {
            scope = PrivilegeScope.DATABASE;
          } else if (!isNULL(tSentryPrivilege.getURI())) {
            scope = PrivilegeScope.URI;
          } else {
            scope = PrivilegeScope.SERVER;
          }
          tSentryPrivilege.setPrivilegeScope(scope.name());
          tSentryPrivilege.setAction(AccessConstants.ALL);
          return tSentryPrivilege;
        }
      

      Note that it blindly copies all fields from the source, replacing null with empty strings and both itself and other consumers downstream do not know which fields were actually set and which were not. Instead it should just clone fields that were set.

      Attachments

        1. SENTRY-1541.v1.patch
          2 kB
          Vamsee K. Yarlagadda
        2. SENTRY-1541.v2.patch
          4 kB
          Vamsee K. Yarlagadda

        Issue Links

          Activity

            People

              vamsee Vamsee K. Yarlagadda
              akolb Alex Kolbasov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: