knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-390 - Include client IP and HTTP verb in audit log
Date Mon, 01 May 2017 19:09:31 GMT
Repository: knox
Updated Branches:
  refs/heads/master 22f0af4de -> 3dc4efb8f


KNOX-390 - Include client IP and HTTP verb in audit log

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/3dc4efb8
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/3dc4efb8
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/3dc4efb8

Branch: refs/heads/master
Commit: 3dc4efb8febe9cfdf1e4baf5331c6904bc44f93a
Parents: 22f0af4
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Mon May 1 15:08:09 2017 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Mon May 1 15:08:09 2017 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/audit/log4j/layout/AuditLayout.java    |  1 +
 .../org/apache/hadoop/gateway/audit/AuditLayoutTest.java  | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/3dc4efb8/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java
b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java
index 09f827c..42ffcf6 100644
--- a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/audit/log4j/layout/AuditLayout.java
@@ -50,6 +50,7 @@ public class AuditLayout extends DateLayout {
     appendParameter( cc == null ? null : cc.getParentRequestId() );
     appendParameter( cc == null ? null : cc.getRequestId() );
     appendParameter( event.getLoggerName() );
+    appendParameter( ac == null ? null : ac.getRemoteIp() );
     appendParameter( ac == null ? null : ac.getTargetServiceName() );
     appendParameter( ac == null ? null : ac.getUsername() );
     appendParameter( ac == null ? null : ac.getProxyUsername() );

http://git-wip-us.apache.org/repos/asf/knox/blob/3dc4efb8/gateway-util-common/src/test/java/org/apache/hadoop/gateway/audit/AuditLayoutTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/test/java/org/apache/hadoop/gateway/audit/AuditLayoutTest.java
b/gateway-util-common/src/test/java/org/apache/hadoop/gateway/audit/AuditLayoutTest.java
index a58ef59..dde1fa8 100644
--- a/gateway-util-common/src/test/java/org/apache/hadoop/gateway/audit/AuditLayoutTest.java
+++ b/gateway-util-common/src/test/java/org/apache/hadoop/gateway/audit/AuditLayoutTest.java
@@ -62,7 +62,7 @@ public class AuditLayoutTest {
   private static final String PARENT_REQUEST_ID = "2";
   private static final String REQUEST_ID = "3";
   private static final String EMPTY = "";
-  private static final String RECORD_PATTERN = "%s %s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s%s";
+  private static final String RECORD_PATTERN = "%s %s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s%s";
 
   static {
     layout.activateOptions();
@@ -111,11 +111,11 @@ public class AuditLayoutTest {
     LoggingEvent event = CollectAppender.queue.iterator().next();
     SimpleDateFormat format = new SimpleDateFormat( "yy/MM/dd HH:mm:ss" );
     String formatedDate = format.format( new Date( event.getTimeStamp() ) );
-    //14/01/24 12:40:24 1|2|3|audit.forward|WEBHDFS|username|proxy_username|system_username|action|resource_type|resource_name|outcome|message
+    //14/01/24 12:40:24 1|2|3|audit.forward|hostaddress|WEBHDFS|username|proxy_username|system_username|action|resource_type|resource_name|outcome|message
     String expectedOutput = String.format(
         RECORD_PATTERN, formatedDate,
         ROOT_REQUEST_ID, PARENT_REQUEST_ID, REQUEST_ID, "audit.forward",
-        TARGET_SERVICE, USERNAME, PROXYUSERNAME, SYSTEMUSERNAME, ACTION,
+        HOST_ADDRESS, TARGET_SERVICE, USERNAME, PROXYUSERNAME, SYSTEMUSERNAME, ACTION,
         RESOURCE_TYPE, RESOURCE_NAME, OUTCOME, MESSAGE, AuditLayout.LINE_SEP );
     String auditOutput = layout.format( event );
     assertThat( auditOutput, is( expectedOutput ) );
@@ -132,7 +132,7 @@ public class AuditLayoutTest {
     //14/01/24 12:41:47 |||audit.forward|||||action|resource_type|resource_name|outcome|message
     String expectedOutput = String.format( RECORD_PATTERN, formatedDate,
         EMPTY, EMPTY, EMPTY, "audit.forward",
-        EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME, MESSAGE,
AuditLayout.LINE_SEP );
+        EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME,
MESSAGE, AuditLayout.LINE_SEP );
     String auditOutput = layout.format( event );
     assertThat( auditOutput, is( expectedOutput ) );
     
@@ -148,7 +148,7 @@ public class AuditLayoutTest {
     //14/01/24 12:41:47 |||audit.forward|||||action|resource_type|resource_name|outcome|
     String expectedOutput = String.format( RECORD_PATTERN, formatedDate,
         EMPTY, EMPTY, EMPTY, "audit.forward",
-        EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME, EMPTY,
AuditLayout.LINE_SEP );
+        EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, ACTION, RESOURCE_TYPE, RESOURCE_NAME, OUTCOME,
EMPTY, AuditLayout.LINE_SEP );
     String auditOutput = layout.format( event );
     assertThat( auditOutput, is( expectedOutput ) );
   }


Mime
View raw message