zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-1260) Audit logging in ZooKeeper servers.
Date Mon, 23 Apr 2018 15:30:01 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-1260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16448311#comment-16448311
] 

ASF GitHub Bot commented on ZOOKEEPER-1260:
-------------------------------------------

Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/338#discussion_r183435384
  
    --- Diff: src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java ---
    @@ -465,6 +488,127 @@ public void processRequest(Request request) {
             }
         }
     
    +    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String
path) {
    +        addSuccessAudit(request, cnxn, op, path, null);
    +    }
    +
    +    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String
path,
    +            String acl) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        ZKAuditLogger.logSuccess(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                cnxn.getHostAddress());
    +    }
    +
    +    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String
path) {
    +        addFailureAudit(request, cnxn, op, path, null);
    +    }
    +
    +    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String
path,
    +            String acl) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        ZKAuditLogger.logFailure(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                cnxn.getHostAddress());
    +    }
    +
    +    private void addAuditLog(Request request, ServerCnxn cnxn, String op, String path,
String acl,
    +            Code err) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        if (err == Code.OK) {
    +            ZKAuditLogger.logSuccess(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                    cnxn.getHostAddress());
    +        } else {
    +            ZKAuditLogger.logFailure(request.getUsers(), op, path, acl, 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 addFailedTxnAduitLog(Request request) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        String op = AuditConstants.OP_CREATE;
    +        String path=null;
    +        long sessionId = -1;
    +        String address = null;
    +        String acls = null;
    +        ByteBuffer reqData = request.request.duplicate();
    +        reqData.rewind();
    +        try {
    +            sessionId = request.cnxn.getSessionId();
    +            switch (request.type) {
    +            case OpCode.create:
    +            case  OpCode.create2:
    +            case  OpCode.createContainer:
    +                op = AuditConstants.OP_CREATE;
    +                CreateRequest createRequest = new CreateRequest();
    +                ByteBufferInputStream.byteBuffer2Record(reqData, createRequest);
    +                path=createRequest.getPath();
    +                break;
    +            case OpCode.delete:
    +            case OpCode.deleteContainer:
    +                op = AuditConstants.OP_DELETE;
    +                //path = new String(request.request.array());
    --- End diff --
    
    Please the commented line.


> Audit logging in ZooKeeper servers.
> -----------------------------------
>
>                 Key: ZOOKEEPER-1260
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1260
>             Project: ZooKeeper
>          Issue Type: New Feature
>          Components: server
>            Reporter: Mahadev konar
>            Assignee: Mohammad Arshad
>            Priority: Major
>             Fix For: 3.5.4, 3.6.0
>
>         Attachments: ZOOKEEPER-1260-01.patch, zookeeperAuditLogs.pdf
>
>
> Lots of users have had questions on debugging which client changed what znode and what
updates went through a znode. We should add audit logging as in Hadoop (look at Namenode Audit
logging) to log which client changed what in the zookeeper servers. This could just be a log4j
audit logger.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message