@aws/nx-plugin 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE-THIRD-PARTY +114 -244
  2. package/generators.json +1 -7
  3. package/package.json +1 -1
  4. package/src/cloudscape-website/app/README.md +84 -48
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +157 -218
  6. package/src/cloudscape-website/app/files/app/README.md.template +44 -0
  7. package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
  8. package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
  9. package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
  10. package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
  11. package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
  12. package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
  13. package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +74 -144
  14. package/src/cloudscape-website/app/generator.js +74 -64
  15. package/src/cloudscape-website/app/generator.js.map +1 -1
  16. package/src/cloudscape-website/app/schema.d.ts +3 -4
  17. package/src/cloudscape-website/app/schema.json +1 -24
  18. package/src/cloudscape-website/cognito-auth/README.md +53 -32
  19. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +161 -125
  20. package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
  21. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
  22. package/src/cloudscape-website/cognito-auth/generator.js +129 -46
  23. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
  24. package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
  25. package/src/cloudscape-website/cognito-auth/schema.json +7 -1
  26. package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +15 -17
  27. package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
  28. package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
  29. package/src/cloudscape-website/runtime-config/generator.js +3 -1
  30. package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
  31. package/src/infra/app/README.md +71 -46
  32. package/src/infra/app/__snapshots__/generator.spec.ts.snap +114 -252
  33. package/src/infra/app/files/app/README.md.template +76 -0
  34. package/src/infra/app/files/app/src/main.ts.template +18 -0
  35. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
  36. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
  37. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
  38. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
  39. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
  40. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
  41. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
  42. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
  43. package/src/infra/app/generator.js +17 -3
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/infra/app/schema.d.ts +10 -1
  46. package/src/infra/app/schema.json +16 -8
  47. package/src/trpc/backend/README.md +102 -80
  48. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +37 -17
  49. package/src/trpc/backend/files/backend/README.md.template +33 -0
  50. package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
  51. package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
  52. package/src/trpc/backend/files/schema/README.md.template +33 -0
  53. package/src/trpc/backend/generator.js +29 -43
  54. package/src/trpc/backend/generator.js.map +1 -1
  55. package/src/trpc/backend/schema.d.ts +3 -1
  56. package/src/trpc/backend/schema.json +8 -13
  57. package/src/trpc/react/README.md +46 -66
  58. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
  59. package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
  60. package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
  61. package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
  62. package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
  63. package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
  64. package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
  65. package/src/trpc/react/generator.js +123 -24
  66. package/src/trpc/react/generator.js.map +1 -1
  67. package/src/trpc/react/schema.json +2 -2
  68. package/src/ts/cjs-to-esm/generator.js.map +1 -1
  69. package/src/ts/lib/eslint.d.ts +1 -1
  70. package/src/ts/lib/eslint.js +59 -11
  71. package/src/ts/lib/eslint.js.map +1 -1
  72. package/src/ts/lib/files/README.md.template +33 -0
  73. package/src/ts/lib/generator.js +11 -4
  74. package/src/ts/lib/generator.js.map +1 -1
  75. package/src/ts/lib/schema.d.ts +1 -3
  76. package/src/ts/lib/schema.json +2 -15
  77. package/src/ts/lib/ts-project-utils.js.map +1 -1
  78. package/src/ts/lib/vitest.js +14 -0
  79. package/src/ts/lib/vitest.js.map +1 -1
  80. package/src/utils/ast.d.ts +13 -0
  81. package/src/utils/ast.js +102 -0
  82. package/src/utils/ast.js.map +1 -0
  83. package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
  84. package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
  85. package/src/utils/files/common/constructs/src/index.ts.template +2 -1
  86. package/src/utils/files/common/readme/README.md.template +33 -0
  87. package/src/utils/files/common/types/src/runtime-config.ts.template +1 -13
  88. package/src/utils/format.js.map +1 -1
  89. package/src/utils/names.d.ts +2 -0
  90. package/src/utils/names.js +27 -0
  91. package/src/utils/names.js.map +1 -0
  92. package/src/utils/npm-scope.js.map +1 -1
  93. package/src/utils/paths.js.map +1 -1
  94. package/src/utils/shared-constructs.js +37 -4
  95. package/src/utils/shared-constructs.js.map +1 -1
  96. package/src/utils/versions.d.ts +15 -9
  97. package/src/utils/versions.js +14 -8
  98. package/src/utils/versions.js.map +1 -1
  99. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
  100. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
  101. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
  102. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
  103. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
  104. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
  105. package/src/gitlab/generator.d.ts +0 -8
  106. package/src/gitlab/generator.js +0 -16
  107. package/src/gitlab/generator.js.map +0 -1
  108. package/src/gitlab/schema.d.ts +0 -9
  109. package/src/gitlab/schema.json +0 -52
  110. package/src/infra/app/files/src/main.ts.template +0 -37
  111. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
  112. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
  113. /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
  114. /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
  115. /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
