Unrecommended Log Profile Retention Policy
- Query id: 25684eac-daaa-4c2c-94b4-8d2dbb627909
- Query name: Unrecommended Log Profile Retention Policy
- Platform: AzureResourceManager
- Severity: Low
- Category: Observability
- CWE: 778
- URL: Github
Description¶
Log Profile Retention Policy should be enabled and the recommended number of days for the retention should be higher than 365 or 0 (0 will retain the events indefinitely)
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - bicep file
resource string 'microsoft.insights/logprofiles@2016-03-01' = {
name: 'string'
location: 'location'
tags: {}
properties: {
storageAccountId: 'storageAccountId'
serviceBusRuleId: 'serviceBusRuleId'
locations: ['location1']
categories: ['Write']
retentionPolicy: {
enabled: true
days: 300
}
}
}
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": [
{
"name": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": true,
"days": 300
}
}
}
],
"outputs": {}
}
Positive test num. 3 - bicep file
resource string 'microsoft.insights/logprofiles@2016-03-01' = {
name: 'string'
location: 'location'
tags: {}
properties: {
storageAccountId: 'storageAccountId'
serviceBusRuleId: 'serviceBusRuleId'
locations: ['location1']
categories: ['Write']
retentionPolicy: {
enabled: false
days: 300
}
}
}
Positive 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": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": false,
"days": 300
}
}
}
],
"outputs": {}
}
Positive test num. 5 - bicep file
Positive 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": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": true,
"days": 300
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 7 - bicep file
Positive 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": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": false,
"days": 300
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Code samples without security vulnerabilities¶
Negative test num. 1 - bicep file
resource string 'microsoft.insights/logprofiles@2016-03-01' = {
name: 'string'
location: 'location'
tags: {}
properties: {
storageAccountId: 'storageAccountId'
serviceBusRuleId: 'serviceBusRuleId'
locations: ['location1']
categories: ['Write']
retentionPolicy: {
enabled: true
days: 400
}
}
}
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": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": true,
"days": 400
}
}
}
],
"outputs": {}
}
Negative test num. 3 - bicep file
resource string 'microsoft.insights/logprofiles@2016-03-01' = {
name: 'string'
location: 'location'
tags: {}
properties: {
storageAccountId: 'storageAccountId'
serviceBusRuleId: 'serviceBusRuleId'
locations: ['location1']
categories: ['Write']
retentionPolicy: {
enabled: true
days: 400
}
}
}
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": "string",
"type": "microsoft.insights/logprofiles",
"apiVersion": "2016-03-01",
"location": "location",
"tags": {},
"properties": {
"storageAccountId": "storageAccountId",
"serviceBusRuleId": "serviceBusRuleId",
"locations": [
"location1"
],
"categories": [
"Write"
],
"retentionPolicy": {
"enabled": true,
"days": 400
}
}
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}