diff --git a/avd_docs/aws/cloudtrail/AVD-AWS-0187/docs.md b/avd_docs/aws/cloudtrail/AVD-AWS-0187/docs.md new file mode 100644 index 000000000..8ca1120b6 --- /dev/null +++ b/avd_docs/aws/cloudtrail/AVD-AWS-0187/docs.md @@ -0,0 +1,13 @@ + +Ensures CloudTrail encryption at rest is enabled for logs + +### Impact + + + +{{ remediationActions }} + +### Links +- https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html + + diff --git a/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption.rego b/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption.rego new file mode 100644 index 000000000..e324eb936 --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption.rego @@ -0,0 +1,25 @@ +# METADATA +# title: "CloudTrail Encryption" +# description: "Ensures CloudTrail encryption at rest is enabled for logs" +# scope: package +# schemas: +# - input: schema.input +# related_resources: +# - https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html +# custom: +# avd_id: AVD-AWS-0187 +# provider: aws +# service: cloudtrail +# severity: HIGH +# short_code: enable-at-rest-encryption +# recommended_action: "Enable CloudTrail log encryption through the CloudTrail console or API" +# input: +# selector: +# - type: cloud +package builtin.aws.cloudtrail.aws0187 + +deny[res] { + trail := input.aws.cloudtrail.trails[_] + trail.kmskeyid.value == "" + res := result.new("Trail is not encrypted.",trail.kmskeyid) +} \ No newline at end of file diff --git a/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption_test.rego b/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption_test.rego new file mode 100644 index 000000000..caef4a889 --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/cloudtrail/enable_at_rest_encryption_test.rego @@ -0,0 +1,11 @@ +package builtin.aws.cloudtrail.aws0187 + +test_detects_when_decrypted { + r := deny with input as {"aws": {"cloudtrail": {"trails": [{"kmskeyid": {"value": ""}}]}}} + count(r) == 1 +} + +test_when_encrypted { + r := deny with input as {"aws": {"cloudtrail": {"trails": [{"kmskeyid": {"value": "key12"}}]}}} + count(r) == 0 +}