-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(checks): migrate Google sql and storage to Rego
Signed-off-by: Nikita Pivkin <[email protected]>
- Loading branch information
Showing
80 changed files
with
1,323 additions
and
1,255 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# METADATA | ||
# title: Enable automated backups to recover from data-loss | ||
# description: | | ||
# Automated backups are not enabled by default. Backups are an easy way to restore data in a corruption or data-loss scenario. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://cloud.google.com/sql/docs/mysql/backup-recovery/backups | ||
# custom: | ||
# id: AVD-GCP-0024 | ||
# avd_id: AVD-GCP-0024 | ||
# provider: google | ||
# service: sql | ||
# severity: MEDIUM | ||
# short_code: enable-backup | ||
# recommended_action: Enable automated backups | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: sql | ||
# provider: google | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#settings.backup_configuration.enabled=true | ||
# good_examples: checks/cloud/google/sql/enable_backup.tf.go | ||
# bad_examples: checks/cloud/google/sql/enable_backup.tf.go | ||
package builtin.google.sql.google0024 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some instance in input.google.sql.instances | ||
instance.isreplica.value == false | ||
instance.settings.backups.enabled.value == false | ||
res := result.new("Database instance does not have backups enabled.", instance.settings.backups.enabled) | ||
} |
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
package builtin.google.sql.google0024_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.google.sql.google0024 as check | ||
import data.lib.test | ||
|
||
test_allow_backups_enabled if { | ||
inp := build_input({ | ||
"isreplica": {"value": false}, | ||
"settings": {"backups": {"enabled": {"value": true}}}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
res == set() | ||
} | ||
|
||
test_deny_backups_disabled if { | ||
inp := build_input({ | ||
"isreplica": {"value": false}, | ||
"settings": {"backups": {"enabled": {"value": false}}}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_allow_backups_disabled_for_replica if { | ||
inp := build_input({ | ||
"isreplica": {"value": true}, | ||
"settings": {"backups": {"enabled": {"value": false}}}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
res == set() | ||
} | ||
|
||
build_input(instance) := {"google": {"sql": {"instances": [instance]}}} |
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.