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

Sentry Privilege TimeStamp is not converted to grantTime in HivePrivilegeInfo correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.1.0
    • 2.2.0
    • None
    • 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.001.patch
          1 kB
          Na Li
        2. SENTRY-2141.002.patch
          2 kB
          Na Li
        3. SENTRY-2141.003.patch
          2 kB
          Na Li

        Issue Links

          Activity

            People

              linaataustin Na Li
              linaataustin Na Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: