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
- CWE: 778
- 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 - bicep file
resource sample_databases_default 'Microsoft.Sql/servers/databases/securityAlertPolicies@2021-02-01-preview' = {
name: 'sample/databases/default'
properties: {
disabledAlerts: ['Sql_Injection']
emailAccountAdmins: true
emailAddresses: ['sample@email.com']
retentionDays: 4
state: 'Enabled'
}
}
Positive 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": {
"disabledAlerts": [ "Sql_Injection" ],
"emailAccountAdmins": true,
"emailAddresses": [ "sample@email.com" ],
"retentionDays": 4,
"state": "Enabled"
}
}
],
"outputs": {}
}
Positive test num. 3 - bicep file
resource sample_databases_default 'Microsoft.Sql/servers/databases/securityAlertPolicies@2021-02-01-preview' = {
name: 'sample/databases/default'
properties: {
disabledAlerts: ['Sql_Injection']
emailAccountAdmins: true
emailAddresses: ['sample@email.com']
retentionDays: 4
state: 'Enabled'
}
}
Positive 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": [ "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 - bicep file
resource sample_databases_default 'Microsoft.Sql/servers/databases/securityAlertPolicies@2021-02-01-preview' = {
name: 'sample/databases/default'
properties: {
disabledAlerts: []
emailAccountAdmins: true
emailAddresses: ['sample@email.com']
retentionDays: 4
state: 'Enabled'
}
}
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": {
"disabledAlerts": [],
"emailAccountAdmins": true,
"emailAddresses": [ "sample@email.com" ],
"retentionDays": 4,
"state": "Enabled"
}
}
],
"outputs": {}
}
Negative test num. 3 - bicep file
resource sample_databases_default 'Microsoft.Sql/servers/databases/securityAlertPolicies@2021-02-01-preview' = {
name: 'sample/databases/default'
properties: {
emailAccountAdmins: true
emailAddresses: ['sample@email.com']
retentionDays: 4
state: 'Enabled'
}
}
Negative test num. 4 - 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. 5 - bicep file
Negative test num. 6 - 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. 7 - bicep file
Negative test num. 8 - 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. 9 - bicep file
Negative test num. 10 - 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. 11 - bicep file
Negative test num. 12 - 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"
}