-
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 AWS elasticache, elasticsearch, elb to Rego
Signed-off-by: Nikita Pivkin <[email protected]>
- Loading branch information
Showing
64 changed files
with
940 additions
and
969 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
41 changes: 41 additions & 0 deletions
41
checks/cloud/aws/elasticache/add_description_for_security_group.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,41 @@ | ||
# METADATA | ||
# title: Missing description for security group/security group rule. | ||
# description: | | ||
# Security groups and security group rules should include a description for auditing purposes. | ||
# Simplifies auditing, debugging, and managing security groups. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/SecurityGroups.Creating.html | ||
# custom: | ||
# id: AVD-AWS-0049 | ||
# avd_id: AVD-AWS-0049 | ||
# provider: aws | ||
# service: elasticache | ||
# severity: LOW | ||
# short_code: add-description-for-security-group | ||
# recommended_action: Add descriptions for all security groups and rules | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: elasticache | ||
# provider: aws | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_security_group#description | ||
# good_examples: checks/cloud/aws/elasticache/add_description_for_security_group.tf.go | ||
# bad_examples: checks/cloud/aws/elasticache/add_description_for_security_group.tf.go | ||
# cloudformation: | ||
# good_examples: checks/cloud/aws/elasticache/add_description_for_security_group.cf.go | ||
# bad_examples: checks/cloud/aws/elasticache/add_description_for_security_group.cf.go | ||
package builtin.aws.elasticache.aws0049 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some secgroup in input.aws.elasticache.securitygroups | ||
secgroup.description.value == "" | ||
res := result.new("Security group does not have a description.", secgroup.description) | ||
} |
65 changes: 0 additions & 65 deletions
65
checks/cloud/aws/elasticache/add_description_for_security_group_test.go
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
checks/cloud/aws/elasticache/add_description_for_security_group_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,18 @@ | ||
package builtin.aws.elasticache.aws0049_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.aws.elasticache.aws0049 as check | ||
import data.lib.test | ||
|
||
test_allow_sg_with_description if { | ||
inp := {"aws": {"elasticache": {"securitygroups": [{"description": {"value": "sg description"}}]}}} | ||
|
||
test.assert_empty(check.deny) with input as inp | ||
} | ||
|
||
test_deny_sg_without_description if { | ||
inp := {"aws": {"elasticache": {"securitygroups": [{"description": {"value": ""}}]}}} | ||
|
||
test.assert_equal_message("Security group does not have a description.", check.deny) with input as inp | ||
} |
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
37 changes: 37 additions & 0 deletions
37
checks/cloud/aws/elasticache/enable_at_rest_encryption.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,37 @@ | ||
# METADATA | ||
# title: Elasticache Replication Group stores unencrypted data at-rest. | ||
# description: | | ||
# Data stored within an Elasticache replication node should be encrypted to ensure sensitive data is kept private. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/at-rest-encryption.html | ||
# custom: | ||
# id: AVD-AWS-0045 | ||
# avd_id: AVD-AWS-0045 | ||
# provider: aws | ||
# service: elasticache | ||
# severity: HIGH | ||
# short_code: enable-at-rest-encryption | ||
# recommended_action: Enable at-rest encryption for replication group | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: elasticache | ||
# provider: aws | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group#at_rest_encryption_enabled | ||
# good_examples: checks/cloud/aws/elasticache/enable_at_rest_encryption.tf.go | ||
# bad_examples: checks/cloud/aws/elasticache/enable_at_rest_encryption.tf.go | ||
package builtin.aws.elasticache.aws0045 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some group in input.aws.elasticache.replicationgroups | ||
group.atrestencryptionenabled.value == false | ||
res := result.new("Replication group does not have at-rest encryption enabled.", group.atrestencryptionenabled) | ||
} |
18 changes: 18 additions & 0 deletions
18
checks/cloud/aws/elasticache/enable_at_rest_encryption_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,18 @@ | ||
package builtin.aws.elasticache.aws0045_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.aws.elasticache.aws0045 as check | ||
import data.lib.test | ||
|
||
test_allow_with_encryption_enabled if { | ||
inp := {"aws": {"elasticache": {"replicationgroups": [{"atrestencryptionenabled": {"value": true}}]}}} | ||
|
||
test.assert_empty(check.deny) with input as inp | ||
} | ||
|
||
test_deny_with_encryption_disabled if { | ||
inp := {"aws": {"elasticache": {"replicationgroups": [{"atrestencryptionenabled": {"value": false}}]}}} | ||
|
||
test.assert_equal_message("Replication group does not have at-rest encryption enabled.", check.deny) with input as inp | ||
} |
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.