From notifications-return-2124-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Oct 3 18:04:47 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id CFD9E18065B for ; Thu, 3 Oct 2019 20:04:46 +0200 (CEST) Received: (qmail 87186 invoked by uid 500); 3 Oct 2019 18:04:46 -0000 Mailing-List: contact notifications-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list notifications@zookeeper.apache.org Received: (qmail 87177 invoked by uid 99); 3 Oct 2019 18:04:46 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Oct 2019 18:04:46 +0000 From: GitBox To: notifications@zookeeper.apache.org Subject: [GitHub] [zookeeper] arshadmohammad commented on a change in pull request #1105: ZOOKEEPER-1260:Audit logging in ZooKeeper servers. Message-ID: <157012588612.17411.7602025671850367350.gitbox@gitbox.apache.org> Date: Thu, 03 Oct 2019 18:04:46 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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