PostgreSQL Database Server Log Checkpoints Disabled
- Query id: f9112910-c7bb-4864-9f5e-2059ba413bb7
- Query name: PostgreSQL Database Server Log Checkpoints Disabled
- Platform: AzureResourceManager
- Severity: Medium
- Category: Networking and Firewall
- CWE: 778
- URL: Github
Description¶
Microsoft.DBforPostgreSQL/servers/configurations should have 'log_checkpoint' property set to 'on'
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - bicep file
param dataDirectory string
param maxSizeMB string
param minSizeMB string
param pageSizeMB string
param workMemMB string
param maintenanceMemMB string
param checkpointSegments string
param checkpointCompletionTarget string
resource MyDBServer1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer1'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer1_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServer1
name: 'log_checkpoints'
properties: {
configurationSets: [
{
configurationSetType: 'Microsoft.DBforPostgreSQL/servers/configurations/dbconfig'
configurationSet: {
name: 'dbconfig'
configurationParameters: [
{
name: 'data_directory'
value: dataDirectory
}
{
name: 'max_size'
value: maxSizeMB
}
{
name: 'min_size'
value: minSizeMB
}
{
name: 'page_size'
value: pageSizeMB
}
{
name: 'work_mem'
value: workMemMB
}
{
name: 'maintenance_work_mem'
value: maintenanceMemMB
}
{
name: 'checkpoint_segments'
value: checkpointSegments
}
{
name: 'checkpoint_completion_target'
value: checkpointCompletionTarget
}
]
}
}
]
}
location: resourceGroup().location
dependsOn: [
'Microsoft.DBforPostgreSQL/servers/MyDBServer'
]
}
Positive 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": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer1",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"configurationSets": [
{
"configurationSetType": "Microsoft.DBforPostgreSQL/servers/configurations/dbconfig",
"configurationSet": {
"name": "dbconfig",
"configurationParameters": [
{
"name": "data_directory",
"value": "[parameters('dataDirectory')]"
},
{
"name": "max_size",
"value": "[parameters('maxSizeMB')]"
},
{
"name": "min_size",
"value": "[parameters('minSizeMB')]"
},
{
"name": "page_size",
"value": "[parameters('pageSizeMB')]"
},
{
"name": "work_mem",
"value": "[parameters('workMemMB')]"
},
{
"name": "maintenance_work_mem",
"value": "[parameters('maintenanceMemMB')]"
},
{
"name": "checkpoint_segments",
"value": "[parameters('checkpointSegments')]"
},
{
"name": "checkpoint_completion_target",
"value": "[parameters('checkpointCompletionTarget')]"
}
]
}
}
]
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
}
Positive test num. 3 - bicep file
resource MyDBServer2 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer2'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer2_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServer2
name: 'log_checkpoints'
properties: {
value: 'off'
}
location: resourceGroup().location
dependsOn: ['Microsoft.DBforPostgreSQL/servers/MyDBServer']
}
Positive test num. 4 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {},
"resources": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer2",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"value": "off"
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
}
Positive test num. 5 - bicep file
resource MyDBServer3 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer3'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
name: 'MyDBServer/log_checkpoints'
properties: {
value: 'off'
}
location: resourceGroup().location
dependsOn: ['MyDBServer']
}
Positive test num. 6 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {},
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer3",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"resources": [
]
},
{
"type": "Microsoft.DBforPostgreSQL/servers/configurations",
"apiVersion": "2017-12-01",
"name": "MyDBServer/log_checkpoints",
"properties": {
"value": "off"
},
"dependsOn": [
"MyDBServer"
],
"location": "[resourceGroup().location]"
}
],
"outputs": {}
}
Positive test num. 7 - bicep file
resource MyDBServer3 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer3'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
name: 'MyDBServer/log_checkpoints'
properties: {
source: 'source'
}
location: resourceGroup().location
dependsOn: ['MyDBServer']
}
Positive test num. 8 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {},
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer3",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"resources": [
]
},
{
"type": "Microsoft.DBforPostgreSQL/servers/configurations",
"apiVersion": "2017-12-01",
"name": "MyDBServer/log_checkpoints",
"properties": {
"source": "source"
},
"dependsOn": [
"MyDBServer"
],
"location": "[resourceGroup().location]"
}
],
"outputs": {}
}
Positive test num. 9 - bicep file
param dataDirectory string
param maxSizeMB string
param minSizeMB string
param pageSizeMB string
param workMemMB string
param maintenanceMemMB string
param checkpointSegments string
param checkpointCompletionTarget string
resource MyDBServer1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer1'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer1_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServer1
name: 'log_checkpoints'
properties: {
configurationSets: [
{
configurationSetType: 'Microsoft.DBforPostgreSQL/servers/configurations/dbconfig'
configurationSet: {
name: 'dbconfig'
configurationParameters: [
{
name: 'data_directory'
value: dataDirectory
}
{
name: 'max_size'
value: maxSizeMB
}
{
name: 'min_size'
value: minSizeMB
}
{
name: 'page_size'
value: pageSizeMB
}
{
name: 'work_mem'
value: workMemMB
}
{
name: 'maintenance_work_mem'
value: maintenanceMemMB
}
{
name: 'checkpoint_segments'
value: checkpointSegments
}
{
name: 'checkpoint_completion_target'
value: checkpointCompletionTarget
}
]
}
}
]
}
location: resourceGroup().location
dependsOn: [
'Microsoft.DBforPostgreSQL/servers/MyDBServer'
]
}
Positive test num. 10 - 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": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer1",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"configurationSets": [
{
"configurationSetType": "Microsoft.DBforPostgreSQL/servers/configurations/dbconfig",
"configurationSet": {
"name": "dbconfig",
"configurationParameters": [
{
"name": "data_directory",
"value": "[parameters('dataDirectory')]"
},
{
"name": "max_size",
"value": "[parameters('maxSizeMB')]"
},
{
"name": "min_size",
"value": "[parameters('minSizeMB')]"
},
{
"name": "page_size",
"value": "[parameters('pageSizeMB')]"
},
{
"name": "work_mem",
"value": "[parameters('workMemMB')]"
},
{
"name": "maintenance_work_mem",
"value": "[parameters('maintenanceMemMB')]"
},
{
"name": "checkpoint_segments",
"value": "[parameters('checkpointSegments')]"
},
{
"name": "checkpoint_completion_target",
"value": "[parameters('checkpointCompletionTarget')]"
}
]
}
}
]
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 11 - bicep file
resource MyDBServer2 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer2'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer2_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServer2
name: 'log_checkpoints'
properties: {
value: 'off'
}
location: resourceGroup().location
dependsOn: ['Microsoft.DBforPostgreSQL/servers/MyDBServer']
}
Positive test num. 12 - 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": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer2",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"value": "off"
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 13 - bicep file
resource MyDBServer3 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer3'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
name: 'MyDBServer/log_checkpoints'
properties: {
value: 'off'
}
location: resourceGroup().location
dependsOn: ['MyDBServer']
}
Positive test num. 14 - 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": [
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer3",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"resources": [
]
},
{
"type": "Microsoft.DBforPostgreSQL/servers/configurations",
"apiVersion": "2017-12-01",
"name": "MyDBServer/log_checkpoints",
"properties": {
"value": "off"
},
"dependsOn": [
"MyDBServer"
],
"location": "[resourceGroup().location]"
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 15 - bicep file
resource MyDBServer3 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServer3'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: 'S0'
tier: 'Basic'
capacity: 1
family: 'GeneralPurpose'
}
}
resource MyDBServer_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
name: 'MyDBServer/log_checkpoints'
properties: {
source: 'source'
}
location: resourceGroup().location
dependsOn: ['MyDBServer']
}
Positive test num. 16 - 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": [
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServer3",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "S0",
"tier": "Basic",
"capacity": 1,
"family": "GeneralPurpose"
},
"resources": [
]
},
{
"type": "Microsoft.DBforPostgreSQL/servers/configurations",
"apiVersion": "2017-12-01",
"name": "MyDBServer/log_checkpoints",
"properties": {
"source": "source"
},
"dependsOn": [
"MyDBServer"
],
"location": "[resourceGroup().location]"
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Code samples without security vulnerabilities¶
Negative test num. 1 - bicep file
param databaseSkuName string
param databaseSkuTier string
param databaseDTU string
param databaseSkuSizeMB string
resource MyDBServerNeg1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServerNeg1'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: databaseSkuName
tier: databaseSkuTier
capacity: databaseDTU
size: databaseSkuSizeMB
family: 'SkuFamily'
}
}
resource MyDBServerNeg1_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServerNeg1
name: 'log_checkpoints'
properties: {
value: 'on'
}
location: resourceGroup().location
dependsOn: [
'Microsoft.DBforPostgreSQL/servers/MyDBServer'
]
}
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": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServerNeg1",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "[parameters('databaseSkuName')]",
"tier": "[parameters('databaseSkuTier')]",
"capacity": "[parameters('databaseDTU')]",
"size": "[parameters('databaseSkuSizeMB')]",
"family": "SkuFamily"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"value": "on"
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
}
Negative test num. 3 - bicep file
param databaseSkuName string
param databaseSkuTier string
param databaseDTU string
param databaseSkuSizeMB string
resource MyDBServerNeg1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
kind: ''
location: resourceGroup().location
name: 'MyDBServerNeg1'
properties: {
sslEnforcement: 'Disabled'
version: '11'
administratorLogin: 'root'
administratorLoginPassword: '12345'
storageMB: '2048'
createMode: 'Default'
collation: 'SQL_Latin1_General_CP1_CI_AS'
creationDate: '2019-04-01T00:00:00Z'
lastModifiedDate: '2019-04-01T00:00:00Z'
maxSizeUnits: 'SizeUnit.megabytes'
isReadOnly: 'false'
isAutoUpgradeEnabled: 'true'
isStateful: 'false'
isExternal: 'false'
}
sku: {
name: databaseSkuName
tier: databaseSkuTier
capacity: databaseDTU
size: databaseSkuSizeMB
family: 'SkuFamily'
}
}
resource MyDBServerNeg1_log_checkpoints 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: MyDBServerNeg1
name: 'log_checkpoints'
properties: {
value: 'on'
}
location: resourceGroup().location
dependsOn: [
'Microsoft.DBforPostgreSQL/servers/MyDBServer'
]
}
Negative test num. 4 - 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": [
{
"apiVersion": "2017-12-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "MyDBServerNeg1",
"properties": {
"sslEnforcement": "Disabled",
"version": "11",
"administratorLogin": "root",
"administratorLoginPassword": "12345",
"storageMB": "2048",
"createMode": "Default",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2019-04-01T00:00:00Z",
"lastModifiedDate": "2019-04-01T00:00:00Z",
"maxSizeUnits": "SizeUnit.megabytes",
"isReadOnly": "false",
"isAutoUpgradeEnabled": "true",
"isStateful": "false",
"isExternal": "false"
},
"sku": {
"name": "[parameters('databaseSkuName')]",
"tier": "[parameters('databaseSkuTier')]",
"capacity": "[parameters('databaseDTU')]",
"size": "[parameters('databaseSkuSizeMB')]",
"family": "SkuFamily"
},
"type": "Microsoft.DBforPostgreSQL/servers",
"resources": [
{
"type": "configurations",
"apiVersion": "2017-12-01",
"dependsOn": [
"Microsoft.DBforPostgreSQL/servers/MyDBServer"
],
"name": "log_checkpoints",
"properties": {
"value": "on"
},
"location": "[resourceGroup().location]"
}
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}