Uploaded image for project: 'Sentry'
  1. Sentry
  2. SENTRY-2141

Sentry Privilege TimeStamp is not converted to grantTime in HivePrivilegeInfo correctly

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0, 2.1.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      since hive is using second as time unit and the variable holding the time is "int", sentry should convert the time from millisecond to second and cast to int. Previous code just cast the long value as time in milliseconds to int as time in seconds, which runs into overflows (because a Long can store a wider range than an Integer), and changes the meaning of the value.

      Correct behavior:

      
      int hiveCreateTime = (int)TimeUnit.SECONDS.convert(tPrivilege.getCreateTime(),
      TimeUnit.MILLISECONDS);
      
      return new HivePrivilegeInfo(principal, hivePrivilege, hivePrivilegeObject, grantor,
      grantOption, hiveCreateTime);
      

      Wrong behavior:

      (int) tPrivilege.getCreateTime()
      

      The original code just cast the timestamp from long to int without converting milliseconds to seconds. Therefore, the timestamp value is wrong when retrieving the privilege from hive.

      The solution is to convert the time correctly.

        Attachments

        1. SENTRY-2141.003.patch
          2 kB
          Na Li
        2. SENTRY-2141.002.patch
          2 kB
          Na Li
        3. SENTRY-2141.001.patch
          1 kB
          Na Li

          Issue Links

            Activity

              People

              • Assignee:
                LinaAtAustin Na Li
                Reporter:
                LinaAtAustin Na Li
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: