Project: KICS (Provisioning / Security & Compliance)
File: e055285c-bc01-48b4-8aa5-8a54acdd29df.md

title: SQL Server Database Without Auditing hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: e055285c-bc01-48b4-8aa5-8a54acdd29df Query name: SQL Server Database Without Auditing Platform: AzureResourceManager Severity: <span style="color:#ff7213">Medium</span> Category: Observability URL: Every 'Microsoft.Sql/servers/databases' resource should have Auditing Enabled<br> ```json title="Positive test num. 1 - json file" hl_lines="22" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" } } ] } ], "outputs": {} } ``` ```json title="Positive test num. 2 - json file" hl_lines="22" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" } }, { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 1073741824, "requestedServiceObjectiveName": "Basic" } }, { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Disabled" } } ], "outputs": {} } ``` ```json title="Positive test num. 3 - json file" hl_lines="24" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": "1073741824", "requestedServiceObjectiveName": "Basic" } } ] } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ``` <details><summary>Positive test num. 4 - json file</summary> ```json hl_lines="24" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" } }, { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 1073741824, "requestedServiceObjectiveName": "Basic" } }, { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Disabled" } } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type":

"name": "myTemplate" } ``` </details> ```json title="Negative test num. 1 - json file" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "ssqlDatabase1", "type": "databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 107374182, "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "auditingSettings", "apiVersion": "2021-02-01-preview", "name": "default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled" } } ] } ] } ], "outputs": {} } ``` ```json title="Negative test num. 2 - json file" { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" } }, { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 1073741824, "requestedServiceObjectiveName": "Basic" } }, { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled" } } ], "outputs": {} } ``` ```json title="Negative test num. 3 - json file" { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" }, "resources": [ { "name": "ssqlDatabase1", "type": "databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 107374182, "requestedServiceObjectiveName": "Basic" }, "resources": [ { "type": "auditingSettings", "apiVersion": "2021-02-01-preview", "name": "default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled" } } ] } ] } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ``` <details><summary>Negative test num. 4 - json file</summary> ```json { "properties": { "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "sqlServer1", "type": "Microsoft.Sql/servers", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlServer1" }, "properties": { "administratorLogin": "adminUsername", "administratorLoginPassword": "adminPassword" } }, { "name": "sqlServer1/sqlDatabase1", "type": "Microsoft.Sql/servers/databases", "apiVersion": "2021-02-01-preview", "location": "[resourceGroup().location]", "tags": { "displayName": "sqlDatabase1" }, "dependsOn": [ "[resourceId('Microsoft.Sql/servers', 'sqlServer1')]" ], "properties": { "collation": "SQLLatin1GeneralCP1CI_AS", "edition": "Basic", "maxSizeBytes": 1073741824, "requestedServiceObjectiveName": "Basic" } }, { "type": "Microsoft.Sql/servers/databases/auditingSettings", "apiVersion": "2021-02-01-preview", "name": "sqlServer1/sqlDatabase1/default", "properties": { "auditActionsAndGroups": [ "DATABASELOGOUTGROUP" ], "isAzureMonitorTargetEnabled": true, "isStorageSecondaryKeyInUse": true, "queueDelayMs": 1000, "retentionDays": 100, "state": "Enabled" } } ], "outputs": {} }, "parameters": {} }, "kind": "template", "type": "Microsoft.Blueprint/blueprints/artifacts", "name": "myTemplate" } ``` </details>