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

fix: not to check DB instances in AVD-AWS-00 #360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 0 additions & 11 deletions checks/cloud/aws/documentdb/encryption_customer_key.rego
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ deny contains res if {
)
}

deny contains res if {
some cluster in input.aws.documentdb.clusters
some instance in cluster.instances
isManaged(instance)
without_cmk(instance)
res := result.new(
"Instance encryption does not use a customer-managed KMS key.",
metadata.obj_by_path(instance, ["kmskeyid"]),
)
}

without_cmk(obj) if value.is_empty(obj.kmskeyid)

without_cmk(obj) if not obj.kmskeyid
12 changes: 0 additions & 12 deletions checks/cloud/aws/documentdb/encryption_customer_key_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@ test_allow_cluster_with_kms_key if {
test.assert_empty(check.deny) with input as inp
}

test_allow_instance_with_kms_key if {
inp := {"aws": {"documentdb": {"clusters": [{"kmskeyid": {"value": "test"}, "instances": [{"kmskeyid": {"value": "test"}}]}]}}}

test.assert_empty(check.deny) with input as inp
}

test_disallow_cluster_without_kms_key if {
inp := {"aws": {"documentdb": {"clusters": [{"kmskeyid": {"value": ""}}]}}}

test.assert_equal_message("Cluster encryption does not use a customer-managed KMS key.", check.deny) with input as inp
}

test_disallow_instance_without_kms_key if {
inp := {"aws": {"documentdb": {"clusters": [{"kmskeyid": {"value": "test"}, "instances": [{"kmskeyid": {"value": ""}}]}]}}}

test.assert_equal_message("Instance encryption does not use a customer-managed KMS key.", check.deny) with input as inp
}
26 changes: 1 addition & 25 deletions test/rego/aws_document_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,12 @@ var awsDocumentDBTestCases = testCases{
expected: true,
},
{
name: "DocDB Instance encryption missing KMS key",
name: "DocDB Cluster encrypted with proper KMS keys",
input: state.State{AWS: aws.AWS{DocumentDB: documentdb.DocumentDB{
Clusters: []documentdb.Cluster{
{
Metadata: trivyTypes.NewTestMetadata(),
KMSKeyID: trivyTypes.String("kms-key", trivyTypes.NewTestMetadata()),
Instances: []documentdb.Instance{
{
Metadata: trivyTypes.NewTestMetadata(),
KMSKeyID: trivyTypes.String("", trivyTypes.NewTestMetadata()),
},
},
},
},
}}},
expected: true,
},
{
name: "DocDB Cluster and Instance encrypted with proper KMS keys",
input: state.State{AWS: aws.AWS{DocumentDB: documentdb.DocumentDB{
Clusters: []documentdb.Cluster{
{
Metadata: trivyTypes.NewTestMetadata(),
KMSKeyID: trivyTypes.String("kms-key", trivyTypes.NewTestMetadata()),
Instances: []documentdb.Instance{
{
Metadata: trivyTypes.NewTestMetadata(),
KMSKeyID: trivyTypes.String("kms-key", trivyTypes.NewTestMetadata()),
},
},
},
},
}}},
Expand Down
Loading