zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] arshadmohammad commented on a change in pull request #1105: ZOOKEEPER-1260:Audit logging in ZooKeeper servers.
Date Thu, 03 Oct 2019 18:04:46 GMT
arshadmohammad commented on a change in pull request #1105: ZOOKEEPER-1260:Audit logging in
ZooKeeper servers.
URL: https://github.com/apache/zookeeper/pull/1105#discussion_r331176947
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java
 ##########
 @@ -514,4 +555,157 @@ public void shutdown() {
         LOG.info("shutdown of request processor complete");
     }
 
+    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String path)
{
+        addSuccessAudit(request, cnxn, op, path, null, null);
+    }
+
+    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String path,
+        String acl, String createMode) {
+        if (!ZKAuditLogger.isAuditEnabled()) {
+            return;
+        }
+        ZKAuditLogger
+            .logSuccess(request.getUsers(), op, path, acl, createMode, cnxn.getSessionIdHex(),
+                cnxn.getHostAddress());
+    }
+
+    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String path)
{
+        addFailureAudit(request, cnxn, op, path, null, null);
+    }
+
+    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String path,
+        String acl, String createMode) {
+        if (!ZKAuditLogger.isAuditEnabled()) {
+            return;
+        }
+        ZKAuditLogger
+            .logFailure(request.getUsers(), op, path, acl, createMode, cnxn.getSessionIdHex(),
+                cnxn.getHostAddress());
+    }
+
+    private void addAuditLog(Request request, ServerCnxn cnxn, String op, String path, String
acl,
+        String createMode, Code err) {
+        if (!ZKAuditLogger.isAuditEnabled()) {
+            return;
+        }
+        if (err == Code.OK) {
+            ZKAuditLogger
+                .logSuccess(request.getUsers(), op, path, acl, createMode, cnxn.getSessionIdHex(),
+                    cnxn.getHostAddress());
+        } else {
+            ZKAuditLogger
+                .logFailure(request.getUsers(), op, path, acl, createMode, cnxn.getSessionIdHex(),
+                    cnxn.getHostAddress());
+        }
+    }
+
+    private String getACLs(Request request) {
+        ByteBuffer reqData = request.request.duplicate();
+        reqData.rewind();
+        SetACLRequest setACLRequest = new SetACLRequest();
+        try {
+            ByteBufferInputStream.byteBuffer2Record(reqData, setACLRequest);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return ZKUtil.aclToString(setACLRequest.getAcl());
+    }
+
+    private void addFailedTxnAuditLog(Request request) {
+        if (!ZKAuditLogger.isAuditEnabled()) {
+            return;
+        }
+        String op = AuditConstants.OP_CREATE;
+        String path = null;
+        long sessionId = -1;
+        String address = null;
+        String acls = null;
+        String createMode = null;
+        ByteBuffer reqData = request.request.duplicate();
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message