Ignore validation and recommendation requests during audit logging
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4abfc3e2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4abfc3e2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4abfc3e2 Branch: refs/heads/audit_logging Commit: 4abfc3e27093b5253ccc9c0644df0dc01e79b4d3 Parents: a4a1fa9 Author: Daniel Gergely <[email protected]> Authored: Thu Feb 25 13:38:44 2016 +0100 Committer: Toader, Sebastian <[email protected]> Committed: Thu Mar 24 13:06:47 2016 +0100 ---------------------------------------------------------------------- .../RecommendationIgnoreEventCreator.java | 77 ++++++++++++++++++++ .../ValidationIgnoreEventCreator.java | 77 ++++++++++++++++++++ .../server/controller/ControllerModule.java | 4 + 3 files changed, 158 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4abfc3e2/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RecommendationIgnoreEventCreator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RecommendationIgnoreEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RecommendationIgnoreEventCreator.java new file mode 100644 index 0000000..d68db84 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RecommendationIgnoreEventCreator.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.request.eventcreator; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.apache.ambari.server.api.services.Request; +import org.apache.ambari.server.api.services.Result; +import org.apache.ambari.server.api.services.ResultStatus; +import org.apache.ambari.server.audit.AuditEvent; +import org.apache.ambari.server.audit.request.RequestAuditEventCreator; +import org.apache.ambari.server.controller.spi.Resource; + +/** + * This creator ignores recommendation post requests + * For resource type {@link Resource.Type#Recommendation} + * and request types {@link Request.Type#POST} + */ +public class RecommendationIgnoreEventCreator implements RequestAuditEventCreator { + + /** + * Set of {@link Request.Type}s that are handled by this plugin + */ + private Set<Request.Type> requestTypes = new HashSet<Request.Type>(); + + { + requestTypes.add(Request.Type.POST); + } + + /** + * {@inheritDoc} + */ + @Override + public Set<Request.Type> getRequestTypes() { + return requestTypes; + } + + /** + * {@inheritDoc} + */ + @Override + public Set<Resource.Type> getResourceTypes() { + return Collections.singleton(Resource.Type.Recommendation); + } + + /** + * {@inheritDoc} + */ + @Override + public Set<ResultStatus.STATUS> getResultStatuses() { + return null; + } + + @Override + public AuditEvent createAuditEvent(Request request, Result result) { + // intentionally skipping this event + return null; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/4abfc3e2/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java new file mode 100644 index 0000000..e52aa10 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ValidationIgnoreEventCreator.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.request.eventcreator; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.apache.ambari.server.api.services.Request; +import org.apache.ambari.server.api.services.Result; +import org.apache.ambari.server.api.services.ResultStatus; +import org.apache.ambari.server.audit.AuditEvent; +import org.apache.ambari.server.audit.request.RequestAuditEventCreator; +import org.apache.ambari.server.controller.spi.Resource; + +/** + * This creator ignores validation post requests + * For resource type {@link Resource.Type#Validation} + * and request types {@link Request.Type#POST} + */ +public class ValidationIgnoreEventCreator implements RequestAuditEventCreator { + + /** + * Set of {@link Request.Type}s that are handled by this plugin + */ + private Set<Request.Type> requestTypes = new HashSet<Request.Type>(); + + { + requestTypes.add(Request.Type.POST); + } + + /** + * {@inheritDoc} + */ + @Override + public Set<Request.Type> getRequestTypes() { + return requestTypes; + } + + /** + * {@inheritDoc} + */ + @Override + public Set<Resource.Type> getResourceTypes() { + return Collections.singleton(Resource.Type.Validation); + } + + /** + * {@inheritDoc} + */ + @Override + public Set<ResultStatus.STATUS> getResultStatuses() { + return null; + } + + @Override + public AuditEvent createAuditEvent(Request request, Result result) { + // intentionally skipping this event + return null; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/4abfc3e2/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java index 0d7128d..f489f54 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java @@ -52,6 +52,7 @@ import org.apache.ambari.server.audit.request.eventcreator.HostEventCreator; import org.apache.ambari.server.audit.request.eventcreator.PrivilegeEventCreator; import org.apache.ambari.server.audit.request.eventcreator.GroupEventCreator; import org.apache.ambari.server.audit.request.eventcreator.MemberEventCreator; +import org.apache.ambari.server.audit.request.eventcreator.RecommendationIgnoreEventCreator; import org.apache.ambari.server.audit.request.eventcreator.RepositoryEventCreator; import org.apache.ambari.server.audit.request.eventcreator.RepositoryVersionEventCreator; import org.apache.ambari.server.audit.request.eventcreator.ServiceConfigDownloadEventCreator; @@ -63,6 +64,7 @@ import org.apache.ambari.server.audit.request.eventcreator.ServiceEventCreator; import org.apache.ambari.server.audit.request.eventcreator.UpgradeEventCreator; import org.apache.ambari.server.audit.request.eventcreator.UpgradeItemEventCreator; import org.apache.ambari.server.audit.request.eventcreator.UserEventCreator; +import org.apache.ambari.server.audit.request.eventcreator.ValidationIgnoreEventCreator; import org.apache.ambari.server.audit.request.eventcreator.ViewInstanceEventCreator; import org.apache.ambari.server.audit.request.eventcreator.ViewPrivilegeEventCreator; import org.apache.ambari.server.checks.AbstractCheckDescriptor; @@ -430,6 +432,8 @@ public class ControllerModule extends AbstractModule { auditLogEventCreatorBinder.addBinding().to(HostEventCreator.class); auditLogEventCreatorBinder.addBinding().to(UpgradeEventCreator.class); auditLogEventCreatorBinder.addBinding().to(UpgradeItemEventCreator.class); + auditLogEventCreatorBinder.addBinding().to(RecommendationIgnoreEventCreator.class); + auditLogEventCreatorBinder.addBinding().to(ValidationIgnoreEventCreator.class); bind(RequestAuditLogger.class).to(RequestAuditLoggerImpl.class); }