@@ -0,0 +1,2807 @@
1
+ ## Config Rule Name : emr-kerberos-enabled
2
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/EMR_KERBEROS_ENABLED.html"
3
+
4
+ #
5
+ #####################################
6
+ ## Gherkin ##
7
+ #####################################
8
+ # Rule Identifier:
9
+ # IAM_NO_INLINE_POLICY_CHECK
10
+ #
11
+ # Description:
12
+ # Checks that inline policy feature is not in use.
13
+ #
14
+ # Reports on:
15
+ # AWS::IAM::User
16
+ # AWS::IAM::Role
17
+ # AWS::IAM::Group
18
+ #
19
+ # Evaluates:
20
+ # AWS CloudFormation
21
+ #
22
+ # Rule Parameters:
23
+ # NA
24
+ #
25
+ # Scenarios:
26
+ # a) SKIP: when there are no IAM Users, Roles, or Groups present
27
+ # b) PASS: when all IAM Users, Roles, or Groups present have no inline policies listed
28
+ # c) FAIL: when any IAM Users, Roles, or Groups present have inline policies listed
29
+ # d) SKIP: when metada has rule suppression for IAM_NO_INLINE_POLICY_CHECK
30
+
31
+ #
32
+ # Select all IAM User, Role, and Group resources from incoming template (payload)
33
+ #
34
+ let aws_iam_entities_no_inline_policy = Resources.*[
35
+ Type in [ /AWS::IAM::User/,
36
+ /AWS::IAM::Role/,
37
+ /AWS::IAM::Group/ ]
38
+ Metadata.guard.SuppressedRules not exists or
39
+ Metadata.guard.SuppressedRules.* != "IAM_NO_INLINE_POLICY_CHECK"
40
+ ]
41
+
42
+ rule IAM_NO_INLINE_POLICY_CHECK when %aws_iam_entities_no_inline_policy !empty {
43
+ %aws_iam_entities_no_inline_policy.Properties.Policies empty
44
+ <<
45
+ Guard Rule Set: hipaa-security
46
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(A),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1)
47
+ Violation: Inline policies are not allowed on IAM Users, Roles, or Groups.
48
+ Fix: Remove the Policies list property from any IAM Users, Roles, or Groups.
49
+ >>
50
+ }
51
+
52
+ #
53
+ #####################################
54
+ ## Gherkin ##
55
+ #####################################
56
+ # Rule Identifier:
57
+ # IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS
58
+ #
59
+ # Description:
60
+ # Checks the IAM policies that you create for Allow statements that grant permissions to all actions on all resources.
61
+ #
62
+ # Reports on:
63
+ # AWS::IAM::Policy
64
+ #
65
+ # Evaluates:
66
+ # AWS CloudFormation
67
+ #
68
+ # Rule Parameters:
69
+ # NA
70
+ #
71
+ # Scenarios:
72
+ # a) SKIP: when there are no IAM Policies present
73
+ # b) PASS: when all IAM Policies do not grant permissions to all actions on all resources
74
+ # c) FAIL: when any IAM Policies grant permissions to all actions on all resources
75
+ # d) SKIP: when metada has rule suppression for IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS
76
+
77
+ #
78
+ # Select all IAM Policy resources from incoming template (payload)
79
+ #
80
+ let aws_iam_policies_no_statements_with_admin_access = Resources.*[ Type == 'AWS::IAM::Policy'
81
+ Metadata.guard.SuppressedRules not exists or
82
+ Metadata.guard.SuppressedRules.* != "IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS"
83
+ ]
84
+
85
+ rule IAM_POLICY_NO_STATEMENTS_WITH_ADMIN_ACCESS when %aws_iam_policies_no_statements_with_admin_access !empty {
86
+ let violations = Resources.*[
87
+ Type == 'AWS::IAM::Policy'
88
+ some Properties.PolicyDocument.Statement[*] {
89
+ some Action[*] == "*"
90
+ Effect == "Allow"
91
+ Resource == "*"
92
+ }
93
+ ]
94
+ %violations empty
95
+ <<
96
+ Guard Rule Set: hipaa-security
97
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(A),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1)
98
+ Violation: One or more IAM policies contain allow statements that grant permissions to all actions on all resources
99
+ Fix: Remove policy statements that match {"Effect": "Allow", "Action": "*", "Resource": "*"}
100
+ >>
101
+ }
102
+
103
+
104
+
105
+ #
106
+ #####################################
107
+ ## Gherkin ##
108
+ #####################################
109
+ # Rule Identifier:
110
+ # IAM_USER_NO_POLICIES_CHECK
111
+ #
112
+ # Description:
113
+ # Checks that none of your IAM users have policies attached. IAM users must inherit permissions from IAM groups or roles.
114
+ #
115
+ # Reports on:
116
+ # AWS::IAM::User
117
+ #
118
+ # Evaluates:
119
+ # AWS CloudFormation
120
+ #
121
+ # Rule Parameters:
122
+ # NA
123
+ #
124
+ # Scenarios:
125
+ # a) SKIP: when there are no IAM Users present
126
+ # b) PASS: when all IAM Users do not have policies attached
127
+ # c) FAIL: when any IAM User have policies attached
128
+ # d) SKIP: when metada has rule suppression for IAM_USER_NO_POLICIES_CHECK
129
+
130
+ #
131
+ # Select all IAM User resources from incoming template (payload)
132
+ #
133
+ let aws_iam_users_no_policies = Resources.*[ Type == 'AWS::IAM::User'
134
+ Metadata.guard.SuppressedRules not exists or
135
+ Metadata.guard.SuppressedRules.* != "IAM_USER_NO_POLICIES_CHECK"
136
+ ]
137
+
138
+ rule IAM_USER_NO_POLICIES_CHECK when %aws_iam_users_no_policies !empty {
139
+ %aws_iam_users_no_policies.Properties.Policies empty
140
+ <<
141
+ Guard Rule Set: hipaa-security
142
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(A),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1)
143
+ Violation: Inline policies are not allowed on IAM Users. IAM users must inherit permissions from IAM groups or roles.
144
+ Fix: Remove the Policies list property from any IAM Users.
145
+ >>
146
+ }
147
+
148
+ ## Config Rule Name : s3-bucket-policy-grantee-check
149
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/s3-bucket-policy-grantee-check.html
150
+
151
+ # Rule Intent: Checks that the access granted by the Amazon S3 bucket is restricted by any of the AWS principals, federated users, service principals, IP addresses, or VPCs that you provide.
152
+
153
+ #
154
+ #####################################
155
+ ## Gherkin ##
156
+ #####################################
157
+ # Rule Identifier:
158
+ # IAM_POLICY_NO_STATEMENTS_WITH_FULL_ACCESS
159
+ #
160
+ # Description:
161
+ # Checks if AWS Identity and Access Management (IAM) policies grant permissions to all actions on individual AWS resources.
162
+ #
163
+ # Reports on:
164
+ # AWS::IAM::ManagedPolicy
165
+ #
166
+ # Evaluates:
167
+ # AWS CloudFormation
168
+ #
169
+ # Rule Parameters:
170
+ # NA
171
+ #
172
+ # Scenarios:
173
+ # a) SKIP: when there are no IAM Managed Policies present
174
+ # b) PASS: when all IAM Managed Policies do not allows full access to at least 1 AWS service
175
+ # c) FAIL: when any IAM Managed Policies allows full access to at least 1 AWS service.
176
+ # d) SKIP: when metada has rule suppression for IAM_POLICY_NO_STATEMENTS_WITH_FULL_ACCESS
177
+
178
+ #
179
+ # Select all IAM Managed Policy resources from incoming template (payload)
180
+ #
181
+ let aws_iam_managed_policies_no_statements_with_full_access = Resources.*[ Type == 'AWS::IAM::ManagedPolicy'
182
+ Metadata.guard.SuppressedRules not exists or
183
+ Metadata.guard.SuppressedRules.* != "IAM_POLICY_NO_STATEMENTS_WITH_FULL_ACCESS"
184
+ ]
185
+
186
+ rule IAM_POLICY_NO_STATEMENTS_WITH_FULL_ACCESS when %aws_iam_managed_policies_no_statements_with_full_access !empty {
187
+ let violations = Resources.*[
188
+ Type == 'AWS::IAM::ManagedPolicy'
189
+ some Properties.PolicyDocument.Statement[*] {
190
+ some Action[*] in ["*", /^[a-zA-Z0-9]*:\*$/]
191
+ Effect == "Allow"
192
+ Resource == "*"
193
+ }
194
+ ]
195
+ %violations empty
196
+ <<
197
+ Guard Rule Set: hipaa-security
198
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(A),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1)
199
+ Violation: One or more IAM Managed Policies allow full access to at least 1 AWS service
200
+ Fix: Remove policy statements that match {"Effect": "Allow", "Action": "<service-name>:*" ... } or {"Effect": "Allow", "Action": "*" ... }
201
+ >>
202
+ }
203
+ #
204
+ #####################################
205
+ ## Gherkin ##
206
+ #####################################
207
+ # Rule Identifier:
208
+ # EC2_INSTANCE_PROFILE_ATTACHED
209
+ #
210
+ # Description:
211
+ # Checks if an Amazon Elastic Compute Cloud (Amazon EC2) instance has an Identity and Access Management (IAM) profile attached to it.
212
+ #
213
+ # Reports on:
214
+ # AWS::EC2::Instance
215
+ #
216
+ # Evaluates:
217
+ # AWS CloudFormation
218
+ #
219
+ # Rule Parameters:
220
+ # NA
221
+ #
222
+ # Scenarios:
223
+ # a) SKIP: when no EC2 Instance resources are present
224
+ # b) PASS: when all EC2 Instace resources have an associated IAM instance profile
225
+ # d) FAIL: when any EC2 Instace resources do not have an associated IAM instance profile
226
+ # e) SKIP: hen metadata includes the suppression for rule EC2_INSTANCE_PROFILE_ATTACHED
227
+
228
+ #
229
+ # Select all EC2 Instance resources from incoming template (payload)
230
+ #
231
+ let ec2_instances_profile_attached = Resources.*[ Type == 'AWS::EC2::Instance'
232
+ Metadata.guard.SuppressedRules not exists or
233
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCE_PROFILE_ATTACHED"
234
+ ]
235
+
236
+ rule EC2_INSTANCE_PROFILE_ATTACHED when %ec2_instances_profile_attached !empty {
237
+ %ec2_instances_profile_attached.Properties.IamInstanceProfile EXISTS
238
+ <<
239
+ Guard Rule Set: hipaa-security
240
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(A),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1)
241
+ Violation: EC2 Instances must have IAM profile attached to it.
242
+ Fix: Associate the EC2 Instance property IamInstanceProfile with an IAM Instance Profile.
243
+ >>
244
+ }
245
+
246
+ #
247
+ #####################################
248
+ ## Gherkin ##
249
+ #####################################
250
+ # Rule Identifier:
251
+ # DMS_REPLICATION_NOT_PUBLIC
252
+ #
253
+ # Description:
254
+ # Checks whether AWS Database Migration Service replication instances are not set to allow public.
255
+ #
256
+ # Reports on:
257
+ # AWS::DMS::ReplicationInstance
258
+ #
259
+ # Evaluates:
260
+ # AWS CloudFormation
261
+ #
262
+ # Rule Parameters:
263
+ # NA
264
+ #
265
+ # Scenarios:
266
+ # a) SKIP: when there is no DMS Replication Instance present
267
+ # b) FAIL: When DMS Replication Instance is present and PubliclyAccessible property is set to true
268
+ # c) PASS: When DMS Replication Instance is present and PubliclyAccessible property is set to false
269
+ # c) PASS: When DMS Replication Instance is present and PubliclyAccessible property is not set
270
+ # d) SKIP: when metada has rule suppression for DMS_REPLICATION_NOT_PUBLIC
271
+
272
+ #
273
+ # Select all Redshift cluster resources from incoming template
274
+ #
275
+
276
+ let dms_replication_instances = Resources.*[ Type == 'AWS::DMS::ReplicationInstance'
277
+ Metadata.guard.SuppressedRules not exists or
278
+ Metadata.guard.SuppressedRules.* != "DMS_REPLICATION_NOT_PUBLIC"
279
+ ]
280
+
281
+ rule DMS_REPLICATION_NOT_PUBLIC when %dms_replication_instances !empty {
282
+ %dms_replication_instances.Properties.PubliclyAccessible exists
283
+ %dms_replication_instances.Properties.PubliclyAccessible == false
284
+ <<
285
+ Guard Rule Set: hipaa-security
286
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
287
+ Violation: AWS Database Migration Service replication instances should not be public.
288
+ Fix: Set the DMS Replication Instance property PubliclyAccessible parameter to true.
289
+ >>
290
+ }
291
+ #
292
+ #####################################
293
+ ## Gherkin ##
294
+ #####################################
295
+ # Rule Identifier:
296
+ # EC2_INSTANCE_NO_PUBLIC_IP
297
+ #
298
+ # Description:
299
+ # Checks whether Amazon Elastic Compute Cloud (Amazon EC2) instances have a public IP association.
300
+ #
301
+ # Reports on:
302
+ # AWS::EC2::Instance
303
+ #
304
+ # Evaluates:
305
+ # AWS CloudFormation
306
+ #
307
+ # Rule Parameters:
308
+ # NA
309
+ #
310
+ # Scenarios:
311
+ # a) SKIP: when no EC2 Instance resources are present
312
+ # b) SKIP: when no EC2 Instances have network interfaces defined
313
+ # c) PASS: when no EC2 Instances with network interfaces have associated public IP addresses
314
+ # d) FAIL: when any EC2 Instances with network interfaces have associated public IP addresses
315
+ # e) SKIP: hen metadata includes the suppression for rule EC2_INSTANCE_NO_PUBLIC_IP
316
+
317
+ #
318
+ # Select all EC2 Instance resources from incoming template (payload)
319
+ #
320
+ let ec2_instances_no_public_ip = Resources.*[Type == 'AWS::EC2::Instance'
321
+ Properties.NetworkInterfaces[*] !empty
322
+ Metadata.guard.SuppressedRules not exists or
323
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCE_NO_PUBLIC_IP"
324
+ ]
325
+
326
+ rule EC2_INSTANCE_NO_PUBLIC_IP when %ec2_instances_no_public_ip !empty {
327
+ %ec2_instances_no_public_ip.Properties.NetworkInterfaces[*] {
328
+ AssociatePublicIpAddress !exists OR
329
+ AssociatePublicIpAddress == false
330
+ <<
331
+ Guard Rule Set: hipaa-security
332
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
333
+ Violation: EC2 Instances cannot have public IP addresses associated with their network interfaces
334
+ Fix: remove the AssociatePublicIpAddress property from NetworkInterfaces list or set it to false
335
+ >>
336
+ }
337
+ }
338
+
339
+
340
+ #
341
+ #####################################
342
+ ## Gherkin ##
343
+ #####################################
344
+ # Rule Identifier:
345
+ # ELASTICSEARCH_IN_VPC_ONLY
346
+ #
347
+ # Description:
348
+ # Elasticsearch domains must be in a VPC
349
+ #
350
+ # Reports on:
351
+ # AWS::Elasticsearch::Domain
352
+ #
353
+ # Evaluates:
354
+ # AWS CloudFormation
355
+ #
356
+ # Rule Parameters:
357
+ # NA
358
+ #
359
+ # Scenarios:
360
+ # a) SKIP: when there is no elasticsearch domain present
361
+ # b) FAIL: when elasticsearch domain does not have VPCOptions or Endpoint properties
362
+ # c) PASS: when elasticsearch domain has VPCOptions or Endpoint properties
363
+ # d) SKIP: when metada has rule suppression for ELASTICSEARCH_IN_VPC_ONLY
364
+
365
+ #
366
+ # Select all elasticsearch domains from incoming template
367
+ #
368
+ let elasticsearch_domains_vpc_required = Resources.*[ Type == 'AWS::Elasticsearch::Domain'
369
+ Metadata.guard.SuppressedRules not exists or
370
+ Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_IN_VPC_ONLY"
371
+ ]
372
+
373
+ rule ELASTICSEARCH_IN_VPC_ONLY when %elasticsearch_domains_vpc_required !empty {
374
+ %elasticsearch_domains_vpc_required.Properties.VPCOptions EXISTS
375
+ <<
376
+ Guard Rule Set: hipaa-security
377
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
378
+ Violation: Elasticsearch domains must be in a VPC.
379
+ Fix: Provide VPCOptions object to enable opensearch to function in a VPC.
380
+ >>
381
+ }
382
+ ## Config Rule Name : emr-master-no-public-ip
383
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/emr-master-no-public-ip.html"
384
+
385
+ #
386
+ #####################################
387
+ ## Gherkin ##
388
+ #####################################
389
+ # Rule Identifier:
390
+ # EC2_INSTANCES_IN_VPC
391
+ #
392
+ # Description:
393
+ # Checks if your EC2 instances belong to a virtual private cloud (VPC).
394
+ #
395
+ # Reports on:
396
+ # AWS::EC2::Instance
397
+ #
398
+ # Evaluates:
399
+ # AWS CloudFormation
400
+ #
401
+ # Rule Parameters:
402
+ # NA
403
+ #
404
+ # Scenarios:
405
+ # a) SKIP: when there are no EC2 resource present
406
+ # b) PASS: when all EC2 resources have the SubnetId property set
407
+ # c) FAIL: when any EC2 resources do not have the SubnetId property set
408
+ # d) SKIP: when metadata includes the suppression for rule EC2_INSTANCES_IN_VPC
409
+
410
+ #
411
+ # Select all ECS Instance resources from incoming template (payload)
412
+ #
413
+ let ec2_instances_in_vpc = Resources.*[ Type == 'AWS::EC2::Instance'
414
+ Metadata.guard.SuppressedRules not exists or
415
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCES_IN_VPC"
416
+ ]
417
+
418
+ rule EC2_INSTANCES_IN_VPC when %ec2_instances_in_vpc !empty {
419
+ %ec2_instances_in_vpc.Properties.SubnetId !empty
420
+ <<
421
+ Guard Rule Set: hipaa-security
422
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
423
+ Violation: EC2 Instances must belong to a VPC
424
+ Fix: set the SubnetId property to a subnet ID
425
+ >>
426
+ }
427
+ #
428
+ #####################################
429
+ ## Gherkin ##
430
+ #####################################
431
+ # Rule Identifier:
432
+ # LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED
433
+ #
434
+ # Description:
435
+ # Checks if the AWS Lambda function policy attached to the Lambda resource prohibits public access.
436
+ #
437
+ # Reports on:
438
+ # AWS::Lambda::Permission
439
+ # AWS::Lambda::LayerVersionPermission
440
+ #
441
+ # Evaluates:
442
+ # AWS CloudFormation
443
+ #
444
+ # Rule Parameters:
445
+ # NA
446
+ #
447
+ # Scenarios:
448
+ # a) SKIP: when no AWS Lambda permission policies are present
449
+ # b) PASS: when all AWS Lambda permission policies prohibit public access
450
+ # c) FAIL: when any AWS Lambda permission policies allow public access
451
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED
452
+
453
+ #
454
+ # Select all AWS Lambda Permission resources from incoming template (payload)
455
+ #
456
+ let aws_lambda_permissions_public_access_prohibited = Resources.*[
457
+ Type in [ /AWS::Lambda::Permission/,
458
+ /AWS::Lambda::LayerVersionPermission/ ]
459
+ Metadata.guard.SuppressedRules not exists or
460
+ Metadata.guard.SuppressedRules.* != "LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED"
461
+ ]
462
+
463
+ rule LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED when %aws_lambda_permissions_public_access_prohibited !empty {
464
+
465
+ # Lambda permission policy where principal is an account id
466
+ %aws_lambda_permissions_public_access_prohibited {
467
+ Type == 'AWS::Lambda::Permission'
468
+ Properties {
469
+ Principal in [ /^\d{12}$/, "AWS::AccountId" ]
470
+ OR Principal > 0
471
+ }
472
+ }
473
+
474
+ # Lambda permission policy where principal is a service (not s3)
475
+ OR %aws_lambda_permissions_public_access_prohibited {
476
+ Type == 'AWS::Lambda::Permission'
477
+ Properties {
478
+ Principal != 's3.amazonaws.com'
479
+ PrincipalOrgID !empty
480
+ OR SourceAccount exists
481
+ OR SourceArn !empty
482
+ <<
483
+ Guard Rule Set: hipaa-security
484
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
485
+ Violation: All Lambda permission policies attached to Lambda resources must prohibit public access.
486
+ Fix: Limit permission policies by setting the Principal property to an account ID,
487
+ or limiting a service principal by setting the SourceArn, SourceAccount, or PrincipalOrgID properties.
488
+ >>
489
+ }
490
+ }
491
+
492
+ # Lambda permission policy where principal is s3 service
493
+ OR %aws_lambda_permissions_public_access_prohibited {
494
+ Type == 'AWS::Lambda::Permission'
495
+ Properties {
496
+ Principal == 's3.amazonaws.com'
497
+ PrincipalOrgID !empty
498
+ OR SourceAccount exists
499
+ <<
500
+ Guard Rule Set: hipaa-security
501
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
502
+ Violation: All Lambda permission policies attached to Lambda resources must prohibit public access.
503
+ Fix: Limit permission policies by setting the Principal property to an account ID,
504
+ or for S3 as the principal specify either a SourceAccount or PrincipalOrgID.
505
+ Note: It is possible for an S3 bucket to be deleted by its owner and recreated by another account.
506
+ >>
507
+ }
508
+ }
509
+
510
+ # Lambda layer version permission policies
511
+ OR %aws_lambda_permissions_public_access_prohibited {
512
+ Type == 'AWS::Lambda::LayerVersionPermission'
513
+ Properties {
514
+ OrganizationId !empty
515
+ OR Principal in [ /^\d{12}$/, "AWS::AccountId" ]
516
+ OR Principal > 0
517
+ <<
518
+ Guard Rule Set: hipaa-security
519
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
520
+ Violation: All Lambda permission policies attached to Lambda resources must prohibit public access.
521
+ Fix: For Lambda layer version permission policies, either limit permissions by the OrganizationId property
522
+ or set the Principal property to an account ID rather than using a wildcard (*).
523
+ >>
524
+ }
525
+ }
526
+ }
527
+
528
+ #
529
+ #####################################
530
+ ## Gherkin ##
531
+ #####################################
532
+ # Rule Identifier:
533
+ # LAMBDA_INSIDE_VPC
534
+ #
535
+ # Description:
536
+ # Checks whether an AWS Lambda function is allowed access to an Amazon Virtual Private Cloud.
537
+ #
538
+ # Reports on:
539
+ # AWS::Lambda::Function
540
+ #
541
+ # Evaluates:
542
+ # AWS CloudFormation
543
+ #
544
+ # Rule Parameters:
545
+ # NA
546
+ #
547
+ # Scenarios:
548
+ # a) SKIP: when no AWS Lambda functions are present
549
+ # b) PASS: when all AWS Lambda functions are VPC enabled
550
+ # c) FAIL: when any AWS Lambda functions are not VPC enabled
551
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_INSIDE_VPC
552
+
553
+ #
554
+ # Select all AWS Lambda Function resources from incoming template (payload)
555
+ #
556
+ let aws_lambda_functions_inside_vpc = Resources.*[ Type == 'AWS::Lambda::Function'
557
+ Metadata.guard.SuppressedRules not exists or
558
+ Metadata.guard.SuppressedRules.* != "LAMBDA_INSIDE_VPC"
559
+ ]
560
+
561
+ rule LAMBDA_INSIDE_VPC when %aws_lambda_functions_inside_vpc !empty {
562
+ %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SecurityGroupIds !empty
563
+ %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SubnetIds !empty
564
+ <<
565
+ Guard Rule Set: hipaa-security
566
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
567
+ Violation: All AWS Lambda Functions must be configured with access to a VPC
568
+ Fix: set the VpcConfig.SecurityGroupIds and VpcConfig.SubnetIds parameters with a list of security groups and subnets.
569
+ Lambda creates an elastic network interface for each combination of security group and subnet in the function's VPC configuration.
570
+ >>
571
+ }
572
+ #
573
+ #####################################
574
+ ## Gherkin ##
575
+ #####################################
576
+ # Rule Identifier:
577
+ # RDS_INSTANCE_PUBLIC_ACCESS_CHECK
578
+ #
579
+ # Description:
580
+ # Checks if an RDS instances has Publicly Accessible not set.
581
+ #
582
+ # Reports on:
583
+ # AWS::RDS::DBInstance
584
+ #
585
+ # Evaluates:
586
+ # AWS CloudFormation
587
+ #
588
+ # Rule Parameters:
589
+ # NA
590
+ #
591
+ # Scenarios:
592
+ # a) SKIP: when there are no RDS instances present
593
+ # b) PASS: when all RDS instances have PubliclyAccessible set to true
594
+ # c) FAIL: when all RDS instances have PubliclyAccessible set to false
595
+ # d) FAIL: when there are RDS instances with PubliclyAccessible property is not present
596
+ # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK
597
+
598
+ #
599
+ # Select all RDS instance resources from incoming template (payload)
600
+ #
601
+ let aws_rds_instances_not_public = Resources.*[ Type == 'AWS::RDS::DBInstance'
602
+ Metadata.guard.SuppressedRules not exists or
603
+ Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_PUBLIC_ACCESS_CHECK"
604
+ ]
605
+
606
+ rule RDS_INSTANCE_PUBLIC_ACCESS_CHECK when %aws_rds_instances_not_public !empty {
607
+ # ALL RDS instances must have PubliclyAccessible set to false
608
+ %aws_rds_instances_not_public.Properties.PubliclyAccessible == false
609
+ <<
610
+ Guard Rule Set: hipaa-security
611
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
612
+ Violation: All RDS instances must not be publicly accessible.
613
+ Fix: Set the PubliclyAccessible to false.
614
+ >>
615
+ }
616
+
617
+ #
618
+ #####################################
619
+ ## Gherkin ##
620
+ #####################################
621
+ # Rule Identifier:
622
+ # REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK
623
+ #
624
+ # Description:
625
+ # Redshift cluster should not be publicly accessible on the internet.
626
+ #
627
+ # Reports on:
628
+ # AWS::EKS::Cluster
629
+ #
630
+ # Evaluates:
631
+ # AWS CloudFormation
632
+ #
633
+ # Rule Parameters:
634
+ # NA
635
+ #
636
+ # Scenarios:
637
+ # a) SKIP: when there is no Redshift cluster present
638
+ # b) PASS: when Redshift Cluster resources do not have the publiclyAccessible property set (default false)
639
+ # c) PASS: when Redshift Cluster resources have the PubliclyAccessible property set to false
640
+ # d) FAIL: when any Redshift Cluster resources have the PubliclyAccessible property set to true
641
+ # e) SKIP: when metada includes the suppression for rule REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK
642
+
643
+ #
644
+ # Select all Redshift cluster resources from incoming template
645
+ #
646
+
647
+ let aws_redshift_clusters_resources_public_access_check = Resources.*[ Type == 'AWS::Redshift::Cluster'
648
+ Metadata.guard.SuppressedRules not exists or
649
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK"
650
+ ]
651
+
652
+
653
+ rule REDSHIFT_CLUSTER_PUBLIC_ACCESS_CHECK when %aws_redshift_clusters_resources_public_access_check !empty {
654
+ %aws_redshift_clusters_resources_public_access_check.Properties.PubliclyAccessible not exists or
655
+ %aws_redshift_clusters_resources_public_access_check.Properties.PubliclyAccessible == false
656
+
657
+ <<
658
+ Guard Rule Set: hipaa-security
659
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
660
+ Violation: Redshift cluster should not be available to public.
661
+ Fix: Set the Redshift property PubliclyAccessible parameter to false.
662
+ >>
663
+ }
664
+
665
+ #
666
+ #####################################
667
+ ## Gherkin ##
668
+ #####################################
669
+ # Rule Identifier:
670
+ # S3_BUCKET_PUBLIC_READ_PROHIBITED
671
+ #
672
+ # Description:
673
+ # Checks if your Amazon S3 buckets do not allow public read access. The rule checks the Block Public
674
+ # Access settings, the bucket policy, and the bucket access control list (ACL).
675
+ #
676
+ # Reports on:
677
+ # AWS::S3::Bucket
678
+ #
679
+ # Evaluates:
680
+ # AWS CloudFormation
681
+ #
682
+ # Rule Parameters:
683
+ # NA
684
+ #
685
+ # Scenarios:
686
+ # a) SKIP: when there are no S3 resource present
687
+ # b) PASS: when all S3 resources Public Access Block Configuration element is present and properties are set to true
688
+ # c) FAIL: when all S3 resources do not have the Public Access Block Configuration element present or all properties set to true
689
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_PUBLIC_READ_PROHIBITED
690
+
691
+ #
692
+ # Select all S3 resources from incoming template (payload)
693
+ #
694
+ let s3_bucket_public_read_prohibited = Resources.*[ Type == 'AWS::S3::Bucket'
695
+ Metadata.guard.SuppressedRules not exists or
696
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_PUBLIC_READ_PROHIBITED"
697
+ ]
698
+
699
+ rule S3_BUCKET_PUBLIC_READ_PROHIBITED when %s3_bucket_public_read_prohibited !empty {
700
+ %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration exists
701
+ %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true
702
+ %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicPolicy == true
703
+ %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.IgnorePublicAcls == true
704
+ %s3_bucket_public_read_prohibited.Properties.PublicAccessBlockConfiguration.RestrictPublicBuckets == true
705
+ <<
706
+ Guard Rule Set: hipaa-security
707
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
708
+ Violation: S3 Bucket Public Write Access controls need to be restricted.
709
+ Fix: Set S3 Bucket PublicAccessBlockConfiguration properties for BlockPublicAcls, BlockPublicPolicy, IgnorePublicAcls, RestrictPublicBuckets parameters to true.
710
+ >>
711
+ }
712
+ #
713
+ #####################################
714
+ ## Gherkin ##
715
+ #####################################
716
+ # Rule Identifier:
717
+ # S3_BUCKET_PUBLIC_WRITE_PROHIBITED
718
+ #
719
+ # Description:
720
+ # Checks if your Amazon S3 buckets do not allow public write access. The rule checks the Block Public
721
+ # Access settings, the bucket policy, and the bucket access control list (ACL).
722
+ #
723
+ # Reports on:
724
+ # AWS::S3::Bucket
725
+ #
726
+ # Evaluates:
727
+ # AWS CloudFormation
728
+ #
729
+ # Rule Parameters:
730
+ # NA
731
+ #
732
+ # Scenarios:
733
+ # a) SKIP: when there are no S3 resource present
734
+ # b) PASS: when all S3 resources Public Access Block Configuration element is present and properties are set to true
735
+ # c) FAIL: when all S3 resources do not have the Public Access Block Configuration element present or all properties set to true
736
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_PUBLIC_WRITE_PROHIBITED
737
+
738
+ #
739
+ # Select all S3 resources from incoming template (payload)
740
+ #
741
+ let s3_buckets_public_write_prohibited = Resources.*[ Type == 'AWS::S3::Bucket'
742
+ Metadata.guard.SuppressedRules not exists or
743
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_PUBLIC_WRITE_PROHIBITED"
744
+ ]
745
+
746
+ rule S3_BUCKET_PUBLIC_WRITE_PROHIBITED when %s3_buckets_public_write_prohibited !empty {
747
+ %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration exists
748
+ %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true
749
+ %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicPolicy == true
750
+ %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.IgnorePublicAcls == true
751
+ %s3_buckets_public_write_prohibited.Properties.PublicAccessBlockConfiguration.RestrictPublicBuckets == true
752
+ <<
753
+ Guard Rule Set: hipaa-security
754
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
755
+ Violation: S3 Bucket Public Write Access controls need to be restricted.
756
+ Fix: Set S3 Bucket PublicAccessBlockConfiguration properties for BlockPublicAcls, BlockPublicPolicy, IgnorePublicAcls, RestrictPublicBuckets parameters to true.
757
+ >>
758
+ }
759
+ ## Config Rule Name : sagemaker-notebook-no-direct-internet-access
760
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/sagemaker-notebook-no-direct-internet-access.html"
761
+
762
+ #
763
+ #####################################
764
+ ## Gherkin ##
765
+ #####################################
766
+ # Rule Identifier:
767
+ # SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED
768
+ #
769
+ # Description:
770
+ # Checks if Amazon Virtual Private Cloud (Amazon VPC) subnets are assigned a public IP address.
771
+ #
772
+ # Reports on:
773
+ # AWS::EC2::Subnet
774
+ #
775
+ # Evaluates:
776
+ # AWS CloudFormation
777
+ #
778
+ # Rule Parameters:
779
+ # NA
780
+ #
781
+ # Scenarios:
782
+ # a) SKIP: when there are no EC2 Subnet resource present
783
+ # b) PASS: when all EC2 Subnet resources have the MapPublicIpOnLaunch property set to false or it is missing (default false)
784
+ # c) FAIL: when any EC2 Subnet resources have the MapPublicIpOnLaunch property set to true
785
+ # d) SKIP: hen metadata includes the suppression for rule SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED
786
+
787
+ #
788
+ # Select all EC2 Subnet resources from incoming template (payload)
789
+ #
790
+ let ec2_subnets_auto_assign_public_ip_disabled = Resources.*[ Type == 'AWS::EC2::Subnet'
791
+ Metadata.guard.SuppressedRules not exists or
792
+ Metadata.guard.SuppressedRules.* != "SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED"
793
+ ]
794
+
795
+ rule SUBNET_AUTO_ASSIGN_PUBLIC_IP_DISABLED when %ec2_subnets_auto_assign_public_ip_disabled !empty {
796
+ %ec2_subnets_auto_assign_public_ip_disabled.Properties.MapPublicIpOnLaunch !exists
797
+ OR %ec2_subnets_auto_assign_public_ip_disabled.Properties.MapPublicIpOnLaunch == false
798
+ <<
799
+ Guard Rule Set: hipaa-security
800
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
801
+ Violation: VPCs should not have subnets that are assigned a public IP address.
802
+ Fix: remove the MapPublicIpOnLaucnh property or set it to false
803
+ >>
804
+ }
805
+ #
806
+ #####################################
807
+ ## Gherkin ##
808
+ #####################################
809
+ # Rule Identifier:
810
+ # S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED
811
+ #
812
+ # Description:
813
+ # Checks if Amazon Simple Storage Service (Amazon S3) buckets are publicly accessible.
814
+ #
815
+ # Reports on:
816
+ # AWS::S3::Bucket
817
+ #
818
+ # Evaluates:
819
+ # AWS CloudFormation
820
+ #
821
+ # Rule Parameters:
822
+ # NA
823
+ #
824
+ # Scenarios:
825
+ # a) SKIP: when there are no S3 resource present
826
+ # b) PASS: when all S3 resources Public Access Block Configuration element is present and properties are set to true
827
+ # c) FAIL: when all S3 resources do not have the Public Access Block Configuration element present or all properties set to true
828
+ # d) SKIP: when metada has rule suppression for S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED
829
+
830
+ #
831
+ # Select all S3 resources from incoming template (payload)
832
+ #
833
+ let s3_buckets_level_public_access_prohibited = Resources.*[ Type == 'AWS::S3::Bucket'
834
+ Metadata.guard.SuppressedRules not exists or
835
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED"
836
+ ]
837
+
838
+ rule S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED when %s3_buckets_level_public_access_prohibited !empty {
839
+ %s3_buckets_level_public_access_prohibited.Properties.PublicAccessBlockConfiguration exists
840
+ %s3_buckets_level_public_access_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicAcls == true
841
+ %s3_buckets_level_public_access_prohibited.Properties.PublicAccessBlockConfiguration.BlockPublicPolicy == true
842
+ %s3_buckets_level_public_access_prohibited.Properties.PublicAccessBlockConfiguration.IgnorePublicAcls == true
843
+ %s3_buckets_level_public_access_prohibited.Properties.PublicAccessBlockConfiguration.RestrictPublicBuckets == true
844
+ <<
845
+ Guard Rule Set: hipaa-security
846
+ Controls: 164.308(a)(3)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
847
+ Violation: S3 Bucket Public Access controls need to be restricted.
848
+ Fix: Set S3 Bucket PublicAccessBlockConfiguration properties for BlockPublicAcls, BlockPublicPolicy, IgnorePublicAcls, RestrictPublicBuckets parameters to true.
849
+ >>
850
+ }
851
+ ## Config Rule Name : ecs-task-definition-user-for-host-mode-check
852
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/ECS_TASK_DEFINITION_USER_FOR_HOST_MODE_CHECK.html"
853
+
854
+ ## Config Rule Name : codebuild-project-envvar-awscred-check
855
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-envvar-awscred-check.html"
856
+
857
+ ## Config Rule Name : codebuild-project-source-repo-url-check
858
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-source-repo-url-check.html"
859
+
860
+ #
861
+ #####################################
862
+ ## Gherkin ##
863
+ #####################################
864
+ # Rule Identifier:
865
+ # RESTRICTED_INCOMING_TRAFFIC
866
+ #
867
+ # Description:
868
+ # Checks if the security groups in use do not allow unrestricted incoming TCP traffic to the specified ports.
869
+ #
870
+ # Reports on:
871
+ # AWS::EC2::SecurityGroup
872
+ #
873
+ # Evaluates:
874
+ # AWS CloudFormation
875
+ #
876
+ # Rule Parameters:
877
+ # NA
878
+ #
879
+ # Scenarios:
880
+ # a) SKIP: when there are no Security Groups resource present
881
+ # b) SKIP when there are no TCP or UDP ingress rules
882
+ # c) PASS: when all Security Groups do no allow any of the restricted common ports
883
+ # d) FAIL: when a Security Group allows any of the restricted common ports
884
+ # e) SKIP: when metadata includes the suppression for rule RESTRICTED_INCOMING_TRAFFIC
885
+
886
+ #
887
+ # Select all Security Group resources from incoming template (payload)
888
+ #
889
+ let aws_security_groups_restricted_incoming_traffic = Resources.*[ Type == 'AWS::EC2::SecurityGroup'
890
+ some Properties.SecurityGroupIngress[*] {
891
+ IpProtocol in ['tcp', 'udp']
892
+ }
893
+ Metadata.guard.SuppressedRules not exists or
894
+ Metadata.guard.SuppressedRules.* != "RESTRICTED_INCOMING_TRAFFIC"
895
+ ]
896
+
897
+ rule RESTRICTED_INCOMING_TRAFFIC when %aws_security_groups_restricted_incoming_traffic !empty {
898
+ let violations = Resources.*[
899
+ Type == 'AWS::EC2::SecurityGroup'
900
+ some Properties.SecurityGroupIngress[*] {
901
+ FromPort in [ 20, 21, 3389, 3306, 4333 ]
902
+ ToPort in [ 20, 21, 3389, 3306, 4333 ]
903
+ }
904
+ ]
905
+ %violations empty
906
+ <<
907
+ Guard Rule Set: hipaa-security
908
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
909
+ Violation: Security groups must not allow unrestricted incoming TCP/UDP traffic to the specified ports [20, 21, 3389, 3306, 4333].
910
+ Fix: change the FromPort and ToPort properties in the SecurityGroupIngress list
911
+ >>
912
+ }
913
+ #
914
+ #####################################
915
+ ## Gherkin ##
916
+ #####################################
917
+ # Rule Identifier:
918
+ # INCOMING_SSH_DISABLED
919
+ #
920
+ # Description:
921
+ # Checks if the incoming SSH traffic for the security groups is accessible.
922
+ #
923
+ # Reports on:
924
+ # AWS::EC2::SecurityGroup
925
+ #
926
+ # Evaluates:
927
+ # AWS CloudFormation
928
+ #
929
+ # Rule Parameters:
930
+ # NA
931
+ #
932
+ # Scenarios:
933
+ # a) SKIP: when no Security Group resources are present
934
+ # b) SKIP: when no SSH ingress is defined (port 22)
935
+ # c) PASS: when all Security Groups resources restrict the IP address of the incoming SSH traffic
936
+ # d) FAIL: when a Security Group allows SSH traffic from any IP address (0.0.0.0/0).
937
+ # e) SKIP: hen metadata includes the suppression for rule INCOMING_SSH_DISABLED
938
+
939
+ #
940
+ # Select all Security Group resources from incoming template (payload)
941
+ #
942
+ let aws_security_groups_restricted_ssh = Resources.*[
943
+ Type == 'AWS::EC2::SecurityGroup'
944
+ some Properties.SecurityGroupIngress[*] {
945
+ ToPort == 22
946
+ FromPort == 22
947
+ IpProtocol == "tcp"
948
+ }
949
+ Metadata.guard.SuppressedRules not exists or
950
+ Metadata.guard.SuppressedRules.* != "INCOMING_SSH_DISABLED"
951
+ ]
952
+
953
+ rule INCOMING_SSH_DISABLED when %aws_security_groups_restricted_ssh !empty {
954
+ %aws_security_groups_restricted_ssh.Properties.SecurityGroupIngress[*] != {CidrIp:"0.0.0.0/0", ToPort:22, FromPort:22, IpProtocol:"tcp"}
955
+ <<
956
+ Guard Rule Set: hipaa-security
957
+ Controls: 164.308(a)(3)(i),164.308(a)(3)(ii)(B),164.308(a)(4)(i),164.308(a)(4)(ii)(A),164.308(a)(4)(ii)(B),164.308(a)(4)(ii)(C),164.312(a)(1),164.312(e)(1)
958
+ Violation: IP addresses of the incoming SSH traffic in the security groups are restricted (CIDR other than 0.0.0.0/0)
959
+ Fix: set SecurityGroupIngress.CidrIp property to a more restrictive CIDR than 0.0.0.0/0
960
+ >>
961
+ }
962
+ ## Config Rule Name : autoscaling-launch-config-public-ip-disabled
963
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/AUTOSCALING_LAUNCH_CONFIG_PUBLIC_IP_DISABLED.html"
964
+
965
+ #
966
+ #####################################
967
+ ## Gherkin ##
968
+ #####################################
969
+ # Rule Identifier:
970
+ # CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED
971
+ #
972
+ # Description:
973
+ # Checks whether AWS CloudTrail trails are configured to send logs to Amazon CloudWatch logs.
974
+ # The trail is non-compliant if the CloudWatchLogsLogGroupArn property of the trail is empty.
975
+ #
976
+ # Reports on:
977
+ # AWS::CloudTrail::Trail
978
+ #
979
+ # Evaluates:
980
+ # AWS CloudFormation
981
+ #
982
+ # Rule Parameters:
983
+ # NA
984
+ #
985
+ # Scenarios:
986
+ # a) SKIP: when there are no CloudTrail Trails present
987
+ # b) PASS: when all CloudTrail Trails have CloudWatchLogsLogGroupArn parameter set
988
+ # c) FAIL: when there are CloudTrail Trails with CloudWatchLogsLogGroupArn property not present
989
+ # d) SKIP: when metada has rule suppression for CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED
990
+
991
+ #
992
+ # Select all CloudTrail Trail resources from incoming template (payload)
993
+ #
994
+ let cloudtrail_trails_cw_logs_enabled = Resources.*[ Type == 'AWS::CloudTrail::Trail'
995
+ Metadata.guard.SuppressedRules not exists or
996
+ Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED"
997
+ ]
998
+
999
+ rule CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED when %cloudtrail_trails_cw_logs_enabled !empty {
1000
+ %cloudtrail_trails_cw_logs_enabled.Properties.CloudWatchLogsLogGroupArn exists
1001
+ <<
1002
+ Guard Rule Set: hipaa-security
1003
+ Controls: 164.308(a)(3)(ii)(A),164.312(b)
1004
+ Violation: CloudTrail Trail should have logs exported to cloudwatch logs.
1005
+ Fix: Set the CloudWatchLogsLogGroupArn parameter to enable exporting to CloudWatch Logs.
1006
+ >>
1007
+ }
1008
+ #
1009
+ #####################################
1010
+ ## Gherkin ##
1011
+ #####################################
1012
+ # Rule Identifier:
1013
+ # CLOUDTRAIL_S3_DATAEVENTS_ENABLED
1014
+ #
1015
+ # Description:
1016
+ # Checks whether at least one AWS CloudTrail trail is logging Amazon S3 data events for all S3 buckets.
1017
+ #
1018
+ # Reports on:
1019
+ # AWS::CloudTrail::Trail
1020
+ #
1021
+ # Evaluates:
1022
+ # AWS CloudFormation
1023
+ #
1024
+ # Rule Parameters:
1025
+ # NA
1026
+ #
1027
+ # Scenarios:
1028
+ # a) SKIP: when there are no CloudTrail Trails present
1029
+ # b) PASS: when all CloudTrail Trails have EventSelectors parameter set
1030
+ # c) FAIL: when there are CloudTrail Trails with EventSelectors property not present
1031
+ # d) SKIP: when metada has rule suppression for CLOUDTRAIL_S3_DATAEVENTS_ENABLED
1032
+
1033
+ #
1034
+ # Select all CloudTrail Trail resources from incoming template (payload)
1035
+ #
1036
+ let cloudtrail_trails_dataevents = Resources.*[ Type == 'AWS::CloudTrail::Trail'
1037
+ Metadata.guard.SuppressedRules not exists or
1038
+ Metadata.guard.SuppressedRules.* != "CLOUDTRAIL_S3_DATAEVENTS_ENABLED"
1039
+ ]
1040
+
1041
+ rule CLOUDTRAIL_S3_DATAEVENTS_ENABLED when %cloudtrail_trails_dataevents !empty {
1042
+ %cloudtrail_trails_dataevents.Properties.EventSelectors EXISTS
1043
+ some %cloudtrail_trails_dataevents.Properties.EventSelectors.* == {DataResources:[{Type:'AWS::S3::Object',Values:['arn:aws:s3:::']}],IncludeManagementEvents:true,ReadWriteType:'All'}
1044
+ <<
1045
+ Guard Rule Set: hipaa-security
1046
+ Controls: 164.308(a)(3)(ii)(A),164.312(b)
1047
+ Violation: CloudTrail Trail should have data events being logged.
1048
+ Fix: Set the EventSelectors parameter to enable encryption. The value can be an alias name prefixed by "alias/", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier.
1049
+ >>
1050
+ }
1051
+ #
1052
+ #####################################
1053
+ ## Gherkin ##
1054
+ #####################################
1055
+ # Rule Identifier:
1056
+ # RDS_INSTANCE_LOGGING_ENABLED
1057
+ #
1058
+ # Description:
1059
+ # Checks if log types exported to Amazon CloudWatch for an Amazon Relational
1060
+ # Database Service (Amazon RDS) instance are enabled.
1061
+ #
1062
+ # Reports on:
1063
+ # AWS::RDS::DBInstance
1064
+ #
1065
+ # Evaluates:
1066
+ # AWS CloudFormation
1067
+ #
1068
+ # Rule Parameters:
1069
+ # NA
1070
+ #
1071
+ # Scenarios:
1072
+ # a) SKIP: when there are no RDS instances present
1073
+ # b) PASS: when all RDS instances have EnableCloudwatchLogsExports set to true
1074
+ # c) FAIL: when all RDS instances have EnableCloudwatchLogsExports set to false
1075
+ # d) FAIL: when there are RDS instances with EnableCloudwatchLogsExports property is not present
1076
+ # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_LOGGING_ENABLED
1077
+
1078
+ #
1079
+ # Select all RDS instance resources from incoming template (payload)
1080
+ #
1081
+
1082
+ let aws_rds_instances_logging_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
1083
+ Metadata.guard.SuppressedRules not exists or
1084
+ Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_LOGGING_ENABLED"
1085
+ ]
1086
+
1087
+
1088
+ rule RDS_INSTANCE_LOGGING_ENABLED when %aws_rds_instances_logging_enabled !empty {
1089
+ %aws_rds_instances_logging_enabled.Properties.EnableCloudwatchLogsExports EXISTS
1090
+ <<
1091
+ Guard Rule Set: hipaa-security
1092
+ Controls: 164.308(a)(3)(ii)(A),164.308(a)(5)(ii)(C),164.312(b)
1093
+ Violation: Enable CloudWatch Logs Exports for monitoring and logging.
1094
+ Fix: Provide EnableCloudWatchLogsExports object to start exporting cloudwatch logs.
1095
+ >>
1096
+ }
1097
+
1098
+
1099
+ #
1100
+ #####################################
1101
+ ## Gherkin ##
1102
+ #####################################
1103
+ # Rule Identifier:
1104
+ # S3_BUCKET_LOGGING_ENABLED
1105
+ #
1106
+ # Description:
1107
+ # Checks whether logging is enabled for your S3 buckets.
1108
+ #
1109
+ # Reports on:
1110
+ # AWS::S3::Bucket
1111
+ #
1112
+ # Evaluates:
1113
+ # AWS CloudFormation
1114
+ #
1115
+ # Rule Parameters:
1116
+ # NA
1117
+ #
1118
+ # Scenarios:
1119
+ # a) SKIP: when there are no S3 resource present
1120
+ # b) PASS: when all S3 resources Logging Configuration exists
1121
+ # c) FAIL: when all S3 resources have Logging Configuration is not set
1122
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_LOGGING_ENABLED
1123
+
1124
+ #
1125
+ # Select all S3 resources from incoming template (payload)
1126
+ #
1127
+
1128
+ let s3_buckets_bucket_logging_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
1129
+ Metadata.guard.SuppressedRules not exists or
1130
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_LOGGING_ENABLED"
1131
+ ]
1132
+
1133
+ rule S3_BUCKET_LOGGING_ENABLED when %s3_buckets_bucket_logging_enabled !empty {
1134
+ %s3_buckets_bucket_logging_enabled.Properties.LoggingConfiguration exists
1135
+ <<
1136
+ Guard Rule Set: hipaa-security
1137
+ Controls: 164.308(a)(3)(ii)(A),164.312(b)
1138
+ Violation: S3 Bucket Logging needs to be configured to enable logging.
1139
+ Fix: Set the S3 Bucket property LoggingConfiguration to start logging into S3 bucket.
1140
+ >>
1141
+ }
1142
+ #
1143
+ #####################################
1144
+ ## Gherkin ##
1145
+ #####################################
1146
+ # Rule Identifier:
1147
+ # ELASTICSEARCH_LOGS_TO_CLOUDWATCH
1148
+ #
1149
+ # Description:
1150
+ # Checks if Amazon OpenSearch Service (OpenSearch Service) domains are
1151
+ # configured to send logs to Amazon CloudWatch Logs.
1152
+ #
1153
+ # Reports on:
1154
+ # AWS::Elasticsearch::Domain
1155
+ #
1156
+ # Evaluates:
1157
+ # AWS CloudFormation
1158
+ #
1159
+ # Rule Parameters:
1160
+ # NA
1161
+ #
1162
+ # Scenarios:
1163
+ # a) SKIP: when there is no elasticsearch domain present
1164
+ # b) FAIL: when elasticsearch domain does not have LogPublishingOptions or Enabled parameter is set to false for all available keys
1165
+ # c) PASS: when elasticsearch domain has LogPublishingOptions with Enabled parameter is set to true on one key
1166
+ # d) SKIP: when metada has rule suppression for ELASTICSEARCH_LOGS_TO_CLOUDWATCH
1167
+
1168
+ #
1169
+ # Select all elasticsearch domains from incoming template
1170
+ #
1171
+
1172
+ let elasticsearch_domains_logs_cloudwatch = Resources.*[ Type == 'AWS::Elasticsearch::Domain'
1173
+ Metadata.guard.SuppressedRules not exists or
1174
+ Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_LOGS_TO_CLOUDWATCH"
1175
+ ]
1176
+
1177
+ rule ELASTICSEARCH_LOGS_TO_CLOUDWATCH when %elasticsearch_domains_logs_cloudwatch !empty {
1178
+
1179
+ %elasticsearch_domains_logs_cloudwatch.Properties.LogPublishingOptions EXISTS
1180
+ %elasticsearch_domains_logs_cloudwatch.Properties.LogPublishingOptions.ES_APPLICATION_LOGS.Enabled == true OR
1181
+ %elasticsearch_domains_logs_cloudwatch.Properties.LogPublishingOptions.SEARCH_SLOW_LOGS.Enabled == true OR
1182
+ %elasticsearch_domains_logs_cloudwatch.Properties.LogPublishingOptions.INDEX_SLOW_LOGS.Enabled == true
1183
+ <<
1184
+ Guard Rule Set: hipaa-security
1185
+ Controls: 164.308(a)(3)(ii)(A),164.312(b)
1186
+ Violation: Elasticsearch domain must have logging configured to send logs to CloudWatch Logs.
1187
+ Fix: Set a LogPublishingOptions object to have the property "Enabled" parameter set to true for keys "ES_APPLICATION_LOGS", "SEARCH_SLOW_LOGS", or "INDEX_SLOW_LOGS".
1188
+ >>
1189
+ }
1190
+ ## Config Rule Name : secretsmanager-rotation-enabled-check
1191
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/secretsmanager-rotation-enabled-check.html"
1192
+
1193
+ ## Config Rule Name : secretsmanager-scheduled-rotation-success-check
1194
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/secretsmanager-scheduled-rotation-success-check.html"
1195
+
1196
+ ## Config Rule Name : secretsmanager-secret-periodic-rotation
1197
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/secretsmanager-secret-periodic-rotation.html"
1198
+
1199
+ ## Config Rule Name : secretsmanager-secret-unused
1200
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/secretsmanager-secret-unused.html"
1201
+
1202
+ ## Config Rule Name : elastic-beanstalk-managed-updates-enabled
1203
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elastic-beanstalk-managed-updates-enabled.html"
1204
+
1205
+ ####################################
1206
+ ## Gherkin ##
1207
+ #####################################
1208
+ # Rule Identifier:
1209
+ # REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK
1210
+ #
1211
+ # Description:
1212
+ # Checks whether Amazon Redshift clusters have the specified maintenance settings (AllowVersionUpgrade, PreferredMaintenanceWindow, AutomatedSnapshotRetentionPeriod)
1213
+ #
1214
+ # Reports on:
1215
+ # AWS::Redshift::Cluster
1216
+ #
1217
+ # Evaluates:
1218
+ # AWS CloudFormation
1219
+ #
1220
+ # Rule Parameters:
1221
+ # NA
1222
+ #
1223
+ # Scenarios:
1224
+ # a) SKIP: when there are no Redshift Cluster resource present
1225
+ # b) PASS: when Redshift Cluster resources have properties PreferredMaintenanceWindow set, AllowVersionUpgrade either not set (default true) or set to true, and AutomatedSnapshotRetentionPeriod either not set (default 1 day) or set to greated than 0.
1226
+ # c) FAIL: when any Redshift Cluster resources do not have PreferredMaintenanceWindow property set
1227
+ # d) FAIL: when any Redshift Cluster resources have AllowVersionUpgrade property set to false
1228
+ # e) FAIL: when any Redshift Cluster resources have AutomatedSnapshotRetentionPeriod property set to 0
1229
+ # f) SKIP: when metadata includes the suppression for rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK
1230
+
1231
+ #
1232
+ # Select all Redshift Cluster resources from incoming template (payload)
1233
+ #
1234
+ let redhshift_clusters_maintenancesettings_check = Resources.*[ Type == 'AWS::Redshift::Cluster'
1235
+ Metadata.guard.SuppressedRules not exists or
1236
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK"
1237
+ ]
1238
+
1239
+ rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK when %redhshift_clusters_maintenancesettings_check !empty {
1240
+ %redhshift_clusters_maintenancesettings_check.Properties.PreferredMaintenanceWindow exists
1241
+
1242
+ %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade not exists or
1243
+ %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade == true
1244
+
1245
+
1246
+ %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod not exists or
1247
+ %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod > 0
1248
+
1249
+ <<
1250
+ Guard Rule Set: hipaa-security
1251
+ Controls: 164.308(a)(5)(ii)(A),164.308(a)(7)(ii)(A)
1252
+ Violation: Amazon Redshift maintenance settings must be configured
1253
+ Fix: set the PreferredMaintenanceWindow property, remove the AllowVersionUpgrade property (default true) or set it to true, and remove the AutomatedSnapshotRetentionPeriod property (default 1 day) or set it to greated than 0.
1254
+ >>
1255
+ }
1256
+ #
1257
+ #####################################
1258
+ ## Gherkin ##
1259
+ #####################################
1260
+ # Rule Identifier:
1261
+ # RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED
1262
+ #
1263
+ # Description:
1264
+ # Checks whether storage encryption is enabled for your RDS DB instances
1265
+ #
1266
+ # Reports on:
1267
+ # AWS::RDS::DBInstance
1268
+ #
1269
+ # Evaluates:
1270
+ # AWS CloudFormation
1271
+ #
1272
+ # Rule Parameters:
1273
+ # NA
1274
+ #
1275
+ # Scenarios:
1276
+ # a) SKIP: when there are no RDS instances present
1277
+ # b) PASS: when all RDS instances have AutoMinorVersionUpgrade set to true
1278
+ # c) FAIL: when all RDS instances have AutoMinorVersionUpgrade set to false
1279
+ # d) FAIL: when there are RDS instances with AutoMinorVersionUpgrade property is not present
1280
+ # e) SKIP: when metadata includes the suppression for rule RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED
1281
+
1282
+ #
1283
+ # Select all RDS instance resources from incoming template (payload)
1284
+ #
1285
+
1286
+ let aws_rds_instances_minor_version_upgrade_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
1287
+ Metadata.guard.SuppressedRules not exists or
1288
+ Metadata.guard.SuppressedRules.* != "RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED"
1289
+ ]
1290
+
1291
+
1292
+ rule RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED when %aws_rds_instances_minor_version_upgrade_enabled !empty {
1293
+ %aws_rds_instances_minor_version_upgrade_enabled.Properties.AutoMinorVersionUpgrade EXISTS
1294
+ %aws_rds_instances_minor_version_upgrade_enabled.Properties.AutoMinorVersionUpgrade == true
1295
+ <<
1296
+ Guard Rule Set: hipaa-security
1297
+ Controls: 164.308(a)(5)(ii)(A)
1298
+ Violation: All RDS instances must have automatic minor version upgrade enabled.
1299
+ Fix: Set the AutoMinorVersionUpgrade parameter to true.
1300
+ >>
1301
+ }
1302
+
1303
+ ## Config Rule Name : dynamodb-autoscaling-enabled
1304
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-autoscaling-enabled.html"
1305
+
1306
+ ## Config Rule Name : elb-cross-zone-load-balancing-enabled
1307
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-cross-zone-load-balancing-enabled.html"
1308
+
1309
+ ## Config Rule Name : elb-deletion-protection-enabled
1310
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-deletion-protection-enabled.html"
1311
+
1312
+ #
1313
+ #####################################
1314
+ ## Gherkin ##
1315
+ #####################################
1316
+ # Rule Identifier:
1317
+ # RDS_INSTANCE_DELETION_PROTECTION_ENABLED
1318
+ #
1319
+ # Description:
1320
+ # Checks if an Amazon Relational Database Service (Amazon RDS) instance has deletion protection enabled.
1321
+ #
1322
+ # Reports on:
1323
+ # AWS::RDS::DBInstance
1324
+ #
1325
+ # Evaluates:
1326
+ # AWS CloudFormation
1327
+ #
1328
+ # Rule Parameters:
1329
+ # NA
1330
+ #
1331
+ # Scenarios:
1332
+ # a) SKIP: when there are no RDS instances present
1333
+ # b) PASS: when all RDS instances have DeletionProtection set to true
1334
+ # c) FAIL: when all RDS instances have DeletionProtection set to false
1335
+ # d) FAIL: when there are RDS instances with DeletionProtection property is not present
1336
+ # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_DELETION_PROTECTION_ENABLED
1337
+
1338
+ #
1339
+ # Select all RDS instance resources from incoming template (payload)
1340
+ #
1341
+ let aws_rds_instances_deletion_protection_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
1342
+ Metadata.guard.SuppressedRules not exists or
1343
+ Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_DELETION_PROTECTION_ENABLED"
1344
+ ]
1345
+
1346
+ rule RDS_INSTANCE_DELETION_PROTECTION_ENABLED when %aws_rds_instances_deletion_protection_enabled !empty {
1347
+ %aws_rds_instances_deletion_protection_enabled.Properties.DeletionProtection EXISTS
1348
+ %aws_rds_instances_deletion_protection_enabled.Properties.DeletionProtection == true
1349
+ <<
1350
+ Guard Rule Set: hipaa-security
1351
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(C)
1352
+ Violation: All RDS instances must deletion protection enabled.
1353
+ Fix: Set the parameter for DeletionProtection to true.
1354
+ >>
1355
+ }
1356
+
1357
+ #
1358
+ #####################################
1359
+ ## Gherkin ##
1360
+ #####################################
1361
+ # Rule Identifier:
1362
+ # RDS_MULTI_AZ_SUPPORT
1363
+ #
1364
+ # Description:
1365
+ # In a Multi-AZ deployment, Amazon RDS automatically provisions and maintains a synchronous
1366
+ # standby replica in a different Availability Zone.
1367
+ #
1368
+ # Reports on:
1369
+ # AWS::RDS::DBInstance
1370
+ #
1371
+ # Evaluates:
1372
+ # AWS CloudFormation
1373
+ #
1374
+ # Rule Parameters:
1375
+ # NA
1376
+ #
1377
+ # Scenarios:
1378
+ # a) SKIP: when there are no RDS instances present
1379
+ # b) PASS: when all RDS instances have MultiAZ set to true
1380
+ # c) FAIL: when all RDS instances have MultiAZ set to false
1381
+ # d) FAIL: when there are RDS instances with MultiAZ property is not present
1382
+ # e) SKIP: when metadata includes the suppression for rule RDS_MULTI_AZ_SUPPORT
1383
+
1384
+ #
1385
+ # Select all RDS instance resources from incoming template (payload)
1386
+ #
1387
+ let aws_rds_instances_multi_az_support = Resources.*[ Type == 'AWS::RDS::DBInstance'
1388
+ Metadata.guard.SuppressedRules not exists or
1389
+ Metadata.guard.SuppressedRules.* != "RDS_MULTI_AZ_SUPPORT"
1390
+ ]
1391
+
1392
+ rule RDS_MULTI_AZ_SUPPORT when %aws_rds_instances_multi_az_support !empty {
1393
+ %aws_rds_instances_multi_az_support.Properties.MultiAZ EXISTS
1394
+ %aws_rds_instances_multi_az_support.Properties.MultiAZ == true
1395
+ <<
1396
+ Guard Rule Set: hipaa-security
1397
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(C)
1398
+ Violation: All RDS instances must have MultiAZ support enabled.
1399
+ Fix: Set the MultiAZ parameter to true.
1400
+ >>
1401
+ }
1402
+
1403
+ #
1404
+ #####################################
1405
+ ## Gherkin ##
1406
+ #####################################
1407
+ # Rule Identifier:
1408
+ # DB_INSTANCE_BACKUP_ENABLED
1409
+ #
1410
+ # Description:
1411
+ # Checks if RDS DB instances have backups enabled.
1412
+ #
1413
+ # Reports on:
1414
+ # AWS::RDS::DBInstance
1415
+ #
1416
+ # Evaluates:
1417
+ # AWS CloudFormation
1418
+ #
1419
+ # Rule Parameters:
1420
+ # NA
1421
+ #
1422
+ # Scenarios:
1423
+ # a) SKIP: when there are no RDS instances present
1424
+ # b) PASS: when all RDS instances have BackupRetentionPeriod set to a positive number
1425
+ # c) FAIL: when all RDS instances have BackupRetentionPeriod set to 0
1426
+ # d) FAIL: when there are RDS instances with BackupRetentionPeriod property is not present
1427
+ # e) SKIP: when metadata includes the suppression for rule DB_INSTANCE_BACKUP_ENABLED
1428
+
1429
+ #
1430
+ # Select all RDS instance resources from incoming template (payload)
1431
+ #
1432
+
1433
+ let aws_rds_instances_db_instance_backup_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
1434
+ Metadata.guard.SuppressedRules not exists or
1435
+ Metadata.guard.SuppressedRules.* != "DB_INSTANCE_BACKUP_ENABLED"
1436
+ ]
1437
+
1438
+
1439
+ rule DB_INSTANCE_BACKUP_ENABLED when %aws_rds_instances_db_instance_backup_enabled !empty {
1440
+ %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod EXISTS
1441
+ %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod >= 1
1442
+ <<
1443
+ Guard Rule Set: hipaa-security
1444
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(A),164.308(a)(7)(ii)(B)
1445
+ Violation: All RDS instances must have automated backup enabled.
1446
+ Fix: Set the BackupRetentionPeriod to values of 1 to 35 to enable backups.
1447
+ >>
1448
+ }
1449
+
1450
+ ## Config Rule Name : dynamodb-in-backup-plan
1451
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-in-backup-plan.html"
1452
+
1453
+ ## Config Rule Name : dynamodb-pitr-enabled
1454
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-pitr-enabled.html"
1455
+
1456
+ # Rule Intent: All DynamoDB Tables must have Point-In-Time-Recovery enabled
1457
+
1458
+ # Expectations:
1459
+ # a) SKIP: when there are no DynamoDB Tables present
1460
+ # b) PASS: when all DynamoDB Tables have PITR enabled
1461
+ # c) FAIL: when all DynamoDB Tables have PITR disabled
1462
+
1463
+ #
1464
+ # Select all DynamoDB Table resources from incoming template (payload)
1465
+ #
1466
+ let aws_dynamodb_table_resources = Resources.*[ Type == 'AWS::DynamoDB::Table' ]
1467
+
1468
+
1469
+ rule DYNAMODB_PITR_ENABLED when %aws_dynamodb_table_resources !empty {
1470
+ # Ensure ALL DynamoDB Tables have Point-In-Time-Recovery enabled
1471
+ %aws_dynamodb_table_resources.Properties.PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled == true
1472
+ <<
1473
+ Guard Rule Set: hipaa-security
1474
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(A),164.308(a)(7)(ii)(B)
1475
+ Violation: All DynamoDB Tables must have Point-In-Time-Recovery enabled.
1476
+ Fix: Set the dynamodb table property PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled to true.
1477
+ >>
1478
+ }
1479
+
1480
+ #
1481
+ #####################################
1482
+ ## Gherkin ##
1483
+ #####################################
1484
+ # Rule Identifier:
1485
+ # EBS_OPTIMIZED_INSTANCE
1486
+ #
1487
+ # Description:
1488
+ # Checks whether EBS optimization is enabled for your EC2 instances that can be EBS-optimized
1489
+ #
1490
+ # Reports on:
1491
+ # AWS::EC2::Instance
1492
+ #
1493
+ # Evaluates:
1494
+ # AWS CloudFormation
1495
+ #
1496
+ # Rule Parameters:
1497
+ # NA
1498
+ #
1499
+ # Scenarios:
1500
+ # a) SKIP: when there are no EC2 resource present
1501
+ # b) PASS: when all EC2 resources EbsOptimized property is set to true
1502
+ # c) FAIL: when any EC2 resources do not have the EbsOptimized property set to true
1503
+ # e) SKIP: hen metadata includes the suppression for rule EBS_OPTIMIZED_INSTANCE
1504
+
1505
+ #
1506
+ # Select all AWS EC2 Instance resources from incoming template (payload)
1507
+ #
1508
+ let ec2_ebs_optimized_instances = Resources.*[ Type == 'AWS::EC2::Instance'
1509
+ Metadata.guard.SuppressedRules not exists or
1510
+ Metadata.guard.SuppressedRules.* != "EBS_OPTIMIZED_INSTANCE"
1511
+ ]
1512
+
1513
+ rule EBS_OPTIMIZED_INSTANCE when %ec2_ebs_optimized_instances !empty {
1514
+ %ec2_ebs_optimized_instances.Properties.EbsOptimized == true
1515
+ <<
1516
+ Guard Rule Set: hipaa-security
1517
+ Controls: 164.308(a)(7)(i)
1518
+ Violation: EBS optimization must be enabled for your EC2 instances
1519
+ Fix: set the EbsOptimized property to true
1520
+ >>
1521
+ }
1522
+ ## Config Rule Name : elasticache-redis-cluster-automatic-backup-check
1523
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elasticache-redis-cluster-automatic-backup-check.html"
1524
+
1525
+ #
1526
+ #####################################
1527
+ ## Gherkin ##
1528
+ #####################################
1529
+ # Rule Identifier:
1530
+ # REDSHIFT_BACKUP_ENABLED
1531
+ #
1532
+ # Description:
1533
+ # Checks that Amazon Redshift automated snapshots are enabled for clusters.
1534
+ #
1535
+ # Reports on:
1536
+ # AWS::Redshift::Cluster
1537
+ #
1538
+ # Evaluates:
1539
+ # AWS CloudFormation
1540
+ #
1541
+ # Rule Parameters:
1542
+ # NA
1543
+ #
1544
+ # Scenarios:
1545
+ # a) SKIP: when there are no Redshift Cluster resource present
1546
+ # b) PASS: when Redshift Cluster resources don't have the AutomatedSnapshotRetentionPeriod property set (default retention period is 1 day)
1547
+ # c) PASS: when Redshift Cluster resources have the AutomatedSnapshotRetentionPeriod property set to greater than 0
1548
+ # d) FAIL: when any Redshift Cluster resources have the AutomatedSnapshotRetentionPeriod property set to 0
1549
+ # e) SKIP: when metadata includes the suppression for rule REDSHIFT_BACKUP_ENABLED
1550
+
1551
+ #
1552
+ # Select all Redshift Cluster resources from incoming template (payload)
1553
+ #
1554
+ let redhshift_backup_enabled_clusters = Resources.*[ Type == 'AWS::Redshift::Cluster'
1555
+ Metadata.guard.SuppressedRules not exists or
1556
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_BACKUP_ENABLED"
1557
+ ]
1558
+
1559
+ rule REDSHIFT_BACKUP_ENABLED when %redhshift_backup_enabled_clusters !empty {
1560
+ %redhshift_backup_enabled_clusters.Properties.AutomatedSnapshotRetentionPeriod not exists
1561
+ or %redhshift_backup_enabled_clusters.Properties.AutomatedSnapshotRetentionPeriod > 0
1562
+ <<
1563
+ Guard Rule Set: hipaa-security
1564
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(A),164.308(a)(7)(ii)(B)
1565
+ Violation: Amazon Redshift automated snapshots must be enabled for clusters
1566
+ Fix: Either remove the AutomatedSnapshotRetentionPeriod property (default retention period is 1 day)
1567
+ Or set the AutomatedSnapshotRetentionPeriod property to an integer greater than 0
1568
+ >>
1569
+ }
1570
+ #
1571
+ #####################################
1572
+ ## Gherkin ##
1573
+ #####################################
1574
+ # Rule Identifier:
1575
+ # S3_BUCKET_REPLICATION_ENABLED
1576
+ #
1577
+ # Description:
1578
+ # Checks whether the Amazon S3 buckets have cross-region replication enabled.
1579
+ #
1580
+ # Reports on:
1581
+ # AWS::S3::Bucket
1582
+ #
1583
+ # Evaluates:
1584
+ # AWS CloudFormation
1585
+ #
1586
+ # Rule Parameters:
1587
+ # NA
1588
+ #
1589
+ # Scenarios:
1590
+ # a) SKIP: when there are no S3 resource present
1591
+ # b) PASS: when all S3 resources replication configuration set status is set to Enabled
1592
+ # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended
1593
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_REPLICATION_ENABLED
1594
+
1595
+ #
1596
+ # Select all S3 resources from incoming template (payload)
1597
+ #
1598
+
1599
+ let s3_buckets_replication_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
1600
+ Metadata.guard.SuppressedRules not exists or
1601
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_REPLICATION_ENABLED"
1602
+ ]
1603
+
1604
+ rule S3_BUCKET_REPLICATION_ENABLED when %s3_buckets_replication_enabled !empty {
1605
+ %s3_buckets_replication_enabled.Properties.ReplicationConfiguration exists
1606
+ <<
1607
+ Guard Rule Set: hipaa-security
1608
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(A),164.308(a)(7)(ii)(B)
1609
+ Violation: S3 Bucket replication should be enabled.
1610
+ Fix: Set S3 Bucket ReplicationConfiguration to another S3 Bucket.
1611
+ >>
1612
+ ## TODO regex to identify cross-region
1613
+ }
1614
+ #
1615
+ #####################################
1616
+ ## Gherkin ##
1617
+ #####################################
1618
+ # Rule Identifier:
1619
+ # S3_BUCKET_VERSIONING_ENABLED
1620
+ #
1621
+ # Description:
1622
+ # Checks if versioning is enabled for your S3 buckets.
1623
+ #
1624
+ # Reports on:
1625
+ # AWS::S3::Bucket
1626
+ #
1627
+ # Evaluates:
1628
+ # AWS CloudFormation
1629
+ #
1630
+ # Rule Parameters:
1631
+ # NA
1632
+ #
1633
+ # Scenarios:
1634
+ # a) SKIP: when there are no S3 resource present
1635
+ # b) PASS: when all S3 resources Versioning Configuration status is set to Enabled
1636
+ # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended
1637
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_VERSIONING_ENABLED
1638
+
1639
+ #
1640
+ # Select all S3 resources from incoming template (payload)
1641
+ #
1642
+ let s3_buckets_versioning_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
1643
+ Metadata.guard.SuppressedRules not exists or
1644
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_VERSIONING_ENABLED"
1645
+ ]
1646
+
1647
+ rule S3_BUCKET_VERSIONING_ENABLED when %s3_buckets_versioning_enabled !empty {
1648
+ %s3_buckets_versioning_enabled.Properties.VersioningConfiguration exists
1649
+ %s3_buckets_versioning_enabled.Properties.VersioningConfiguration.Status == 'Enabled'
1650
+ <<
1651
+ Guard Rule Set: hipaa-security
1652
+ Controls: 164.308(a)(7)(i),164.308(a)(7)(ii)(A),164.308(a)(7)(ii)(B),164.312(c)(1),164.312(c)(2)
1653
+ Violation: S3 Bucket Versioning must be enabled.
1654
+ Fix: Set the S3 Bucket property VersioningConfiguration.Status to 'Enabled' .
1655
+ >>
1656
+ }
1657
+ ## Config Rule Name : alb-http-drop-invalid-header-enabled
1658
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/alb-http-drop-invalid-header-enabled.html"
1659
+
1660
+ ## Config Rule Name : alb-http-to-https-redirection-check
1661
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/alb-http-to-https-redirection-check.html"
1662
+
1663
+ # Rule Intent: Checks if HTTP to HTTPS redirection is configured on all HTTP listeners of Application Load Balancers.
1664
+
1665
+ # Expectations:
1666
+ # a) SKIP: when there are no ALB resources present
1667
+ # b) PASS: when one or more HTTP listeners have forwarding to an HTTPS listener
1668
+ # c) FAIL: when one of more HTTP listeners have forwarding to an HTTP listener instead of redirection.
1669
+ # d) FAIL: when one or more HTTP listeners of Application Load Balancer do not have HTTP to HTTPS redirection configured.
1670
+
1671
+
1672
+
1673
+ #
1674
+ # Select all ALB resources from incoming template (payload)
1675
+ #
1676
+
1677
+ #
1678
+ #####################################
1679
+ ## Gherkin ##
1680
+ #####################################
1681
+ # Rule Identifier:
1682
+ # API_GW_CACHE_ENABLED_AND_ENCRYPTED
1683
+ #
1684
+ # Description:
1685
+ # Checks that all methods in Amazon API Gateway stages have cache enabled and cache encrypted.
1686
+ #
1687
+ # Reports on:
1688
+ # AWS::ApiGateway::Stage
1689
+ #
1690
+ # Evaluates:
1691
+ # AWS CloudFormation
1692
+ #
1693
+ # Rule Parameters:
1694
+ # NA
1695
+ #
1696
+ # Scenarios:
1697
+ # a) SKIP: when there are no API GW Stage Methods present
1698
+ # b) PASS: when all API Stage Method has caching enabled and encrypted
1699
+ # c) FAIL: when API Stage Method does not have caching enabled and encrypted
1700
+ # d) SKIP: when metadata includes the suppression for rule API_GW_CACHE_ENABLED_AND_ENCRYPTED
1701
+
1702
+ let api_gw_cache_enabled_encrypted = Resources.*[ Type == 'AWS::ApiGateway::Stage'
1703
+ Metadata.guard.SuppressedRules not exists or
1704
+ Metadata.guard.SuppressedRules.* != "API_GW_CACHE_ENABLED_AND_ENCRYPTED"
1705
+ ]
1706
+
1707
+ rule API_GW_CACHE_ENABLED_AND_ENCRYPTED when %api_gw_cache_enabled_encrypted !empty {
1708
+ when %api_gw_cache_enabled_encrypted.Properties.MethodSettings exists {
1709
+ %api_gw_cache_enabled_encrypted.Properties.MethodSettings.*.CacheDataEncrypted == true
1710
+ %api_gw_cache_enabled_encrypted.Properties.MethodSettings.*.CachingEnabled == true
1711
+ <<
1712
+ Guard Rule Set: hipaa-security
1713
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1714
+ Violation: API Gateway Stage Method not set with caching and caching encrypted
1715
+ Fix: API GW Stage Method property CacheDataEncrypted and CachingEnabled set to true
1716
+ >>
1717
+ }
1718
+ }
1719
+ ## Config Rule Name : api-gw-ssl-enabled
1720
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/api-gw-ssl-enabled.html"
1721
+
1722
+ #
1723
+ #####################################
1724
+ ## Gherkin ##
1725
+ #####################################
1726
+ # Rule Identifier:
1727
+ # CLOUD_TRAIL_ENCRYPTION_ENABLED
1728
+ #
1729
+ # Description:
1730
+ # Checks if AWS CloudTrail is configured to use the server side encryption (SSE)
1731
+ # AWS Key Management Service KMS key encryption.
1732
+ #
1733
+ # Reports on:
1734
+ # AWS::CloudTrail::Trail
1735
+ #
1736
+ # Evaluates:
1737
+ # AWS CloudFormation
1738
+ #
1739
+ # Rule Parameters:
1740
+ # NA
1741
+ #
1742
+ # Scenarios:
1743
+ # a) SKIP: when there are no CloudTrail Trails present
1744
+ # b) PASS: when all CloudTrail Trails have KMSKeyId parameter set
1745
+ # c) FAIL: when there are CloudTrail Trails with KMSKeyId property not present
1746
+ # d) SKIP: when metada has rule suppression for CLOUD_TRAIL_ENCRYPTION_ENABLED
1747
+
1748
+ #
1749
+ # Select all CloudTrail Trail resources from incoming template (payload)
1750
+ #
1751
+ let cloudtrail_trails_encryption = Resources.*[ Type == 'AWS::CloudTrail::Trail'
1752
+ Metadata.guard.SuppressedRules not exists or
1753
+ Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_ENCRYPTION_ENABLED"
1754
+ ]
1755
+
1756
+ rule CLOUD_TRAIL_ENCRYPTION_ENABLED when %cloudtrail_trails_encryption !empty {
1757
+ %cloudtrail_trails_encryption.Properties.KMSKeyId EXISTS
1758
+ %cloudtrail_trails_encryption.Properties.KMSKeyId is_string
1759
+ <<
1760
+ Guard Rule Set: hipaa-security
1761
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1762
+ Violation: CloudTrail Trail should be used to encrypt logs delivered by CloudTrail.
1763
+ Fix: Set the KMSKeyId parameter to enable encryption. The value can be an alias name prefixed by "alias/", a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier.
1764
+ >>
1765
+ }
1766
+ #
1767
+ #####################################
1768
+ ## Gherkin ##
1769
+ #####################################
1770
+ # Rule Identifier:
1771
+ # CLOUDWATCH_LOG_GROUP_ENCRYPTED
1772
+ #
1773
+ # Description:
1774
+ # Checks if a log group in Amazon CloudWatch Logs is encrypted with a
1775
+ # AWS Key Management Service (KMS) managed Customer Master Keys (CMK).
1776
+ #
1777
+ # Reports on:
1778
+ # AWS::Logs::LogGroup
1779
+ #
1780
+ # Evaluates:
1781
+ # AWS CloudFormation
1782
+ #
1783
+ # Rule Parameters:
1784
+ # NA
1785
+ #
1786
+ # Scenarios:
1787
+ # a) SKIP: when there are no cloudwatch logs log group resources present
1788
+ # b) PASS: when all cloudwatch logs log group resources property KmsKeyId is set
1789
+ # c) FAIL: when all cloudwatch logs log group resources property KmsKeyId is not set with valid value
1790
+ # d) SKIP: when metada has rule suppression for CLOUDWATCH_LOG_GROUP_ENCRYPTED
1791
+
1792
+ #
1793
+ # Select all cloudwatch logs log group resources from incoming template (payload)
1794
+ #
1795
+ let cloudwatch_logs = Resources.*[ Type == 'AWS::Logs::LogGroup'
1796
+ Metadata.guard.SuppressedRules not exists or
1797
+ Metadata.guard.SuppressedRules.* != "CLOUDWATCH_LOG_GROUP_ENCRYPTED"
1798
+ ]
1799
+
1800
+ rule CLOUDWATCH_LOG_GROUP_ENCRYPTED when %cloudwatch_logs !empty {
1801
+ %cloudwatch_logs.Properties.KmsKeyId exists
1802
+ <<
1803
+ Guard Rule Set: hipaa-security
1804
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1805
+ Violation: CloudWatch Log LogsGroup does not have KmsKeyId set.
1806
+ Fix: Set the KmsKeyId parameter to a ARN.
1807
+ >>
1808
+ }
1809
+
1810
+ ## Config Rule Name : dynamodb-table-encrypted-kms
1811
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-table-encrypted-kms.html"
1812
+
1813
+ #
1814
+ #####################################
1815
+ ## Gherkin ##
1816
+ #####################################
1817
+ # Rule Identifier:
1818
+ # EC2_EBS_ENCRYPTION_BY_DEFAULT
1819
+ #
1820
+ # Description:
1821
+ # Check that Amazon Elastic Block Store (EBS) encryption is enabled by default
1822
+ # Reports on:
1823
+ # AWS::EC2::Volume
1824
+ #
1825
+ # Evaluates:
1826
+ # AWS CloudFormation
1827
+ #
1828
+ # Rule Parameters:
1829
+ # NA
1830
+ #
1831
+ # Scenarios:
1832
+ # a) SKIP: when no EC2 Volume resources are present
1833
+ # b) PASS: when all EC2 Volume resources have the Encrypted property set to true
1834
+ # c) FAIL: when any EC2 Volumes resources do not have the Encrypted property set to true
1835
+ # e) SKIP: when metadata includes the suppression for rule EC2_EBS_ENCRYPTION_BY_DEFAULT
1836
+
1837
+ #
1838
+ # Select all EC2 Volume resources from incoming template (payload)
1839
+ #
1840
+ let ec2_ebs_volumes_encrypted_by_default = Resources.*[ Type == 'AWS::EC2::Volume'
1841
+ Metadata.guard.SuppressedRules not exists or
1842
+ Metadata.guard.SuppressedRules.* != "EC2_EBS_ENCRYPTION_BY_DEFAULT"
1843
+ ]
1844
+
1845
+ rule EC2_EBS_ENCRYPTION_BY_DEFAULT when %ec2_ebs_volumes_encrypted_by_default !empty {
1846
+ %ec2_ebs_volumes_encrypted_by_default.Properties.Encrypted == true
1847
+ <<
1848
+ Guard Rule Set: hipaa-security
1849
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1850
+ Violation: All EBS Volumes should be encryped
1851
+ Fix: Set Encrypted property to true
1852
+ >>
1853
+ }
1854
+ #
1855
+ #####################################
1856
+ ## Gherkin ##
1857
+ #####################################
1858
+ # Rule Identifier:
1859
+ # EFS_ENCRYPTED_CHECK
1860
+ #
1861
+ # Description:
1862
+ # Checks if Amazon Elastic File System (Amazon EFS) is configured to encrypt the file data
1863
+ # using AWS Key Management Service (AWS KMS). The rule is NON_COMPLIANT if the encrypted
1864
+ # key is set to false on DescribeFileSystems or if the KmsKeyId key on DescribeFileSystems
1865
+ # does not match the KmsKeyId parameter.
1866
+ #
1867
+ # Reports on:
1868
+ # AWS::EFS::FileSystem
1869
+ #
1870
+ # Evaluates:
1871
+ # AWS CloudFormation
1872
+ #
1873
+ # Rule Parameters:
1874
+ # NA
1875
+ #
1876
+ # Scenarios:
1877
+ # a) SKIP: when there are no EFS resource present
1878
+ # b) PASS: when all EFS resources have encrypted key property set to true
1879
+ # c) FAIL: when all EFS resources have encrypted key property not set or set to false
1880
+ # d) SKIP: when guard metadata states EFS_ENCRYPTED_CHECK to be suppressed
1881
+
1882
+ #
1883
+ # Select all EFS resources from incoming template (payload)
1884
+ #
1885
+ let efs_file_systems_encrypted_check = Resources.*[ Type == 'AWS::EFS::FileSystem'
1886
+ Metadata.guard.SuppressedRules not exists or
1887
+ Metadata.guard.SuppressedRules.* != "EFS_ENCRYPTED_CHECK"
1888
+ ]
1889
+
1890
+ rule EFS_ENCRYPTED_CHECK when %efs_file_systems_encrypted_check !empty {
1891
+ %efs_file_systems_encrypted_check.Properties.Encrypted == true
1892
+ <<
1893
+ Guard Rule Set: hipaa-security
1894
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1895
+ Violation: EFS filesystem must be encrypted.
1896
+ Fix: Set the EFS Filesystem property Encrypted parameter to true.
1897
+ >>
1898
+ }
1899
+ #
1900
+ #####################################
1901
+ ## Gherkin ##
1902
+ #####################################
1903
+ # Rule Identifier:
1904
+ # ELASTICSEARCH_ENCRYPTED_AT_REST
1905
+ #
1906
+ # Description:
1907
+ # Elasticsearch domains must enforce server side encryption
1908
+ #
1909
+ # Reports on:
1910
+ # AWS::Elasticsearch::Domain
1911
+ #
1912
+ # Evaluates:
1913
+ # AWS CloudFormation
1914
+ #
1915
+ # Rule Parameters:
1916
+ # NA
1917
+ #
1918
+ # Scenarios:
1919
+ # a) SKIP: when there is no elasticsearch domain present
1920
+ # b) FAIL: when elasticsearch domain has server side encryption set to false
1921
+ # c) PASS: when elasticsearch domain has server side encryption set to true
1922
+ # d) FAIL: when elasticsearch domain has server side encryption property is missing
1923
+ # e) SKIP: when metada has rule suppression for ELASTICSEARCH_ENCRYPTED_AT_REST
1924
+
1925
+ #
1926
+ # Select all elasticsearch domains from incoming template
1927
+ #
1928
+ let elasticsearch_domains_encrypted = Resources.*[ Type == 'AWS::Elasticsearch::Domain'
1929
+ Metadata.guard.SuppressedRules not exists or
1930
+ Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_ENCRYPTED_AT_REST"
1931
+ ]
1932
+
1933
+ rule ELASTICSEARCH_ENCRYPTED_AT_REST when %elasticsearch_domains_encrypted !empty {
1934
+ %elasticsearch_domains_encrypted.Properties.EncryptionAtRestOptions.Enabled == true
1935
+ <<
1936
+ Guard Rule Set: hipaa-security
1937
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
1938
+ Violation: Elasticsearch domains must enforce server side encryption.
1939
+ Fix: Set the EncryptionAtRestOptions.Enabled parameter to true.
1940
+ >>
1941
+ }
1942
+ #
1943
+ #####################################
1944
+ ## Gherkin ##
1945
+ #####################################
1946
+ # Rule Identifier:
1947
+ # ELASTICSEARCH_NODE_TO_NODE_ENCRYPTION_CHECK
1948
+ #
1949
+ # Description:
1950
+ # Elasticsearch domains must enforce Node-to-Node Encryption
1951
+ #
1952
+ # Reports on:
1953
+ # AWS::Elasticsearch::Domain
1954
+ #
1955
+ # Evaluates:
1956
+ # AWS CloudFormation
1957
+ #
1958
+ # Rule Parameters:
1959
+ # NA
1960
+ #
1961
+ # Scenarios:
1962
+ # a) SKIP: when there is no elasticsearch domain present
1963
+ # b) FAIL: when elasticsearch domain has Node-to-Node encryption set to false
1964
+ # c) PASS: when elasticsearch domain has Node-to-Node encryption set to true
1965
+ # d) FAIL: when elasticsearch domain has Node-to-Node encryption property missing
1966
+ # e) SKIP: when metada has rule suppression for ELASTICSEARCH_NODE_TO_NODE_ENCRYPTION_CHECK
1967
+
1968
+ #
1969
+ # Select all elasticsearch domains from incoming template
1970
+ #
1971
+
1972
+ let elasticsearch_domains_node2node_encrpytion = Resources.*[ Type == 'AWS::Elasticsearch::Domain'
1973
+ Metadata.guard.SuppressedRules not exists or
1974
+ Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_NODE_TO_NODE_ENCRYPTION_CHECK"
1975
+ ]
1976
+
1977
+ rule ELASTICSEARCH_NODE_TO_NODE_ENCRYPTION_CHECK when %elasticsearch_domains_node2node_encrpytion !empty {
1978
+ %elasticsearch_domains_node2node_encrpytion.Properties.NodeToNodeEncryptionOptions.Enabled == true
1979
+ <<
1980
+ Guard Rule Set: hipaa-security
1981
+ Controls: 164.312(a)(2)(iv),164.312(e)(1),164.312(e)(2)(i),164.312(e)(2)(ii)
1982
+ Violation: Elasticsearch domains must enforce Node-to-Node Encryption.
1983
+ Fix: Set the NodeToNodeEncryptionOptions.Enabled parameter to true.
1984
+ >>
1985
+ }
1986
+
1987
+ ## Config Rule Name : elb-acm-certificate-required
1988
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-acm-certificate-required.html"
1989
+
1990
+ ## Config Rule Name : elb-tls-https-listeners-only
1991
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-tls-https-listeners-only.html"
1992
+
1993
+ #
1994
+ #####################################
1995
+ ## Gherkin ##
1996
+ #####################################
1997
+ # Rule Identifier:
1998
+ # ENCRYPTED_VOLUMES
1999
+ #
2000
+ # Description:
2001
+ # Checks if the EBS volumes that are in an attached state are encrypted.
2002
+ #
2003
+ # Reports on:
2004
+ # AWS::EC2::Volume
2005
+ #
2006
+ # Evaluates:
2007
+ # AWS CloudFormation
2008
+ #
2009
+ # Rule Parameters:
2010
+ # NA
2011
+ #
2012
+ # Scenarios:
2013
+ # a) SKIP: when there are no EBS volume resources present
2014
+ # b) PASS: when all EBS volumes have the KmsKeyId property set or the Encrypted property set to true
2015
+ # c) FAIL: when any EC2 volumes do not have the KmsKeyId or Encrypted property set
2016
+ # e) SKIP: hen metadata includes the suppression for rule ENCRYPTED_VOLUMES
2017
+
2018
+ #
2019
+ # Select all EC2 Instance resources from incoming template (payload)
2020
+ #
2021
+ let ebs_volumes_encrypted = Resources.*[ Type == 'AWS::EC2::Volume'
2022
+ Metadata.guard.SuppressedRules not exists or
2023
+ Metadata.guard.SuppressedRules.* != "ENCRYPTED_VOLUMES"
2024
+ ]
2025
+
2026
+ rule ENCRYPTED_VOLUMES when %ebs_volumes_encrypted !empty {
2027
+ %ebs_volumes_encrypted.Properties.KmsKeyId !empty
2028
+ OR %ebs_volumes_encrypted.Properties.Encrypted == true
2029
+ <<
2030
+ Guard Rule Set: hipaa-security
2031
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
2032
+ Violation: EBS volumes in an attached state must encrypted.
2033
+ Fix: either set the KmsKeyId property to a key ID, key alias, key ARN, or alias ARN
2034
+ or set the Encrypted property to true to encrypt the volume with the account default key or AWS managed key.
2035
+ >>
2036
+ }
2037
+ #
2038
+ #####################################
2039
+ ## Gherkin ##
2040
+ #####################################
2041
+ # Rule Identifier:
2042
+ # RDS_SNAPSHOT_ENCRYPTED
2043
+ #
2044
+ # Description:
2045
+ # Checks whether Amazon Relational Database Service (Amazon RDS) DB snapshots are encrypted.
2046
+ #
2047
+ #
2048
+ # Reports on:
2049
+ # AWS::RDS::DBInstance
2050
+ #
2051
+ # Evaluates:
2052
+ # AWS CloudFormation
2053
+ #
2054
+ # Rule Parameters:
2055
+ # NA
2056
+ #
2057
+ # Scenarios:
2058
+ # a) SKIP: when there are no RDS instances present
2059
+ # b) PASS: when all RDS instances have StorageEncrypted set to true
2060
+ # c) FAIL: when all RDS instances have StorageEncrypted set to false
2061
+ # d) FAIL: when there are RDS instances with StorageEncrypted property is not present
2062
+ # e) SKIP: when metadata includes the suppression for rule RDS_SNAPSHOT_ENCRYPTED
2063
+
2064
+ #
2065
+ # Select all RDS instance resources from incoming template (payload)
2066
+ #
2067
+ let aws_rds_instances_snapshot_encrypted = Resources.*[ Type == 'AWS::RDS::DBInstance'
2068
+ Metadata.guard.SuppressedRules not exists or
2069
+ Metadata.guard.SuppressedRules.* != "RDS_SNAPSHOT_ENCRYPTED"
2070
+ ]
2071
+
2072
+
2073
+ rule RDS_SNAPSHOT_ENCRYPTED when %aws_rds_instances_snapshot_encrypted !empty {
2074
+ %aws_rds_instances_snapshot_encrypted.Properties.StorageEncrypted EXISTS
2075
+ %aws_rds_instances_snapshot_encrypted.Properties.StorageEncrypted == true
2076
+ <<
2077
+ Guard Rule Set: hipaa-security
2078
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
2079
+ Violation: All RDS instances must have snapshots encrypted.
2080
+ Fix: Set the StorageEncrypted parameter to true so by default all snapshots are encrypted.
2081
+ >>
2082
+ }
2083
+
2084
+ #
2085
+ #####################################
2086
+ ## Gherkin ##
2087
+ #####################################
2088
+ # Rule Identifier:
2089
+ # RDS_STORAGE_ENCRYPTED
2090
+ #
2091
+ # Description:
2092
+ # Checks whether storage encryption is enabled for your RDS DB instances.
2093
+ #
2094
+ #
2095
+ # Reports on:
2096
+ # AWS::RDS::DBInstance
2097
+ #
2098
+ # Evaluates:
2099
+ # AWS CloudFormation
2100
+ #
2101
+ # Rule Parameters:
2102
+ # NA
2103
+ #
2104
+ # Scenarios:
2105
+ # a) SKIP: when there are no RDS instances present
2106
+ # b) PASS: when all RDS instances have StorageEncrypted set to true
2107
+ # c) FAIL: when all RDS instances have StorageEncrypted set to false
2108
+ # d) FAIL: when there are RDS instances with StorageEncrypted property is not present
2109
+ # e) SKIP: when metadata includes the suppression for rule RDS_STORAGE_ENCRYPTED
2110
+
2111
+ #
2112
+ # Select all RDS instance resources from incoming template (payload)
2113
+ #
2114
+ let aws_rds_instances_storage_encrypted = Resources.*[ Type == 'AWS::RDS::DBInstance'
2115
+ Metadata.guard.SuppressedRules not exists or
2116
+ Metadata.guard.SuppressedRules.* != "RDS_STORAGE_ENCRYPTED"
2117
+ ]
2118
+
2119
+
2120
+ rule RDS_STORAGE_ENCRYPTED when %aws_rds_instances_storage_encrypted !empty {
2121
+ %aws_rds_instances_storage_encrypted.Properties.StorageEncrypted EXISTS
2122
+ %aws_rds_instances_storage_encrypted.Properties.StorageEncrypted == true
2123
+ <<
2124
+ Guard Rule Set: hipaa-security
2125
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
2126
+ Violation: All RDS instances must have encrypted storage.
2127
+ Fix: Set the StorageEncrypted parameter to true.
2128
+ >>
2129
+ }
2130
+
2131
+ ####################################
2132
+ ## Gherkin ##
2133
+ #####################################
2134
+ # Rule Identifier:
2135
+ # REDSHIFT_CLUSTER_CONFIGURATION_CHECK
2136
+ #
2137
+ # Description:
2138
+ # Checks whether Amazon Redshift clusters have the specified settings (Encrypted Only)
2139
+ #
2140
+ # Reports on:
2141
+ # AWS::Redshift::Cluster
2142
+ #
2143
+ # Evaluates:
2144
+ # AWS CloudFormation
2145
+ #
2146
+ # Rule Parameters:
2147
+ # NA
2148
+ #
2149
+ # Scenarios:
2150
+ # a) SKIP: when there are no Redshift Cluster resource present
2151
+ # b) PASS: when Redshift Cluster resources have the Encrypted property set to true
2152
+ # c) FAIL: when any Redshift Cluster resources do not have Encrypted property set (default false)
2153
+ # d) FAIL: when any Redshift Cluster resources have Encrypted property set to false
2154
+ # e) SKIP: when metadata includes the suppression for rule REDSHIFT_CLUSTER_CONFIGURATION_CHECK
2155
+
2156
+ #
2157
+ # Select all Redshift Cluster resources from incoming template (payload)
2158
+ #
2159
+ let redhshift_clusters_configuration_check = Resources.*[ Type == 'AWS::Redshift::Cluster'
2160
+ Metadata.guard.SuppressedRules not exists or
2161
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_CONFIGURATION_CHECK"
2162
+ ]
2163
+
2164
+ rule REDSHIFT_CLUSTER_CONFIGURATION_CHECK when %redhshift_clusters_configuration_check !empty {
2165
+ %redhshift_clusters_configuration_check.Properties.Encrypted == true
2166
+
2167
+ <<
2168
+ Guard Rule Set: hipaa-security
2169
+ Controls: 164.312(a)(2)(iv),164.312(b),164.312(e)(2)(ii)
2170
+ Violation: Amazon Redshift configuration should have encryption enabled
2171
+ Fix: Set the Encrypted property to true
2172
+ >>
2173
+ }
2174
+ #
2175
+ #####################################
2176
+ ## Gherkin ##
2177
+ #####################################
2178
+ # Rule Identifier:
2179
+ # S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED
2180
+ #
2181
+ # Description:
2182
+ # Checks if your Amazon S3 bucket either has the Amazon S3 default encryption enabled or that the Amazon S3 bucket policy
2183
+ # explicitly denies put-object requests without server side encryption that uses AES-256 or AWS Key Management Service.
2184
+ #
2185
+ # Reports on:
2186
+ # AWS::S3::Bucket
2187
+ #
2188
+ # Evaluates:
2189
+ # AWS CloudFormation
2190
+ #
2191
+ # Rule Parameters:
2192
+ # NA
2193
+ #
2194
+ # Scenarios:
2195
+ # a) SKIP: when there are no S3 resource present
2196
+ # b) PASS: when all S3 resources Bucket Encryption ServerSideEncryptionByDefault is set to either "aws:kms" or "AES256"
2197
+ # c) FAIL: when all S3 resources have Bucket Encryption ServerSideEncryptionByDefault is not set or does not have "aws:kms" or "AES256" configurations
2198
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED
2199
+
2200
+ #
2201
+ # Select all S3 resources from incoming template (payload)
2202
+ #
2203
+
2204
+ let s3_buckets_server_side_encryption = Resources.*[ Type == 'AWS::S3::Bucket'
2205
+ Metadata.guard.SuppressedRules not exists or
2206
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED"
2207
+ ]
2208
+
2209
+ rule S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED when %s3_buckets_server_side_encryption !empty {
2210
+ %s3_buckets_server_side_encryption.Properties.BucketEncryption exists
2211
+ %s3_buckets_server_side_encryption.Properties.BucketEncryption.ServerSideEncryptionConfiguration[*].ServerSideEncryptionByDefault.SSEAlgorithm in ["aws:kms","AES256"]
2212
+ <<
2213
+ Guard Rule Set: hipaa-security
2214
+ Controls: 164.312(a)(2)(iv),164.312(c)(2),164.312(e)(2)(ii)
2215
+ Violation: S3 Bucket must enable server-side encryption.
2216
+ Fix: Set the S3 Bucket property BucketEncryption.ServerSideEncryptionConfiguration.ServerSideEncryptionByDefault.SSEAlgorithm to either "aws:kms" or "AES256"
2217
+ >>
2218
+ }
2219
+
2220
+ #
2221
+ #####################################
2222
+ ## Gherkin ##
2223
+ #####################################
2224
+ # Rule Identifier:
2225
+ # S3_BUCKET_SSL_REQUESTS_ONLY
2226
+ #
2227
+ # Description:
2228
+ # Checks if Amazon S3 buckets have policies that require requests to use Secure Socket Layer (SSL).
2229
+ #
2230
+ # Reports on:
2231
+ # AWS::S3::BucketPolicy
2232
+ #
2233
+ # Evaluates:
2234
+ # AWS CloudFormation
2235
+ #
2236
+ # Rule Parameters:
2237
+ # NA
2238
+ #
2239
+ # Scenarios:
2240
+ # a) SKIP: when there are no S3 Bucket Policy Document resource present
2241
+ # b) PASS: when all S3 Bucket Policy Document set to deny if condition SecureTransport not true
2242
+ # c) FAIL: when all S3 Bucket Policy Document does not have deny on insecure transport actions
2243
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_SSL_REQUESTS_ONLY
2244
+
2245
+ #
2246
+ # Select all S3 resources from incoming template (payload)
2247
+ #
2248
+ let s3_buckets_policies_ssl_requests_only = Resources.*[ Type == 'AWS::S3::BucketPolicy'
2249
+ Metadata.guard.SuppressedRules not exists or
2250
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_SSL_REQUESTS_ONLY"
2251
+ ]
2252
+
2253
+ rule S3_BUCKET_SSL_REQUESTS_ONLY when %s3_buckets_policies_ssl_requests_only !empty {
2254
+ some %s3_buckets_policies_ssl_requests_only.Properties.PolicyDocument.Statement.* == {"Action":"s3:*","Effect":"Deny","Principal":"*","Resource":"*","Condition":{"Bool":{"aws:SecureTransport":false}}}
2255
+ <<
2256
+ Guard Rule Set: hipaa-security
2257
+ Controls: 164.312(a)(2)(iv),164.312(c)(2),164.312(e)(1),164.312(e)(2)(i),164.312(e)(2)(ii)
2258
+ Violation: Bucket policies must feature a statement to enforce TLS usage.
2259
+ Fix: Set a bucket policy statement to '"Action":"s3:*","Effect":"Deny","Principal":"*","Resource":"*","Condition":{"Bool":{"aws:SecureTransport":false}}' .
2260
+ >>
2261
+ }
2262
+ #
2263
+ #####################################
2264
+ ## Gherkin ##
2265
+ #####################################
2266
+ # Rule Identifier:
2267
+ # S3_DEFAULT_ENCRYPTION_KMS
2268
+ #
2269
+ # Description:
2270
+ # Checks whether the Amazon S3 buckets are encrypted with AWS Key Management Service(AWS KMS).
2271
+ # The rule is NON_COMPLIANT if the Amazon S3 bucket is not encrypted with AWS KMS key.
2272
+ #
2273
+ # Reports on:
2274
+ # AWS::S3::Bucket
2275
+ #
2276
+ # Evaluates:
2277
+ # AWS CloudFormation
2278
+ #
2279
+ # Rule Parameters:
2280
+ # NA
2281
+ #
2282
+ # Scenarios:
2283
+ # a) SKIP: when there are no S3 resource present
2284
+ # b) PASS: when all S3 resources have ServerSideEncryptionConfiguration property set with values of "aws:kms" or "AES256"
2285
+ # c) FAIL: when all S3 resources have ServerSideEncryptionConfiguration property not set or values are not "aws:kms" or "AES256"
2286
+ # d) SKIP: when metadata includes the suppression for rule S3_DEFAULT_ENCRYPTION_KMS
2287
+
2288
+ #
2289
+ # Assignments
2290
+ #
2291
+ let s3_buckets_s3_default_encryption = Resources.*[ Type == 'AWS::S3::Bucket'
2292
+ Metadata.guard.SuppressedRules not exists or
2293
+ Metadata.guard.SuppressedRules.* != "S3_DEFAULT_ENCRYPTION_KMS"
2294
+ ]
2295
+
2296
+ rule S3_DEFAULT_ENCRYPTION_KMS when %s3_buckets_s3_default_encryption !empty {
2297
+ %s3_buckets_s3_default_encryption.Properties.BucketEncryption exists
2298
+ %s3_buckets_s3_default_encryption.Properties.BucketEncryption.ServerSideEncryptionConfiguration[*].ServerSideEncryptionByDefault.SSEAlgorithm in ["aws:kms","AES256"]
2299
+ <<
2300
+ Guard Rule Set: hipaa-security
2301
+ Controls: 164.312(a)(2)(iv),164.312(e)(2)(ii)
2302
+ Violation: S3 Bucket default encryption must be set.
2303
+ Fix: Set the S3 Bucket property BucketEncryption.ServerSideEncryptionConfiguration.ServerSideEncryptionByDefault.SSEAlgorithm to either "aws:kms" or "AES256"
2304
+ >>
2305
+ }
2306
+
2307
+ ## Config Rule Name : sagemaker-endpoint-configuration-kms-key-configured
2308
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/sagemaker-endpoint-configuration-kms-key-configured.html"
2309
+
2310
+ ## Config Rule Name : sagemaker-notebook-instance-kms-key-configured
2311
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/sagemaker-notebook-instance-kms-key-configured.html"
2312
+
2313
+ ## Config Rule Name : sns-encrypted-kms
2314
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/sns-encrypted-kms.html"
2315
+
2316
+ ## Config Rule Name : secretsmanager-using-cmk
2317
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/secretsmanager-using-cmk.html"
2318
+
2319
+ ## Config Rule Name : elbv2-acm-certificate-required
2320
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elbv2-acm-certificate-required.html"
2321
+
2322
+ #
2323
+ #####################################
2324
+ ## Gherkin ##
2325
+ #####################################
2326
+ # Rule Identifier:
2327
+ # API_GW_EXECUTION_LOGGING_ENABLED
2328
+ #
2329
+ # Description:
2330
+ # Checks that all methods in Amazon API Gateway stage has logging enabled. The rule is NON_COMPLIANT if logging is not enabled.
2331
+ #
2332
+ # Reports on:
2333
+ # AWS::ApiGateway::Stage
2334
+ #
2335
+ # Evaluates:
2336
+ # AWS CloudFormation
2337
+ #
2338
+ # Rule Parameters:
2339
+ # NA
2340
+ #
2341
+ # Scenarios:
2342
+ # a) SKIP: when there are no API GW Stage present
2343
+ # b) PASS: when all API GW Stage Methods have logginglevel set to "ERROR" OR "INFO"
2344
+ # c) FAIL: when API GW Domain Names doesn't have logginglevel set to "ERROR" OR "INFO"
2345
+ # d) SKIP: when metadata includes the suppression for rule API_GW_EXECUTION_LOGGING_ENABLED
2346
+
2347
+ let api_gw_execution_logging_enabled = Resources.*[ Type == 'AWS::ApiGateway::Stage'
2348
+ Metadata.guard.SuppressedRules not exists or
2349
+ Metadata.guard.SuppressedRules.* != "API_GW_EXECUTION_LOGGING_ENABLED"
2350
+ ]
2351
+
2352
+ rule API_GW_EXECUTION_LOGGING_ENABLED when %api_gw_execution_logging_enabled !empty {
2353
+ when %api_gw_execution_logging_enabled.Properties.MethodSettings !empty {
2354
+ %api_gw_execution_logging_enabled.Properties.MethodSettings.*.LoggingLevel == "ERROR" OR
2355
+ %api_gw_execution_logging_enabled.Properties.MethodSettings.*.LoggingLevel == "INFO"
2356
+ <<
2357
+ Guard Rule Set: hipaa-security
2358
+ Controls: 164.312(b)
2359
+ Violation: Logging Level for API GW Method Setting not set
2360
+ Fix: API GW Stage Method Setting logging level must be set to "ERROR" or "INFO"
2361
+ >>
2362
+ }
2363
+ }
2364
+ ## Config Rule Name : autoscaling-group-elb-healthcheck-required
2365
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-group-elb-healthcheck-required.html"
2366
+ #
2367
+ #####################################
2368
+ ## Gherkin ##
2369
+ #####################################
2370
+ # Rule Identifier:
2371
+ # AUTOSCALING_GROUP_ELB_HEALTHCHECK_REQUIRED
2372
+ #
2373
+ # Description:
2374
+ # Checks whether your Auto Scaling groups that are associated with a load balancer are using Elastic Load Balancing health checks.
2375
+ #
2376
+ # Reports on:
2377
+ # AWS::AutoScaling::AutoScalingGroup
2378
+ #
2379
+ # Evaluates:
2380
+ # AWS CloudFormation
2381
+ #
2382
+ # Rule Parameters:
2383
+ # NA
2384
+ #
2385
+ # Scenarios:
2386
+ # a) SKIP: when there are no S3 resource present
2387
+ # b) PASS: when all S3 resources ObjectLockEnabled property is set to true
2388
+ # c) FAIL: when all S3 resources do not have the ObjectLockEnabled property is set to true or is missing
2389
+ # d) SKIP: when metada has rule suppression for S3_BUCKET_DEFAULT_LOCK_ENABLED
2390
+
2391
+ #
2392
+ # Select all S3 resources from incoming template (payload)
2393
+ #
2394
+ ## Config Rule Name : beanstalk-enhanced-health-reporting-enabled
2395
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/beanstalk-enhanced-health-reporting-enabled.html"
2396
+
2397
+ #
2398
+ #####################################
2399
+ ## Gherkin ##
2400
+ #####################################
2401
+ # Rule Identifier:
2402
+ # CLOUDWATCH_ALARM_ACTION_CHECK
2403
+ #
2404
+ # Description:
2405
+ # Checks whether CloudWatch alarms have at least one alarm action,
2406
+ # one Insufficient Data Actions action, or one OK action enabled.
2407
+ #
2408
+ # Reports on:
2409
+ # AWS::Logs::LogGroup
2410
+ #
2411
+ # Evaluates:
2412
+ # AWS CloudFormation
2413
+ #
2414
+ # Rule Parameters:
2415
+ # NA
2416
+ #
2417
+ # Scenarios:
2418
+ # a) SKIP: when there are no cloudwatch alarm resources present
2419
+ # b) PASS: when resource Metadata is set with rule suppressed
2420
+ # c) PASS: when all cloudwatch alarm resources property Alarm Actions, Insufficient Data Actions, or OK Action set
2421
+ # d) FAIL: when all cloudwatch alarms resources property Alarm Actions, Insufficient Data Actions, or OK Action are not set with valid value
2422
+ # e) SKIP: when metada has rule suppression for CLOUDWATCH_ALARM_ACTION_CHECK
2423
+
2424
+ #
2425
+ # Select all cloudwatch logs log group resources from incoming template (payload)
2426
+ #
2427
+ let cloudwatch_alarm_action_check = Resources.*[ Type == 'AWS::CloudWatch::Alarm'
2428
+ Metadata.guard.SuppressedRules not exists or
2429
+ Metadata.guard.SuppressedRules.* != "CLOUDWATCH_ALARM_ACTION_CHECK"
2430
+ ]
2431
+
2432
+ rule CLOUDWATCH_ALARM_ACTION_CHECK when %cloudwatch_alarm_action_check !empty {
2433
+ %cloudwatch_alarm_action_check.Properties.AlarmActions exists or
2434
+ %cloudwatch_alarm_action_check.Properties.OKActions exists or
2435
+ %cloudwatch_alarm_action_check.Properties.InsufficientDataActions exists
2436
+
2437
+ <<
2438
+ Guard Rule Set: hipaa-security
2439
+ Controls: 164.312(b)
2440
+ Violation: CloudWatch Alarms should have at least one Alarm Action, one Insufficient Data Actions action, or one OK Action enabled.
2441
+ Fix: Set one Alarm Action, one Insufficient Data Actions action, or one OK Action on the CloudWatch Alarm resource.
2442
+ >>
2443
+ }
2444
+
2445
+
2446
+ #
2447
+ #####################################
2448
+ ## Gherkin ##
2449
+ #####################################
2450
+ # Rule Identifier:
2451
+ # CW_LOGGROUP_RETENTION_PERIOD_CHECK
2452
+ #
2453
+ # Description:
2454
+ # Checks whether Amazon CloudWatch LogGroup retention
2455
+ # period is set to specific number of days.
2456
+ #
2457
+ # Reports on:
2458
+ # AWS::Logs::LogGroup
2459
+ #
2460
+ # Evaluates:
2461
+ # AWS CloudFormation
2462
+ #
2463
+ # Rule Parameters:
2464
+ # NA
2465
+ #
2466
+ # Scenarios:
2467
+ # a) SKIP: when there are no cloudwatch logs log group resources present
2468
+ # b) PASS: when all cloudwatch logs log group resources property RetentionInDays is set
2469
+ # c) FAIL: when all cloudwatch logs log group resources property RetentionInDays is not set with valid value
2470
+ # d) SKIP: when metada has rule suppression for CW_LOGGROUP_RETENTION_PERIOD_CHECK
2471
+
2472
+ #
2473
+ # Select all cloudwatch logs log group resources from incoming template (payload)
2474
+ #
2475
+ let cloudwatch_logs_retention_period = Resources.*[ Type == 'AWS::Logs::LogGroup'
2476
+ Metadata.guard.SuppressedRules not exists or
2477
+ Metadata.guard.SuppressedRules.* != "CW_LOGGROUP_RETENTION_PERIOD_CHECK"
2478
+ ]
2479
+
2480
+ rule CW_LOGGROUP_RETENTION_PERIOD_CHECK when %cloudwatch_logs_retention_period !empty {
2481
+ %cloudwatch_logs_retention_period.Properties.RetentionInDays IN [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
2482
+ <<
2483
+ Guard Rule Set: hipaa-security
2484
+ Controls: 164.312(b)
2485
+ Violation: CloudWatch Log LogsGroup does not have RetentionInDays set.
2486
+ Fix: Set the RetentionInDays parameter to a value of 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, or 3653.
2487
+ >>
2488
+ }
2489
+ ## Config Rule Name : dynamodb-throughput-limit-check
2490
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-throughput-limit-check.html"
2491
+
2492
+ #
2493
+ #####################################
2494
+ ## Gherkin ##
2495
+ #####################################
2496
+ # Rule Identifier:
2497
+ # EC2_INSTANCE_DETAILED_MONITORING_ENABLED
2498
+ #
2499
+ # Description:
2500
+ # Checks if detailed monitoring is enabled for EC2 instances.
2501
+ #
2502
+ # Reports on:
2503
+ # AWS::EC2::Instance
2504
+ #
2505
+ # Evaluates:
2506
+ # AWS CloudFormation
2507
+ #
2508
+ # Rule Parameters:
2509
+ # NA
2510
+ #
2511
+ # Scenarios:
2512
+ # a) SKIP: when there are no EC2 resource present
2513
+ # b) PASS: when all EC2 resources have the Monitoring property set to true
2514
+ # c) FAIL: when any EC2 resources do not have the Monitoring property set to true
2515
+ # d) SKIP: hen metadata includes the suppression for rule EC2_INSTANCE_DETAILED_MONITORING_ENABLED
2516
+
2517
+ #
2518
+ # Select all EC2 Instance resources from incoming template (payload)
2519
+ #
2520
+ let ec2_instances_detailed_monitoring_enabled = Resources.*[ Type == 'AWS::EC2::Instance'
2521
+ Metadata.guard.SuppressedRules not exists or
2522
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCE_DETAILED_MONITORING_ENABLED"
2523
+ ]
2524
+
2525
+ rule EC2_INSTANCE_DETAILED_MONITORING_ENABLED when %ec2_instances_detailed_monitoring_enabled !empty {
2526
+ %ec2_instances_detailed_monitoring_enabled.Properties.Monitoring == true
2527
+ <<
2528
+ Guard Rule Set: hipaa-security
2529
+ Controls: 164.312(b)
2530
+ Violation: EC2 Instance Monitoring must be enabled on all EC2 instances
2531
+ Fix: set the Monitoring property to true
2532
+ >>
2533
+ }
2534
+ ## Config Rule Name : elb-logging-enabled
2535
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-logging-enabled.html"
2536
+
2537
+ #
2538
+ #####################################
2539
+ ## Gherkin ##
2540
+ #####################################
2541
+ # Rule Identifier:
2542
+ # LAMBDA_CONCURRENCY_CHECK
2543
+ #
2544
+ # Description:
2545
+ # Checks whether the AWS Lambda function is configured with function-level concurrent execution limit.
2546
+ #
2547
+ # Reports on:
2548
+ # AWS::Lambda::Function
2549
+ #
2550
+ # Evaluates:
2551
+ # AWS CloudFormation
2552
+ #
2553
+ # Rule Parameters:
2554
+ # NA
2555
+ #
2556
+ # Scenarios:
2557
+ # a) SKIP: when no AWS Lambda functions are present
2558
+ # b) PASS: when all AWS Lambda functions are configured with function-level concurrent execution limits
2559
+ # c) FAIL: when any AWS Lambda functions are not configured with function-level concurrent execution limits
2560
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_CONCURRENCY_CHECK
2561
+
2562
+ #
2563
+ # Select all AWS Lambda Function resources from incoming template (payload)
2564
+ #
2565
+ let aws_lambda_functions_concurrency = Resources.*[ Type == 'AWS::Lambda::Function'
2566
+ Metadata.guard.SuppressedRules not exists or
2567
+ Metadata.guard.SuppressedRules.* != "LAMBDA_CONCURRENCY_CHECK"
2568
+ ]
2569
+
2570
+ rule LAMBDA_CONCURRENCY_CHECK when %aws_lambda_functions_concurrency !empty {
2571
+ %aws_lambda_functions_concurrency.Properties.ReservedConcurrentExecutions >= 0
2572
+ <<
2573
+ Guard Rule Set: hipaa-security
2574
+ Controls: 164.312(b)
2575
+ Violation: All AWS Lambda Functions must have concurrent execution limits configured
2576
+ Fix: Set the ReservedConcurrentExecutions property to an integer greater than or equal to 0
2577
+ >>
2578
+ }
2579
+ #
2580
+ #####################################
2581
+ ## Gherkin ##
2582
+ #####################################
2583
+ # Rule Identifier:
2584
+ # LAMBDA_DLQ_CHECK
2585
+ #
2586
+ # Description:
2587
+ # Checks whether an AWS Lambda function is configured with a dead-letter queue.
2588
+ #
2589
+ # Reports on:
2590
+ # AWS::Lambda::Function
2591
+ #
2592
+ # Evaluates:
2593
+ # AWS CloudFormation
2594
+ #
2595
+ # Rule Parameters:
2596
+ # NA
2597
+ #
2598
+ # Scenarios:
2599
+ # a) SKIP: when no AWS Lambda functions are present
2600
+ # b) PASS: when all AWS Lambda functions are configured with a dead-letter queue
2601
+ # c) FAIL: when any AWS Lambda functions are not configured with a dead-letter queue
2602
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_DLQ_CHECK
2603
+
2604
+ #
2605
+ # Select all AWS Lambda Function resources from incoming template (payload)
2606
+ #
2607
+ let aws_lambda_functions_dlq = Resources.*[ Type == 'AWS::Lambda::Function'
2608
+ Metadata.guard.SuppressedRules not exists or
2609
+ Metadata.guard.SuppressedRules.* != "LAMBDA_DLQ_CHECK"
2610
+ ]
2611
+
2612
+ rule LAMBDA_DLQ_CHECK when %aws_lambda_functions_dlq !empty {
2613
+ %aws_lambda_functions_dlq.Properties.DeadLetterConfig.TargetArn !empty
2614
+ <<
2615
+ Guard Rule Set: hipaa-security
2616
+ Controls: 164.312(b)
2617
+ Violation: All AWS Lambda Functions must have a dead-letter queue configured
2618
+ Fix: Set the DeadLetterConfig.TargetAr Property to the Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic
2619
+ >>
2620
+ }
2621
+ #
2622
+ #####################################
2623
+ ## Gherkin ##
2624
+ #####################################
2625
+ # Rule Identifier:
2626
+ # RDS_ENHANCED_MONITORING_ENABLED
2627
+ #
2628
+ # Description:
2629
+ # Checks whether enhanced monitoring is enabled for Amazon Relational Database Service (Amazon RDS) instances.
2630
+ #
2631
+ # Reports on:
2632
+ # AWS::RDS::DBInstance
2633
+ #
2634
+ # Evaluates:
2635
+ # AWS CloudFormation
2636
+ #
2637
+ # Rule Parameters:
2638
+ # NA
2639
+ #
2640
+ # Scenarios:
2641
+ # a) SKIP: when there are no RDS instances present
2642
+ # b) PASS: when all RDS instances have MonitoringInterval set to a value of 1, 5, 10, 15, 30, or 60
2643
+ # c) FAIL: when all RDS instances have MonitoringInterval set to 0
2644
+ # d) FAIL: when there are RDS instances with MonitoringInterval property is not present
2645
+ # e) SKIP: when metadata includes the suppression for rule RDS_ENHANCED_MONITORING_ENABLED
2646
+
2647
+
2648
+ #
2649
+ # Select all RDS instance resources from incoming template (payload)
2650
+ #
2651
+
2652
+ let aws_rds_instances_enhanced_monitoring_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
2653
+ Metadata.guard.SuppressedRules not exists or
2654
+ Metadata.guard.SuppressedRules.* != "RDS_ENHANCED_MONITORING_ENABLED"
2655
+ ]
2656
+
2657
+
2658
+ rule RDS_ENHANCED_MONITORING_ENABLED when %aws_rds_instances_enhanced_monitoring_enabled !empty {
2659
+ %aws_rds_instances_enhanced_monitoring_enabled.Properties.MonitoringInterval EXISTS
2660
+ %aws_rds_instances_enhanced_monitoring_enabled.Properties.MonitoringInterval IN [1, 5, 10, 15, 30, 60]
2661
+ <<
2662
+ Guard Rule Set: hipaa-security
2663
+ Controls: 164.312(b)
2664
+ Violation: RDS Instance enhanced monitoring required.
2665
+ Fix: Specify a value of 1, 5, 10, 15, 30, or 60 for the parameter on the property MonitoringInterval.
2666
+ >>
2667
+ }
2668
+
2669
+ ## Config Rule Name : wafv2-logging-enabled
2670
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/wafv2-logging-enabled.html"
2671
+
2672
+ #
2673
+ #####################################
2674
+ ## Gherkin ##
2675
+ #####################################
2676
+ # Rule Identifier:
2677
+ # CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED
2678
+ #
2679
+ # Description:
2680
+ # Checks whether AWS CloudTrail creates a signed digest file with logs.
2681
+ #
2682
+ # Reports on:
2683
+ # AWS::CloudTrail::Trail
2684
+ #
2685
+ # Evaluates:
2686
+ # AWS CloudFormation
2687
+ #
2688
+ # Rule Parameters:
2689
+ # NA
2690
+ #
2691
+ # Scenarios:
2692
+ # a) SKIP: when there are no CloudTrail Trails present
2693
+ # b) PASS: when all CloudTrail Trails have EnableLogFileValidation parameter set true
2694
+ # c) FAIL: when there are CloudTrail Trails with the EnableLogFileValidation parameter is set to false
2695
+ # d) FAIL: when there are CloudTrail Trails with EnableLogFileValidation property not present
2696
+ # e) SKIP: when metada has rule suppression for CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED
2697
+
2698
+
2699
+ #
2700
+ # Select all CloudTrail Trail resources from incoming template (payload)
2701
+ #
2702
+ let cloudtrail_trails_log_validation = Resources.*[ Type == 'AWS::CloudTrail::Trail'
2703
+ Metadata.guard.SuppressedRules not exists or
2704
+ Metadata.guard.SuppressedRules.* != "CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED"
2705
+ ]
2706
+
2707
+ rule CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED when %cloudtrail_trails_log_validation !empty {
2708
+ %cloudtrail_trails_log_validation.Properties.EnableLogFileValidation EXISTS
2709
+ %cloudtrail_trails_log_validation.Properties.EnableLogFileValidation == true
2710
+ <<
2711
+ Guard Rule Set: hipaa-security
2712
+ Controls: 164.312(c)(1),164.312(c)(2)
2713
+ Violation: CloudTrail Trail should have Log File Validation enabled.
2714
+ Fix: Set the EnableLogFileValidation parameter to true.
2715
+ >>
2716
+ }
2717
+ #
2718
+ #####################################
2719
+ ## Gherkin ##
2720
+ #####################################
2721
+ # Rule Identifier:
2722
+ # NO_UNRESTRICTED_ROUTE_TO_IGW
2723
+ #
2724
+ # Description:
2725
+ # Checks if there are public routes in the route table to an Internet Gateway (IGW).
2726
+ #
2727
+ # Reports on:
2728
+ # AWS::EC2::Route
2729
+ #
2730
+ # Evaluates:
2731
+ # AWS CloudFormation
2732
+ #
2733
+ # Rule Parameters:
2734
+ # NA
2735
+ #
2736
+ # Scenarios:
2737
+ # a) SKIP: when no EC2 Route resources are present
2738
+ # b) SKIP: when there are no EC2 Routes to an Internet Gateway (no GatewayId property)
2739
+ # c) PASS: when all EC2 Routes to an Internet Gateway have a restricted destination CIDR block (not '0.0.0.0/0' or '::/0')
2740
+ # d) FAIL: when any EC2 Routes to an Internet Gateway have a destination CIDR block of '0.0.0.0/0' or '::/0'
2741
+ # e) SKIP: hen metadata includes the suppression for rule NO_UNRESTRICTED_ROUTE_TO_IGW
2742
+
2743
+ #
2744
+ # Select all EC2 Route resources from incoming template (payload)
2745
+ #
2746
+ let routes_no_unrestricted_to_igw = Resources.*[ Type == 'AWS::EC2::Route'
2747
+ Properties.GatewayId exists
2748
+ Metadata.guard.SuppressedRules not exists or
2749
+ Metadata.guard.SuppressedRules.* != "NO_UNRESTRICTED_ROUTE_TO_IGW"
2750
+ ]
2751
+
2752
+ rule NO_UNRESTRICTED_ROUTE_TO_IGW when %routes_no_unrestricted_to_igw !empty {
2753
+ %routes_no_unrestricted_to_igw {
2754
+ Properties {
2755
+ DestinationCidrBlock not in ['0.0.0.0/0', '::/0']
2756
+ <<
2757
+ Guard Rule Set: hipaa-security
2758
+ Controls: 164.312(e)(1)
2759
+ Violation: EC2 Routes to an IGW cannot have a destination CIDR block of '0.0.0.0/0' or '::/0'
2760
+ Fix: Remove routes to an IGW (with the GatewayId property defined) or modify the DestinationCidrBlock property to a more restricted CIDR block
2761
+ >>
2762
+ }
2763
+ }
2764
+ }
2765
+ ####################################
2766
+ ## Gherkin ##
2767
+ #####################################
2768
+ # Rule Identifier:
2769
+ # REDSHIFT_ENHANCED_VPC_ROUTING_ENABLED
2770
+ #
2771
+ # Description:
2772
+ # Checks if Amazon Redshift cluster has 'enhancedVpcRouting' enabled.
2773
+ #
2774
+ # Reports on:
2775
+ # AWS::Redshift::Cluster
2776
+ #
2777
+ # Evaluates:
2778
+ # AWS CloudFormation
2779
+ #
2780
+ # Rule Parameters:
2781
+ # NA
2782
+ #
2783
+ # Scenarios:
2784
+ # a) SKIP: when there are no Redshift Cluster resource present
2785
+ # b) PASS: when Redshift Cluster resources have property EnhancedVpcRouting set to true
2786
+ # c) FAIL: when any Redshift Cluster resources do not have EnhancedVpcRouting property set (defualt false)
2787
+ # d) FAIL: when any Redshift Cluster resources have EnhancedVpcRouting property set to false
2788
+ # e) SKIP: when metadata includes the suppression for rule REDSHIFT_ENHANCED_VPC_ROUTING_ENABLED
2789
+
2790
+ #
2791
+ # Select all Redshift Cluster resources from incoming template (payload)
2792
+ #
2793
+ let redhshift_enhanced_vpc_routing_enabled_clusters = Resources.*[ Type == 'AWS::Redshift::Cluster'
2794
+ Metadata.guard.SuppressedRules not exists or
2795
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_ENHANCED_VPC_ROUTING_ENABLED"
2796
+ ]
2797
+
2798
+ rule REDSHIFT_ENHANCED_VPC_ROUTING_ENABLED when %redhshift_enhanced_vpc_routing_enabled_clusters !empty {
2799
+ %redhshift_enhanced_vpc_routing_enabled_clusters.Properties.EnhancedVpcRouting == true
2800
+
2801
+ <<
2802
+ Guard Rule Set: hipaa-security
2803
+ Controls: 164.312(e)(1)
2804
+ Violation: Enhanced VPC Routing must be enabled on Redshift clusters
2805
+ Fix: set the EnhancedVpcRouting property to true
2806
+ >>
2807
+ }