-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from nikpivkin/go2rego-azure-4
refactor(checks): migrate Azure monitor, network, synapse, securitycenter to Rego
- Loading branch information
Showing
65 changed files
with
1,656 additions
and
1,054 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
checks/cloud/azure/monitor/activity_log_retention_set.rego
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,54 @@ | ||
# METADATA | ||
# title: Ensure the activity retention log is set to at least a year | ||
# description: | | ||
# The average time to detect a breach is up to 210 days, to ensure that all the information required for an effective investigation is available, the retention period should allow for delayed starts to investigating. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/platform-logs-overview | ||
# custom: | ||
# id: AVD-AZU-0031 | ||
# avd_id: AVD-AZU-0031 | ||
# provider: azure | ||
# service: monitor | ||
# severity: MEDIUM | ||
# short_code: activity-log-retention-set | ||
# recommended_action: Set a retention period that will allow for delayed investigation | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: monitor | ||
# provider: azure | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_log_profile#retention_policy | ||
# good_examples: checks/cloud/azure/monitor/activity_log_retention_set.tf.go | ||
# bad_examples: checks/cloud/azure/monitor/activity_log_retention_set.tf.go | ||
package builtin.azure.monitor.azure0031 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some profile in input.azure.monitor.logprofiles | ||
isManaged(profile) | ||
not profile.retentionpolicy.enabled.value | ||
res := result.new( | ||
"Profile does not enable the log retention policy.", | ||
object.get(profile, ["retentionpolicy", "enabled"], profile), | ||
) | ||
} | ||
|
||
deny contains res if { | ||
some profile in input.azure.monitor.logprofiles | ||
isManaged(profile) | ||
profile.retentionpolicy.enabled.value | ||
not is_recommended_retention_policy(profile) | ||
res := result.new( | ||
"Profile has a log retention policy of less than 1 year.", | ||
object.get(profile, ["retentionpolicy", "days"], profile), | ||
) | ||
} | ||
|
||
is_recommended_retention_policy(profile) := profile.retentionpolicy.days.value >= 365 |
89 changes: 0 additions & 89 deletions
89
checks/cloud/azure/monitor/activity_log_retention_set_test.go
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
checks/cloud/azure/monitor/activity_log_retention_set_test.rego
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,33 @@ | ||
package builtin.azure.monitor.azure0031_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.azure.monitor.azure0031 as check | ||
import data.lib.test | ||
|
||
test_deny_retention_policy_disabled if { | ||
inp := {"azure": {"monitor": {"logprofiles": [{"retentionpolicy": {"enabled": {"value": false}}}]}}} | ||
|
||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_deny_retention_policy_enabled_but_days_lt_365 if { | ||
inp := {"azure": {"monitor": {"logprofiles": [{"retentionpolicy": { | ||
"enabled": {"value": true}, | ||
"days": {"value": 30}, | ||
}}]}}} | ||
|
||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_allow_retention_policy_enabled_and_days_gt_365 if { | ||
inp := {"azure": {"monitor": {"logprofiles": [{"retentionpolicy": { | ||
"enabled": {"value": true}, | ||
"days": {"value": 365}, | ||
}}]}}} | ||
|
||
res := check.deny with input as inp | ||
count(res) == 0 | ||
} |
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
Oops, something went wrong.