Пример #1
0
        /// <summary>
        /// This method is responsible to call the right API in the communication layer that will eventually send the information in the
        /// object to the REST endpoint
        /// </summary>
        /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
        protected override ServerAdvancedDataSecurityPolicyModel PersistChanges(ServerAdvancedDataSecurityPolicyModel model)
        {
            model.IsEnabled = true;

            if (DoNotConfigureVulnerabilityAssessment)
            {
                ModelAdapter.SetServerAdvancedDataSecurity(model);
            }
            else
            {
                // Deploy arm template to enable VA - only if VA at server level is not defined
                var vaAdapter = new SqlVulnerabilityAssessmentAdapter(DefaultContext);
                var vaModel   = vaAdapter.GetVulnerabilityAssessmentSettings(ResourceGroupName, ServerName, "", ApplyToType.Server);

                if (string.IsNullOrEmpty(vaModel.StorageAccountName))
                {
                    var serverAdapter = new AzureSqlServerAdapter(DefaultContext);
                    AzureSqlServerModel serverModel = serverAdapter.GetServer(ResourceGroupName, ServerName);
                    ModelAdapter.EnableServerAdsWithVa(ResourceGroupName, ServerName, serverModel.Location, DeploymentName);
                }
                else
                {
                    ModelAdapter.SetServerAdvancedDataSecurity(model);
                }
            }

            return(model);
        }
        /// <summary>
        /// Sets a server Advanced Data Security policy model for the given server
        /// </summary>
        public ServerAdvancedDataSecurityPolicyModel SetServerAdvancedDataSecurity(ServerAdvancedDataSecurityPolicyModel model)
        {
            // Currently Advanced Data Security policy is a TD policy until the backend will support Advanced Data Security APIs
            var threatDetectionPolicy = SqlThreatDetectionAdapter.GetServerThreatDetectionPolicy(model.ResourceGroupName, model.ServerName);

            threatDetectionPolicy.ThreatDetectionState = model.IsEnabled ? ThreatDetectionStateType.Enabled : ThreatDetectionStateType.Disabled;

            SqlThreatDetectionAdapter.SetServerThreatDetectionPolicy(threatDetectionPolicy, AzureEnvironment.Endpoint.StorageEndpointSuffix);

            return(model);
        }
        /// <summary>
        /// Provides a server Advanced Data Security policy model for the given server
        /// </summary>
        public ServerAdvancedDataSecurityPolicyModel GetServerAdvancedDataSecurityPolicy(string resourceGroup, string serverName)
        {
            // Currently Advanced Threat Protection policy is a TD policy until the backend will support Advanced Threat Protection APIs
            var threatDetectionPolicy = SqlThreatDetectionAdapter.GetServerThreatDetectionPolicy(resourceGroup, serverName);
            var serverAdvancedDataSecurityPolicyModel = new ServerAdvancedDataSecurityPolicyModel()
            {
                ResourceGroupName = resourceGroup,
                ServerName        = serverName,
                IsEnabled         = (threatDetectionPolicy.ThreatDetectionState == ThreatDetectionStateType.Enabled)
            };

            return(serverAdvancedDataSecurityPolicyModel);
        }
 /// <summary>
 /// This method is responsible to call the right API in the communication layer that will eventually send the information in the
 /// object to the REST endpoint
 /// </summary>
 /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
 protected override ServerAdvancedDataSecurityPolicyModel PersistChanges(ServerAdvancedDataSecurityPolicyModel model)
 {
     model.IsEnabled = false;
     ModelAdapter.SetServerAdvancedDataSecurity(model, DefaultContext.Environment.GetEndpoint(AzureEnvironment.Endpoint.StorageEndpointSuffix));
     return(model);
 }
 /// <summary>
 /// This method is responsible to call the right API in the communication layer that will eventually send the information in the
 /// object to the REST endpoint
 /// </summary>
 /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
 protected override ServerAdvancedDataSecurityPolicyModel PersistChanges(ServerAdvancedDataSecurityPolicyModel model)
 {
     model.IsEnabled = false;
     ModelAdapter.SetServerAdvancedDataSecurity(model);
     return(model);
 }
 /// <summary>
 /// No sending is needed as this is a Get cmdlet
 /// </summary>
 /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
 protected override ServerAdvancedDataSecurityPolicyModel PersistChanges(ServerAdvancedDataSecurityPolicyModel model)
 {
     return(model);
 }
        /// <summary>
        /// Provides the model element that this cmdlet operates on
        /// </summary>
        /// <returns>A model object</returns>
        protected override ServerAdvancedDataSecurityPolicyModel GetEntity()
        {
            ServerAdvancedDataSecurityPolicyModel model = base.GetEntity();

            return(ModelAdapter.GetServerAdvancedDataSecurityPolicy(model.ResourceGroupName, model.ServerName));
        }