Description
Recently AmazonCloudWatch support was added to the audit module in this commit.
However, this commit also changed the toDate method of ElasticSearchAccessAuditsService.java because of which the event time on the Audit screen is showing the wrong date from 1970. The error stack is as follows:
2022-05-08 07:04:22,887 [http-nio-6080-exec-6] ERROR [MiscUtil.java:938] Error converting value to date. Value = 2022-05-08T06:42:01.621Z java.lang.IllegalArgumentException: null at java.base/java.util.Date.parse(Date.java:616) at java.base/java.util.Date.<init>(Date.java:274) at org.apache.ranger.audit.provider.MiscUtil.toDate(MiscUtil.java:936) at org.apache.ranger.elasticsearch.ElasticSearchAccessAuditsService.populateViewBean(ElasticSearchAccessAuditsService.java:260) at org.apache.ranger.elasticsearch.ElasticSearchAccessAuditsService.searchXAccessAudits(ElasticSearchAccessAuditsService.java:95) at org.apache.ranger.biz.AssetMgr.getAccessLogs(AssetMgr.java:1139) at org.apache.ranger.rest.AssetREST.getAccessLogs(AssetREST.java:672) at org.apache.ranger.rest.AssetREST$$FastClassBySpringCGLIB$$8cffcb6d.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
The screenshot shows the erroneous date on ranger-admin
Please refer: https://github.com/apache/ranger/commit/71744d3ff8e0db7f0a49881a891e77edf0ea518d#r73132360