-
Notifications
You must be signed in to change notification settings - Fork 42
Add audit logs #1666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add audit logs #1666
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...cloudfoundry/multiapps/controller/core/auditlogging/ApplicationConfigurationAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
|
|
||
| public class ApplicationConfigurationAuditLog { | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public ApplicationConfigurationAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logEnvironmentVariableRead(String envVariableName, String value, String spaceGuid) { | ||
| String performedAction = MessageFormat.format(Messages.READ_ENV, envVariableName, value, spaceGuid); | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(spaceGuid, | ||
| performedAction, | ||
| Messages.ENVIRONMENT_VARIABLE_READ_AUDIT_LOG_CONFIG)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
...main/java/org/cloudfoundry/multiapps/controller/core/auditlogging/AuditLoggingFacade.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,20 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.mta.model.AuditableConfiguration; | ||
|
|
||
| public interface AuditLoggingFacade { | ||
|
|
||
| void logSecurityIncident(AuditLogConfiguration configuration); | ||
|
|
||
| void logDataAccessAuditLog(AuditLogConfiguration configuration); | ||
|
|
||
| void logConfigurationChangeAuditLog(AuditLogConfiguration configuration, ConfigurationChangeActions configurationAction); | ||
|
|
||
| void logConfigurationChangeAuditLog(AuditLogConfiguration configuration, | ||
| ConfigurationChangeActions configurationAction, | ||
| AuditableConfiguration oldValue, | ||
| AuditableConfiguration newValue); | ||
|
|
||
| } |
71 changes: 71 additions & 0 deletions
71
...loudfoundry/multiapps/controller/core/auditlogging/ConfigurationEntryServiceAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationEntry; | ||
|
|
||
| public class ConfigurationEntryServiceAuditLog { | ||
|
|
||
| private static final String PROVIDER_ID_PROPERTY_NAME = "providerId"; | ||
| private static final String PROVIDER_NID_PROPERTY_NAME = "providerNid"; | ||
| private static final String PROVIDER_VERSION_PROPERTY_NAME = "providerVersion"; | ||
| private static final String PROVIDER_NAMESPACE_PROPERTY_NAME = "providerNamespace"; | ||
| private static final String PROVIDER_TARGET_PROPERTY_NAME = "providerTarget"; | ||
| private static final String PROVIDER_CONTENT_PROPERTY_NAME = "providerContent"; | ||
| private static final String PROVIDER_CONTENT_ID_PROPERTY_NAME = "providerContentId"; | ||
|
|
||
| private static final String PROVIDER_TARGET_TEMPLATE = "{0}/{1}"; | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public ConfigurationEntryServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logAddConfigurationEntry(String username, String spaceGuid, ConfigurationEntry entry) { | ||
| String performedAction = MessageFormat.format(Messages.ENTRY_CREATE, spaceGuid); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.ENTRY_CREATE_AUDIT_LOG_CONFIG, | ||
| buildAddConfigEntryParameters(entry)), | ||
| ConfigurationChangeActions.CONFIGURATION_CREATE); | ||
| } | ||
|
|
||
| public void logUpdateConfigurationEntry(String username, String spaceGuid, ConfigurationEntry oldEntry, ConfigurationEntry newEntry) { | ||
| String performedAction = MessageFormat.format(Messages.ENTRY_UPDATE, spaceGuid); | ||
|
|
||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.ENTRY_UPDATE_AUDIT_LOG_CONFIG), | ||
| ConfigurationChangeActions.CONFIGURATION_UPDATE, oldEntry, newEntry); | ||
|
|
||
| } | ||
|
|
||
| private Map<String, String> buildAddConfigEntryParameters(ConfigurationEntry entry) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| String providerTarget = MessageFormat.format(PROVIDER_TARGET_TEMPLATE, | ||
| entry.getTargetSpace() | ||
| .getOrganizationName(), | ||
| entry.getTargetSpace() | ||
| .getSpaceName()); | ||
|
|
||
| identifiers.put(PROVIDER_ID_PROPERTY_NAME, entry.getProviderId()); | ||
| identifiers.put(PROVIDER_NID_PROPERTY_NAME, entry.getProviderNid()); | ||
| identifiers.put(PROVIDER_VERSION_PROPERTY_NAME, Objects.toString(entry.getProviderVersion())); | ||
| identifiers.put(PROVIDER_NAMESPACE_PROPERTY_NAME, entry.getProviderNamespace()); | ||
| identifiers.put(PROVIDER_TARGET_PROPERTY_NAME, providerTarget); | ||
| identifiers.put(PROVIDER_CONTENT_PROPERTY_NAME, entry.getContent()); | ||
| identifiers.put(PROVIDER_CONTENT_ID_PROPERTY_NAME, entry.getContentId()); | ||
|
|
||
| return identifiers; | ||
| } | ||
|
|
||
| } |
58 changes: 58 additions & 0 deletions
58
...ndry/multiapps/controller/core/auditlogging/ConfigurationSubscriptionServiceAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationSubscription; | ||
|
|
||
| public class ConfigurationSubscriptionServiceAuditLog { | ||
|
|
||
| private static final String SUBSCRIPTION_ID_PROPERTY_NAME = "subscriptionId"; | ||
| private static final String APPLICATION_ID_PROPERTY_NAME = "applicationId"; | ||
| private static final String MTA_ID_PROPERTY_NAME = "mtaId"; | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public ConfigurationSubscriptionServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logAddConfigurationSubscription(String username, String spaceGuid, ConfigurationSubscription subscription) { | ||
| String performedAction = MessageFormat.format(Messages.SUBSCRIPTION_CREATE, spaceGuid); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.SUBSCRIPTION_CREATE_AUDIT_LOG_CONFIG, | ||
| buildAddConfigSubscriptionParameters( | ||
| subscription)), | ||
| ConfigurationChangeActions.CONFIGURATION_CREATE); | ||
| } | ||
|
|
||
| public void logUpdateConfigurationSubscription(String username, String spaceGuid, ConfigurationSubscription oldSubscription, | ||
| ConfigurationSubscription updatedSubscription) { | ||
|
|
||
| String performedAction = MessageFormat.format(Messages.SUBSCRIPTION_UPDATE, spaceGuid); | ||
|
|
||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.SUBSCRIPTION_UPDATE_AUDIT_LOG_CONFIG), | ||
| ConfigurationChangeActions.CONFIGURATION_UPDATE, oldSubscription, | ||
| updatedSubscription); | ||
| } | ||
|
|
||
| private Map<String, String> buildAddConfigSubscriptionParameters(ConfigurationSubscription subscription) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
|
|
||
| identifiers.put(APPLICATION_ID_PROPERTY_NAME, subscription.getAppName()); | ||
| identifiers.put(MTA_ID_PROPERTY_NAME, subscription.getMtaId()); | ||
| identifiers.put(SUBSCRIPTION_ID_PROPERTY_NAME, String.valueOf(subscription.getId())); | ||
|
|
||
| return identifiers; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.