ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/2] git commit: ARGUS-91: updated audit logs written to HDFS with additional fields (agentHostname, logType, eventId).
Date Wed, 01 Oct 2014 02:36:35 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 24526c6ec -> db6acff81


ARGUS-91: updated audit logs written to HDFS with additional fields
(agentHostname, logType, eventId).

Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/85d672f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/85d672f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/85d672f3

Branch: refs/heads/master
Commit: 85d672f3077eb08fc0e4f10bce04eb46d31d6f0d
Parents: cc6c439
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Tue Sep 30 19:12:55 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Tue Sep 30 19:12:55 2014 -0700

----------------------------------------------------------------------
 .../xasecure/audit/model/AuditEventBase.java    | 63 +++++++++++++++-----
 .../audit/provider/BufferedAuditProvider.java   | 12 ++++
 .../com/xasecure/audit/provider/MiscUtil.java   | 10 +++-
 3 files changed, 66 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/85d672f3/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java b/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
index df0f42f..4fd56be 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
@@ -20,6 +20,7 @@
  package com.xasecure.audit.model;
 
 import java.util.Date;
+import java.util.UUID;
 
 import com.xasecure.audit.dao.DaoManager;
 
@@ -32,20 +33,23 @@ public abstract class AuditEventBase {
 	protected static final int MAX_REQUEST_DATA_FIELD_SIZE = 1800 ;
 
 	
-	protected String agentId;
-	protected String user;
-	protected Date   eventTime = new Date();
-	protected long   policyId;
-	protected String accessType;
-	protected short  accessResult; // 0 - DENIED; 1 - ALLOWED; HTTP return code 
-	protected String resultReason;
-	protected String aclEnforcer;
-	protected int repositoryType;
-	protected String repositoryName;
-	protected String sessionId;
-	protected String clientType;
-	protected String clientIP;
-	protected String action;
+	protected String agentId        = null;
+	protected String user           = null;
+	protected Date   eventTime      = new Date();
+	protected long   policyId       = 0;
+	protected String accessType     = null;
+	protected short  accessResult   = 0; // 0 - DENIED; 1 - ALLOWED; HTTP return code 
+	protected String resultReason   = null;
+	protected String aclEnforcer    = null;
+	protected int    repositoryType = 0;
+	protected String repositoryName = null;
+	protected String sessionId      = null;
+	protected String clientType     = null;
+	protected String clientIP       = null;
+	protected String action         = null;
+	protected String agentHostname  = null;
+	protected String logType        = null;
+	protected String eventId        = null;
 
 	protected AuditEventBase() {
 	}
@@ -276,6 +280,30 @@ public abstract class AuditEventBase {
 		this.action = action;
 	}
 
+	public String getAgentHostname() {
+		return agentHostname;
+	}
+
+	public void setAgentHostname(String agentHostname) {
+		this.agentHostname = agentHostname;
+	}
+
+	public String getLogType() {
+		return logType;
+	}
+
+	public void setLogType(String logType) {
+		this.logType = logType;
+	}
+
+	public String getEventId() {
+		return eventId;
+	}
+
+	public void setEventId(String eventId) {
+		this.eventId = eventId;
+	}
+
 	public abstract void persist(DaoManager daoManager);
 
 	@Override
@@ -297,8 +325,11 @@ public abstract class AuditEventBase {
 		  .append("sessionId=").append(sessionId).append(FIELD_SEPARATOR)
 		  .append("clientType=").append(clientType).append(FIELD_SEPARATOR)
 		  .append("clientIP=").append(clientIP).append(FIELD_SEPARATOR)
-		  .append("action=").append(action).append(FIELD_SEPARATOR);
-		
+		  .append("action=").append(action).append(FIELD_SEPARATOR)
+		  .append("agentHostname=").append(agentHostname).append(FIELD_SEPARATOR)
+		  .append("logType=").append(logType).append(FIELD_SEPARATOR)
+		  .append("eventId=").append(eventId).append(FIELD_SEPARATOR)
+		;
 		return sb;
 	}
 	

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/85d672f3/agents-audit/src/main/java/com/xasecure/audit/provider/BufferedAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/BufferedAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/BufferedAuditProvider.java
index 3db5f91..92a6980 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/BufferedAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/BufferedAuditProvider.java
@@ -26,6 +26,18 @@ public abstract class BufferedAuditProvider implements AuditProvider {
 
 	@Override
 	public void log(AuditEventBase event) {
+		if(event.getAgentHostname() == null) {
+			event.setAgentHostname(MiscUtil.getHostname());
+		}
+
+		if(event.getLogType() == null) {
+			event.setLogType("ArgusAudit");
+		}
+
+		if(event.getEventId() == null) {
+			event.setEventId(MiscUtil.generateUniqueId());
+		}
+
 		mBuffer.add(event);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/85d672f3/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java b/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
index 9ad3db9..40cbbc5 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
@@ -2,9 +2,9 @@ package com.xasecure.audit.provider;
 
 import java.io.File;
 import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.rmi.dgc.VMID;
 import java.text.SimpleDateFormat;
+import java.util.UUID;
 
 import org.apache.log4j.helpers.LogLog;
 
@@ -31,7 +31,7 @@ public class MiscUtil {
 
 	static {
 		try {
-			sGsonBuilder = new GsonBuilder().create();
+			sGsonBuilder = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z").create();
 		} catch(Throwable excp) {
 			LogLog.warn("failed to create GsonBuilder object. stringigy() will return obj.toString(),
instead of Json", excp);
 		}
@@ -101,7 +101,7 @@ public class MiscUtil {
 
 		try {
 			ret = InetAddress.getLocalHost().getHostName();
-		} catch (UnknownHostException excp) {
+		} catch (Exception excp) {
 			LogLog.warn("getHostname()", excp);
 		}
 
@@ -209,6 +209,10 @@ public class MiscUtil {
 
 		return ret;
 	}
+	
+	public static String generateUniqueId() {
+		return UUID.randomUUID().toString();
+	}
 
 	public static <T> String stringify(T log) {
 		String ret = null;


Mime
View raw message