فهرست منبع

[core] Audit DELETE_USER operations in process_view before we delete the actual user records

Jenny Kim 10 سال پیش
والد
کامیت
21e5eb6
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      desktop/core/src/desktop/middleware.py

+ 5 - 3
desktop/core/src/desktop/middleware.py

@@ -361,6 +361,8 @@ class AuditLoggingMiddleware(object):
     '/useradmin/groups/edit/(?P<name>%s)' % (groupname_re,): 'EDIT_GROUP'
   }
 
+  process_view_operations = ('USER_LOGOUT', 'DELETE_USER')
+
   def __init__(self):
     from desktop.conf import AUDIT_EVENT_LOG_DIR, SERVER_USER
 
@@ -373,7 +375,7 @@ class AuditLoggingMiddleware(object):
   def process_view(self, request, view_func, view_args, view_kwargs):
     try:
       operation = self._get_operation(request.path)
-      if operation == 'USER_LOGOUT':
+      if operation in self.process_view_operations:
         self._log_message(operation, request)
     except Exception, e:
       LOG.error('Could not audit the request: %s' % e)
@@ -384,7 +386,7 @@ class AuditLoggingMiddleware(object):
     response['audited'] = False
     try:
       operation = self._get_operation(request.path)
-      if request.method == 'POST' and operation and operation != 'USER_LOGOUT':
+      if request.method == 'POST' and operation not in self.process_view_operations:
         self._log_message(operation, request, response)
         response['audited'] = True
     except Exception, e:
@@ -448,7 +450,7 @@ class AuditLoggingMiddleware(object):
         if pattern.match(url):
           return operation
 
-    return None
+    return ''
 
   def _get_operation_text(self, operation, request):
     if request.method == 'POST':