-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bicep): Add bicep version of policy (#6191)
* Add bicep version of policy * Add test * Fix test * Update expected.yaml
- Loading branch information
Showing
7 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
checkov/bicep/checks/graph_checks/SQLServerAuditingRetention90Days.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
metadata: | ||
id: "CKV_AZURE_24" | ||
name: "Ensure that 'Auditing' Retention is 'greater than 90 days' for SQL servers" | ||
category: "LOGGING" | ||
definition: | ||
and: | ||
- cond_type: "filter" | ||
attribute: "resource_type" | ||
value: | ||
- "Microsoft.Sql/servers" | ||
operator: "within" | ||
- cond_type: "connection" | ||
resource_types: | ||
- "Microsoft.Sql/servers" | ||
connected_resource_types: | ||
- "Microsoft.Sql/servers/auditingSettings" | ||
operator: "exists" | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Microsoft.Sql/servers/auditingSettings" | ||
attribute: "properties.retentionDays" | ||
operator: "exists" | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Microsoft.Sql/servers/auditingSettings" | ||
attribute: "properties.retentionDays" | ||
operator: "greater_than_or_equal" | ||
value: 90 | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Microsoft.Sql/servers/auditingSettings" | ||
attribute: "properties.state" | ||
operator: "equals" | ||
value: Enabled |
10 changes: 10 additions & 0 deletions
10
tests/bicep/graph/checks/resources/SQLServerAuditingRetention90Days/expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pass: | ||
- 'Microsoft.Sql/servers.sqlServer_pass' | ||
fail: | ||
- 'Microsoft.Sql/servers.sqlServer_fail1' | ||
- 'Microsoft.Sql/servers.sqlServer_fail2' | ||
- 'Microsoft.Sql/servers.sqlServer_fail3' | ||
evaluated_keys: | ||
- 'properties/retentionDays' | ||
- 'properties/state' | ||
- 'resource_type' |
15 changes: 15 additions & 0 deletions
15
tests/bicep/graph/checks/resources/SQLServerAuditingRetention90Days/fail1_less_90.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource sqlServer_fail1 'Microsoft.Sql/servers@2023-05-01-preview' = { | ||
name: sqlServerName | ||
} | ||
|
||
/// SQL Auditing | ||
|
||
resource sql_auditing_fail1 'Microsoft.Sql/servers/auditingSettings@2023-05-01-preview' = { | ||
name: 'default' | ||
parent: sqlServer_fail1 | ||
properties: { | ||
isAzureMonitorTargetEnabled: true | ||
retentionDays: 67 | ||
state: 'Enabled' | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...icep/graph/checks/resources/SQLServerAuditingRetention90Days/fail2_no_auditsettings.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource sqlServer_fail2 'Microsoft.Sql/servers@2023-05-01-preview' = { | ||
name: sqlServerName | ||
} | ||
|
||
/// No SQL Audit Settings |
15 changes: 15 additions & 0 deletions
15
tests/bicep/graph/checks/resources/SQLServerAuditingRetention90Days/fail3_not_enabled.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource sqlServer_fail3 'Microsoft.Sql/servers@2023-05-01-preview' = { | ||
name: sqlServerName | ||
} | ||
|
||
/// SQL Auditing | ||
|
||
resource sql_auditing_fail3 'Microsoft.Sql/servers/auditingSettings@2023-05-01-preview' = { | ||
name: 'default' | ||
parent: sqlServer_fail3 | ||
properties: { | ||
isAzureMonitorTargetEnabled: true | ||
retentionDays: 92 | ||
state: 'Disabled' | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/bicep/graph/checks/resources/SQLServerAuditingRetention90Days/pass1.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource sqlServer_pass 'Microsoft.Sql/servers@2023-05-01-preview' = { | ||
name: sqlServerName | ||
} | ||
|
||
/// SQL Auditing | ||
|
||
resource sql_auditing_pass 'Microsoft.Sql/servers/auditingSettings@2023-05-01-preview' = { | ||
name: 'default' | ||
parent: sqlServer_pass | ||
properties: { | ||
isAzureMonitorTargetEnabled: true | ||
retentionDays: 92 | ||
state: 'Enabled' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters