Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rules): dedupe AVD-AWS-0180 #26

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions rules/cloud/policies/aws/rds/disable_public_access.rego
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# METADATA
# title: "RDS Publicly Accessible"
# description: "Ensures RDS instances are not launched into the public cloud."
# description: "Ensures RDS instances and RDS Cluster instances are not launched into the public cloud."
# scope: package
# schemas:
# - input: schema["cloud"]
Expand All @@ -12,17 +12,17 @@
# service: rds
# severity: HIGH
# short_code: enable-public-access
# recommended_action: "Remove the public endpoint from the RDS instance'"
# recommended_action: "Remove the public endpoint from the RDS instance."
# input:
# selector:
# - type: cloud
# subtypes:
# - service: rds
# provider: aws
# terraform:
# good_examples: "rules/cloud/policies/aws/rds/no_public_db_access.tf.go"
# good_examples: "rules/cloud/policies/aws/rds/disable_public_access.tf.go"
# cloud_formation:
# good_examples: "rules/cloud/policies/aws/rds/no_public_db_access.cf.go"
# good_examples: "rules/cloud/policies/aws/rds/disable_public_access.cf.go"

package builtin.aws.rds.aws0180

Expand All @@ -31,3 +31,9 @@ deny[res] {
instance.publicaccess.value
res := result.new("Instance has Public Access enabled", instance.publicaccess)
}

deny[res] {
instance := input.aws.rds.clusters[_].instances[_].instance
instance.publicaccess.value
res := result.new("Cluster instance has Public Access enabled", instance.publicaccess)
}
10 changes: 10 additions & 0 deletions rules/cloud/policies/aws/rds/disable_public_access_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ test_when_enabled {
r := deny with input as {"aws": {"rds": {"instances": [{"publicaccess": {"value": true}}]}}}
count(r) == 1
}

test_when_cluster_disabled {
r := deny with input as {"aws": {"rds": {"clusters": [{"instances": [{"instance": {"publicaccess": {"value": false}}}]}]}}}
count(r) == 0
}

test_when_cluster_enabled {
r := deny with input as {"aws": {"rds": {"clusters": [{"instances": [{"instance": {"publicaccess": {"value": true}}}]}]}}}
count(r) == 1
}
63 changes: 0 additions & 63 deletions rules/cloud/policies/aws/rds/no_public_db_access.go

This file was deleted.

72 changes: 0 additions & 72 deletions rules/cloud/policies/aws/rds/no_public_db_access_test.go

This file was deleted.