SQL Server Database With Alerts Disabled

  • Query id: 574e8d82-1db2-4b9c-b526-e320ede9a9ff
  • Query name: SQL Server Database With Alerts Disabled
  • Platform: AzureResourceManager
  • Severity: Medium
  • Category: Best Practices
  • URL: Github

Description

All Alerts should be enabled in SQL Database Server SecurityAlerts Policy Properties
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
      "apiVersion": "2021-02-01-preview",
      "name": "sample/databases/default",
      "properties": {
        "disabledAlerts": [ "Sql_Injection" ],
        "emailAccountAdmins": true,
        "emailAddresses": [ "sample@email.com" ],
        "retentionDays": 4,
        "state": "Enabled"
      }
    }
  ],
  "outputs": {}
}
Positive test num. 2 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
          "apiVersion": "2021-02-01-preview",
          "name": "sample/databases/default",
          "properties": {
            "disabledAlerts": [ "Sql_Injection" ],
            "emailAccountAdmins": true,
            "emailAddresses": [ "sample@email.com" ],
            "retentionDays": 4,
            "state": "Enabled"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
      "apiVersion": "2021-02-01-preview",
      "name": "sample/databases/default",
      "properties": {
        "disabledAlerts": [],
        "emailAccountAdmins": true,
        "emailAddresses": [ "sample@email.com" ],
        "retentionDays": 4,
        "state": "Enabled"
      }
    }
  ],
  "outputs": {}
}
Negative test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
      "apiVersion": "2021-02-01-preview",
      "name": "sample/databases/default",
      "properties": {
        "emailAccountAdmins": true,
        "emailAddresses": [ "sample@email.com" ],
        "retentionDays": 4,
        "state": "Enabled"
      }
    }
  ],
  "outputs": {}
}
Negative test num. 3 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
      "apiVersion": "2021-02-01-preview",
      "name": "sample/databases/default",
      "properties": {
        "emailAccountAdmins": true,
        "emailAddresses": [ "sample@email.com" ],
        "retentionDays": 4,
        "state": "Disabled"
      }
    }
  ],
  "outputs": {}
}

Negative test num. 4 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
          "apiVersion": "2021-02-01-preview",
          "name": "sample/databases/default",
          "properties": {
            "disabledAlerts": [],
            "emailAccountAdmins": true,
            "emailAddresses": [ "sample@email.com" ],
            "retentionDays": 4,
            "state": "Enabled"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Negative test num. 5 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
          "apiVersion": "2021-02-01-preview",
          "name": "sample/databases/default",
          "properties": {
            "emailAccountAdmins": true,
            "emailAddresses": [ "sample@email.com" ],
            "retentionDays": 4,
            "state": "Enabled"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Negative test num. 6 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "type": "Microsoft.Sql/servers/databases/securityAlertPolicies",
          "apiVersion": "2021-02-01-preview",
          "name": "sample/databases/default",
          "properties": {
            "emailAccountAdmins": true,
            "emailAddresses": [ "sample@email.com" ],
            "retentionDays": 4,
            "state": "Disabled"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}