/// <summary> /// Provides a server threat detection policy model for the given server /// </summary> public ServerThreatDetectionPolicyModel GetServerThreatDetectionPolicy(string resourceGroup, string serverName) { if (!IsRightServerVersionForThreatDetection(resourceGroup, serverName)) { throw new Exception(Properties.Resources.ServerNotApplicableForThreatDetection); } var threatDetectionPolicy = ThreatDetectionCommunicator.GetServerSecurityAlertPolicy(resourceGroup, serverName); var serverThreatDetectionPolicyModel = new ServerThreatDetectionPolicyModel() { ThreatDetectionState = ModelizeThreatDetectionState(threatDetectionPolicy.State.ToString()), NotificationRecipientsEmails = string.Join(";", threatDetectionPolicy.EmailAddresses.ToArray()), EmailAdmins = threatDetectionPolicy.EmailAccountAdmins == null ? false : threatDetectionPolicy.EmailAccountAdmins.Value, RetentionInDays = (uint)threatDetectionPolicy.RetentionDays, }; serverThreatDetectionPolicyModel.ExcludedDetectionTypes = threatDetectionPolicy.DisabledAlerts.Where(alert => !string.IsNullOrEmpty(alert)).ToArray() ?? new string[] { }; serverThreatDetectionPolicyModel.ResourceGroupName = resourceGroup; serverThreatDetectionPolicyModel.ServerName = serverName; ModelizeStorageAccount(serverThreatDetectionPolicyModel, threatDetectionPolicy.StorageEndpoint); return(serverThreatDetectionPolicyModel); }
/// <summary> /// Provides a database threat detection policy model for the given database /// </summary> public ServerThreatDetectionPolicyModel GetServerThreatDetectionPolicy(string resourceGroup, string serverName, string requestId) { if (!IsRightServerVersionForThreatDetection(resourceGroup, serverName, requestId)) { throw new Exception(Properties.Resources.ServerNotApplicableForThreatDetection); } var threatDetectionPolicy = ThreatDetectionCommunicator.GetServerSecurityAlertPolicy(resourceGroup, serverName, requestId); var serverThreatDetectionPolicyModel = ModelizeThreatDetectionPolicy(threatDetectionPolicy.Properties, new ServerThreatDetectionPolicyModel()) as ServerThreatDetectionPolicyModel; serverThreatDetectionPolicyModel.ResourceGroupName = resourceGroup; serverThreatDetectionPolicyModel.ServerName = serverName; return(serverThreatDetectionPolicyModel); }