Unrecommended Network Watcher Flow Log Retention Policy
- Query id: 564b70f8-41cd-4690-aff8-bb53add86bc9
- Query name: Unrecommended Network Watcher Flow Log Retention Policy
- Platform: AzureResourceManager
- Severity: Medium
- Category: Observability
- URL: Github
Description¶
Network Watcher Flow Log Retention Policy should be enabled and the recommended number of days for the retention should be higher than 90
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/flowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 2,
"enabled": false
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 2
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"retentionPolicy": {
"days": 95,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/flowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 2,
"enabled": false
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 2
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Postitive test num. 7 - 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Postitive 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"retentionPolicy": {
"days": 95,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/flowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 92,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 95,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
}
Negative test num. 3 - 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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/flowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 92,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
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": [
{
"name": "flowlogs/sample",
"type": "Microsoft.Network/networkWatchers/FlowLogs",
"apiVersion": "2020-11-01",
"location": "location",
"tags": {},
"properties": {
"targetResourceId": "targetResourceId",
"storageId": "storageId",
"enabled": true,
"retentionPolicy": {
"days": 95,
"enabled": true
},
"format": {
"type": "JSON"
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}