Commit 9683c117 by Neeru Gupta Committed by Vimal Sharma

Add exclusion mechanism for Atlas audit mechanism

parent 384c3358
......@@ -9,6 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1391 Add exclusion mechanism for Atlas audit mechanism (guptaneeru via svimal2106)
ATLAS-1280 Atlas changes to support Hive hook for Hive2 (mneethiraj via svimal2106)
ATLAS-1432 Responsive loader and css changes (kevalbhatt via mneethiraj)
ATLAS-1434 Updated typename validation to allow "." for classifications (ashutoshm via mneethiraj)
ATLAS-1435 include common attributes in v2 entity API response (svimal2106 via mneethiraj)
......
......@@ -102,13 +102,15 @@ public class AtlasRepositoryConfiguration {
* Get the list of operations which are configured to be skipped from auditing
* Valid format is HttpMethod:URL eg: GET:Version
* @return list of string
* @throws AtlasException
*/
public static List<String> getAuditExcludedOperations(Configuration config) {
public static List<String> getAuditExcludedOperations(Configuration config) throws AtlasException {
if (config == null) {
try {
config = ApplicationProperties.get();
} catch (AtlasException e) {
LOG.error(" Error reading operations for auditing ", e);
throw e;
}
}
if (skippedOperations == null) {
......@@ -130,7 +132,7 @@ public class AtlasRepositoryConfiguration {
return skippedOperations;
}
public static boolean isExcludedFromAudit(Configuration config, String httpMethod, String httpUrl) {
public static boolean isExcludedFromAudit(Configuration config, String httpMethod, String httpUrl) throws AtlasException {
if (getAuditExcludedOperations(config).size() > 0) {
return getAuditExcludedOperations(config).contains(httpMethod.toLowerCase() + SEPARATOR + httpUrl.toLowerCase());
} else {
......
......@@ -19,11 +19,13 @@
package org.apache.atlas.web.filters;
import com.google.inject.Singleton;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContext;
import org.apache.atlas.metrics.Metrics;
import org.apache.atlas.util.AtlasRepositoryConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.atlas.util.AtlasRepositoryConfiguration;
import org.apache.atlas.web.util.DateTimeHelper;
import org.apache.atlas.web.util.Servlets;
import org.slf4j.Logger;
......@@ -40,7 +42,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
......@@ -126,7 +127,11 @@ public class AuditFilter implements Filter {
}
boolean isOperationExcludedFromAudit(String requestHttpMethod, String requestOperation, Configuration config) {
return AtlasRepositoryConfiguration.isExcludedFromAudit(config, requestHttpMethod, requestOperation);
try {
return AtlasRepositoryConfiguration.isExcludedFromAudit(config, requestHttpMethod, requestOperation);
} catch (AtlasException e) {
return false;
}
}
@Override
......
......@@ -115,4 +115,11 @@ public class AuditFilterTest {
verify(filterChain).doFilter(servletRequest, servletResponse);
}
@Test
public void testNullConfig() {
AtlasRepositoryConfiguration.resetExcludedOperations();
AuditFilter auditFilter = new AuditFilter();
assertFalse(auditFilter.isOperationExcludedFromAudit("GET", "Version", null));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment