Exemplo n.º 1
0
 /// <summary>
 /// Updates the content of the model object with all the storage related information
 /// </summary>
 private void ModelizeStorageInfo(BaseAuditingPolicyModel model, string accountName, string primary, string secondary)
 {
     model.StorageAccountName = accountName;
     if (!String.IsNullOrEmpty(secondary))
     {
         model.StorageKeyType = StorageKeyKind.Secondary;
     }
     else
     {
         model.StorageKeyType = StorageKeyKind.Primary;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the content of the model object with all the retention information
        /// </summary>
        private void ModelizeRetentionInfo(BaseAuditingPolicyModel model, string retentionDays, string auditLogsTableName, string fullAuditLogsTableName)
        {
            model.TableIdentifier        = auditLogsTableName;
            model.FullAuditLogsTableName = fullAuditLogsTableName;
            uint retentionDaysForModel;

            if (!(UInt32.TryParse(retentionDays, out retentionDaysForModel)))
            {
                retentionDaysForModel = 0;
            }
            model.RetentionInDays = retentionDaysForModel;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Extracts the storage account requested key
 /// </summary>
 private string ExtractStorageAccountKey(string storageName, BaseAuditingPolicyModel model, string storageAccountResourceGroup, StorageKeyKind keyType)
 {
     if (IgnoreStorage)
     {
         return(null);
     }
     if (model.StorageKeyType == keyType)
     {
         return(AzureCommunicator.GetStorageKeys(storageAccountResourceGroup, storageName)[keyType]);
     }
     return(null);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Updates the given model with all the event types information
 /// </summary>
 private void ModelizeEventTypesInfo(BaseAuditingPolicyModel model, string eventTypesToAudit)
 {
     HashSet<AuditEventType> events = new HashSet<AuditEventType>();
     if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Success) != -1) events.Add(AuditEventType.PlainSQL_Success);
     if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Failure) != -1) events.Add(AuditEventType.PlainSQL_Failure);
     if (eventTypesToAudit.IndexOf(SecurityConstants.ParameterizedSQL_Success) != -1) events.Add(AuditEventType.ParameterizedSQL_Success);
     if (eventTypesToAudit.IndexOf(SecurityConstants.ParameterizedSQL_Failure) != -1) events.Add(AuditEventType.ParameterizedSQL_Failure);
     if (eventTypesToAudit.IndexOf(SecurityConstants.StoredProcedure_Success) != -1) events.Add(AuditEventType.StoredProcedure_Success);
     if (eventTypesToAudit.IndexOf(SecurityConstants.StoredProcedure_Failure) != -1) events.Add(AuditEventType.StoredProcedure_Failure);
     if (eventTypesToAudit.IndexOf(SecurityConstants.Login_Success) != -1) events.Add(AuditEventType.Login_Success);
     if (eventTypesToAudit.IndexOf(SecurityConstants.Login_Failure) != -1) events.Add(AuditEventType.Login_Failure);
     if (eventTypesToAudit.IndexOf(SecurityConstants.TransactionManagement_Success) != -1) events.Add(AuditEventType.TransactionManagement_Success);
     if (eventTypesToAudit.IndexOf(SecurityConstants.TransactionManagement_Failure) != -1) events.Add(AuditEventType.TransactionManagement_Failure);
     model.EventType = events.ToArray();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Extracts the storage account name from the given model
        /// </summary>
        private string ExtractStorageAccountName(BaseAuditingPolicyModel model)
        {
            string storageAccountName = null;

            if (model.StorageAccountName == FetchedStorageAccountName) // the user provided the same storage account that was given before
            {
                storageAccountName = FetchedStorageAccountName;
            }
            else if (model.StorageAccountName == null) // the user did not provided storage account for a policy for which such account is already defined
            {
                storageAccountName = FetchedStorageAccountName;
            }
            else // the user updates the name of the storage account
            {
                storageAccountName = model.StorageAccountName;
            }
            if (string.IsNullOrEmpty(storageAccountName) && (!IgnoreStorage)) // can happen if the user didn't provide account name for a policy that lacked it
            {
                throw new Exception(string.Format(Resources.NoStorageAccountWhenConfiguringAuditingPolicy));
            }
            return(storageAccountName);
        }
        /// <summary>
        /// Extracts the event types from the given model
        /// </summary>
        private string ExtractEventTypes(BaseAuditingPolicyModel model)
        {
            if (model.EventType == null)
            {
                return(null);
            }

            StringBuilder events = new StringBuilder();

            if (IsEventTypeOn(AuditEventType.DataAccess, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.DataAccess).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.DataChanges, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.DataChanges).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.RevokePermissions, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.RevokePermissions).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.SchemaChanges, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.SchemaChanges).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.SecurityExceptions, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.SecurityExceptions).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.PlainSQL_Success, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.PlainSQL_Success).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.PlainSQL_Failure, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.PlainSQL_Failure).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.ParameterizedSQL_Success, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.ParameterizedSQL_Success).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.ParameterizedSQL_Failure, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.ParameterizedSQL_Failure).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.StoredProcedure_Success, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.StoredProcedure_Success).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.StoredProcedure_Failure, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.StoredProcedure_Failure).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.Login_Success, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.Login_Success).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.Login_Failure, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.Login_Failure).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.TransactionManagement_Success, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.TransactionManagement_Success).Append(",");
            }
            if (IsEventTypeOn(AuditEventType.TransactionManagement_Failure, model.EventType))
            {
                events.Append(SecurityConstants.AuditingEndpoint.TransactionManagement_Failure).Append(",");
            }
            if (events.Length != 0)
            {
                events.Remove(events.Length - 1, 1); // remove trailing comma
            }
            return(events.ToString());
        }
        /// <summary>
        /// Updates the given model with all the event types information
        /// </summary>
        private void ModelizeEventTypesInfo(BaseAuditingPolicyModel model, string eventTypesToAudit)
        {
            HashSet <AuditEventType> events = new HashSet <AuditEventType>();

            if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.DataAccess) != -1)
            {
                events.Add(AuditEventType.DataAccess);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.DataChanges) != -1)
            {
                events.Add(AuditEventType.DataChanges);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.RevokePermissions) != -1)
            {
                events.Add(AuditEventType.RevokePermissions);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.SchemaChanges) != -1)
            {
                events.Add(AuditEventType.SchemaChanges);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.DeprecatedAuditEvents.SecurityExceptions) != -1)
            {
                events.Add(AuditEventType.SecurityExceptions);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Success) != -1)
            {
                events.Add(AuditEventType.PlainSQL_Success);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.PlainSQL_Failure) != -1)
            {
                events.Add(AuditEventType.PlainSQL_Failure);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.ParameterizedSQL_Success) != -1)
            {
                events.Add(AuditEventType.ParameterizedSQL_Success);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.ParameterizedSQL_Failure) != -1)
            {
                events.Add(AuditEventType.ParameterizedSQL_Failure);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.StoredProcedure_Success) != -1)
            {
                events.Add(AuditEventType.StoredProcedure_Success);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.StoredProcedure_Failure) != -1)
            {
                events.Add(AuditEventType.StoredProcedure_Failure);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.Login_Success) != -1)
            {
                events.Add(AuditEventType.Login_Success);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.Login_Failure) != -1)
            {
                events.Add(AuditEventType.Login_Failure);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.TransactionManagement_Success) != -1)
            {
                events.Add(AuditEventType.TransactionManagement_Success);
            }
            if (eventTypesToAudit.IndexOf(SecurityConstants.TransactionManagement_Failure) != -1)
            {
                events.Add(AuditEventType.TransactionManagement_Failure);
            }
            model.EventType = events.ToArray();
        }