inspec 2.1.72 → 2.1.78

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -13
  3. data/Gemfile +1 -1
  4. data/docs/resources/aws_cloudtrail_trail.md.erb +10 -4
  5. data/docs/resources/aws_cloudtrail_trails.md.erb +6 -1
  6. data/docs/resources/aws_cloudwatch_alarm.md.erb +10 -5
  7. data/docs/resources/aws_cloudwatch_log_metric_filter.md.erb +4 -1
  8. data/docs/resources/aws_config_delivery_channel.md.erb +9 -4
  9. data/docs/resources/aws_config_recorder.md.erb +10 -5
  10. data/docs/resources/aws_ec2_instance.md.erb +6 -0
  11. data/docs/resources/aws_iam_access_key.md.erb +8 -2
  12. data/docs/resources/aws_iam_access_keys.md.erb +11 -5
  13. data/docs/resources/aws_iam_group.md.erb +6 -0
  14. data/docs/resources/aws_iam_groups.md.erb +7 -1
  15. data/docs/resources/aws_iam_password_policy.md.erb +7 -1
  16. data/docs/resources/aws_iam_policies.md.erb +8 -3
  17. data/docs/resources/aws_iam_policy.md.erb +14 -8
  18. data/docs/resources/aws_iam_role.md.erb +6 -0
  19. data/docs/resources/aws_iam_root_user.md.erb +6 -0
  20. data/docs/resources/aws_iam_user.md.erb +9 -4
  21. data/docs/resources/aws_iam_users.md.erb +12 -6
  22. data/docs/resources/aws_kms_key.md.erb +11 -5
  23. data/docs/resources/aws_kms_keys.md.erb +7 -2
  24. data/docs/resources/aws_rds_instance.md.erb +6 -0
  25. data/docs/resources/aws_route_table.md.erb +6 -0
  26. data/docs/resources/aws_route_tables.md.erb +6 -0
  27. data/docs/resources/aws_s3_bucket.md.erb +7 -1
  28. data/docs/resources/aws_s3_bucket_object.md.erb +8 -2
  29. data/docs/resources/aws_s3_buckets.md.erb +7 -1
  30. data/docs/resources/aws_security_group.md.erb +24 -18
  31. data/docs/resources/aws_security_groups.md.erb +6 -0
  32. data/docs/resources/aws_sns_subscription.md.erb +17 -12
  33. data/docs/resources/aws_sns_topic.md.erb +6 -0
  34. data/docs/resources/aws_sns_topics.md.erb +6 -0
  35. data/docs/resources/aws_subnet.md.erb +19 -13
  36. data/docs/resources/aws_subnets.md.erb +6 -0
  37. data/docs/resources/aws_vpc.md.erb +6 -1
  38. data/docs/resources/aws_vpcs.md.erb +6 -0
  39. data/docs/resources/http.md.erb +6 -6
  40. data/inspec.gemspec +3 -1
  41. data/lib/inspec/reporters/automate.rb +1 -1
  42. data/lib/inspec/version.rb +1 -1
  43. data/lib/resources/aws/aws_iam_policy.rb +2 -1
  44. data/lib/resources/aws/aws_security_group.rb +4 -4
  45. metadata +18 -4
@@ -56,7 +56,7 @@ The following examples show how to use this InSpec audit resource.
56
56
  # Verify that there is at least one statement allowing access to S3
57
57
  it { should have_statement(Action: 's3:PutObject', Effect: 'allow') }
58
58
 
59
- # have_statement does not expand wildcards. If you want to verify
59
+ # have_statement does not expand wildcards. If you want to verify
60
60
  # they are absent, an explicit check is required.
61
61
  it { should_not have_statement(Action: 's3:*') }
62
62
  end
@@ -125,11 +125,11 @@ Returns the default version of the policy document after decoding as a Ruby hash
125
125
 
126
126
  For details regarding the contents of this structure, refer to the [AWS IAM Policy JSON Reference](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html). A set of examples is [also available](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html).
127
127
 
128
- Example:
128
+ Example:
129
129
 
130
130
  # Fetch the policy structure as a Ruby object
131
131
  policy_struct = aws_iam_policy('my-policy').policy
132
- # Write a manually-constructed test to check that the policy
132
+ # Write a manually-constructed test to check that the policy
133
133
  # has an IP constraint on the first statement
134
134
  # ( Based on https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_deny-ip.html )
135
135
  describe 'Check that we are restricting IP access' do
@@ -195,10 +195,10 @@ Examines the list of statements contained in the policy and passes if at least o
195
195
 
196
196
  Please note the following about the behavior of `have_statement`:
197
197
  * `Action`, `Sid`, and `Resource` allow using a regular expression as the search critera instead of a string literal.
198
- * it does not support wildcard expansion; to check for a wildcard value, check for it explicitly. For example, if the policy includes a statement with `"Action": "s3:*"` and the test checks for `Action: "s3:PutObject"`, the test _will not match_. You must write an additional test checking for the wildcard case.
198
+ * it does not support wildcard expansion; to check for a wildcard value, check for it explicitly. For example, if the policy includes a statement with `"Action": "s3:*"` and the test checks for `Action: "s3:PutObject"`, the test _will not match_. You must write an additional test checking for the wildcard case.
199
199
  * it supports searching list values. For example, if a statement contains a list of 3 resources, and a `have_statement` test specifes _one_ of those resources, it will match.
200
200
  * `Action` and `Resource` allow using a list of string literals or regular expressions in a test, in which case _all_ must match on the _same_ statement for the test to match. Order is ignored.
201
- * it does not support the `Principal` or `Conditional` key, or any of `NotAction`, `NotPrincipal`, or `NotResource`.
201
+ * it does not support the `[Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal)` or `Conditional` key, or any of `NotAction`, `Not[Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal)`, or `NotResource`.
202
202
 
203
203
  Examples:
204
204
 
@@ -210,7 +210,7 @@ Examples:
210
210
  # Verify bob is allowed to manage things on S3 buckets that start with bobs-stuff
211
211
  describe aws_iam_policy('bob-is-a-packrat') do
212
212
  it { should have_statement(Effect: 'Allow',
213
- # Using the AWS wildcard - this must match exactly
213
+ # Using the AWS wildcard - this must match exactly
214
214
  Resource: 'arn:aws:s3:::bobs-stuff*',
215
215
  # Specify a list of actions - all must match, no others, order isn't important
216
216
  Action: ['s3:PutObject', 's3:GetObject', 's3:DeleteObject'])}
@@ -220,7 +220,7 @@ Examples:
220
220
  it { should_not have_statement(Effect: 'Allow', Action: 's3:*')}
221
221
  it { should_not have_statement(Effect: 'Allow', Action: '*')}
222
222
 
223
- # An alternative to checking for wildcards is to specify the
223
+ # An alternative to checking for wildcards is to specify the
224
224
  # statements you expect, then restrict statement count
225
225
  its('statement_count') { should cmp 1 }
226
226
  end
@@ -230,10 +230,16 @@ Examples:
230
230
  # Check to see if anything mentions RDS at all.
231
231
  # This catches `rds:CreateDBinstance` and `rds:*`, but would not catch '*'.
232
232
  it { should_not have_statement(Action: /^rds:.+$/)}
233
-
233
+
234
234
  # This policy should refer to both sally and kim's s3 buckets.
235
235
  # This will only match if there is a statement that refers to both resources.
236
236
  it { should have_statement(Resource: [/arn:aws:s3.+:sally/, /arn:aws:s3.+:kim/]) }
237
237
  # The following also matches on a statement mentioning only one of them
238
238
  it { should have_statement(Resource: /arn:aws:s3.+:(sally|kim)/) }
239
239
  end
240
+
241
+ ## AWS Permissions
242
+
243
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `iam:GetPolicy`, `iam:ListPolicy`, and `iam:ListEntitiesForPolicy` actions set to allow.
244
+
245
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Identity And Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html).
@@ -61,3 +61,9 @@ Indicates that the Role Name provided was found. Use `should_not` to test for IA
61
61
  describe aws_iam_role('should-not-be-there') do
62
62
  it { should_not exist }
63
63
  end
64
+
65
+ ## AWS Permissions
66
+
67
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `iam:GetRole` action with Effect set to Allow.
68
+
69
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Identity And Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html).
@@ -68,3 +68,9 @@ The `have_virtual_mfa_enabled` matcher tests if the AWS root user has Virtual Mu
68
68
  The `have_access_key` matcher tests if the AWS root user has at least one access key.
69
69
 
70
70
  it { should have_access_key }
71
+
72
+ ## AWS Permissions
73
+
74
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `iam:GetAccountSummary` action with Effect set to Allow.
75
+
76
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Identity And Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html).
@@ -57,7 +57,7 @@ Returns a list of IAM Managed Policy ARNs as strings that identify the policies
57
57
  # This is a customer-managed policy
58
58
  its('attached_policy_arns') { should include 'arn:aws:iam::123456789012:policy/test-inline-policy-01' }
59
59
  # This is an AWS-managed policy
60
- its('attached_policy_arns') { should include 'arn:aws:iam::aws:policy/AlexaForBusinessGatewayExecution' }
60
+ its('attached_policy_arns') { should include 'arn:aws:iam::aws:policy/AlexaForBusinessGatewayExecution' }
61
61
  end
62
62
 
63
63
  ### attached\_policy\_names
@@ -68,7 +68,7 @@ Returns a list of IAM Managed Policy Names as strings that identify the policies
68
68
  # This is a customer-managed policy
69
69
  its('attached_policy_names') { should include 'test-inline-policy-01' }
70
70
  # This is an AWS-managed policy
71
- its('attached_policy_names') { should include 'AlexaForBusinessGatewayExecution' }
71
+ its('attached_policy_names') { should include 'AlexaForBusinessGatewayExecution' }
72
72
  end
73
73
 
74
74
  ### inline\_policy\_names
@@ -77,7 +77,7 @@ Returns a list of IAM Inline Policy Names as strings that identify the inline po
77
77
 
78
78
  describe aws_iam_user('bob') do
79
79
  its('inline_policy_names') { should include 'test-inline-policy-01' }
80
- its('inline_policy_names.count') { should eq 1 }
80
+ its('inline_policy_names.count') { should eq 1 }
81
81
  end
82
82
 
83
83
 
@@ -112,4 +112,9 @@ The `have\_inline\_policies` matcher tests if the user has at least one IAM poli
112
112
  The `have_mfa_enabled` matcher tests if the user has Multi-Factor Authentication enabled, requiring them to enter a secondary code when they login to the web console.
113
113
 
114
114
  it { should have_mfa_enabled }
115
-
115
+
116
+ ## AWS Permissions
117
+
118
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `iam:GetUser`, `iam:GetLoginProfile`, `iam:ListMFADevices`, `iam:ListAccessKeys`, `iam:ListUserPolicies`, and `iam:ListAttachedUserPolicies` actions set to allow.
119
+
120
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Identity And Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html).
@@ -99,7 +99,7 @@ True or false. Filters the users to include only those that have at least one IA
99
99
 
100
100
  ### has\_console\_password
101
101
 
102
- True or false. Filters the users to include only those that have a console password (that is, they are able to login to the AWS web UI using a password).
102
+ True or false. Filters the users to include only those that have a console password (that is, they are able to login to the AWS web UI using a password).
103
103
 
104
104
  # No console passwords for anyone
105
105
  describe aws_iam_users.where(has_console_password: true) do
@@ -143,8 +143,8 @@ Integer. Filters the users to include only those who used their password a certa
143
143
  end
144
144
 
145
145
  # This filter is often more useful in block mode, using a greater-than
146
- # Here, audit users who have not logged in in the last 30 days
147
- describe aws_iam_users.where do
146
+ # Here, audit users who have not logged in in the last 30 days
147
+ describe aws_iam_users.where do
148
148
  password_ever_used && password_last_used_days_ago > 30
149
149
  end do
150
150
  it { should_not exist' }
@@ -169,8 +169,8 @@ String. Filters the users to include only those whose username matches the value
169
169
  it { should_not have_console_password }
170
170
  end
171
171
 
172
- # Method call example. This is a poor use of aws_iam_users (plural);
173
- # if you want to audit an individual user whose username you know, use
172
+ # Method call example. This is a poor use of aws_iam_users (plural);
173
+ # if you want to audit an individual user whose username you know, use
174
174
  # aws_iam_user (singular)
175
175
  # Verify Bob exists
176
176
  describe aws_iam_users.where(username: 'bob') do
@@ -222,7 +222,7 @@ Array of strings. Each entry is the name of a user that matched. There will be e
222
222
 
223
223
  ## Matchers
224
224
 
225
- This InSpec audit resource has the following resource-specific matchers.
225
+ This InSpec audit resource has the following resource-specific matchers.
226
226
  For a full list of available matchers, please visit our [universal matchers page](https://www.inspec.io/docs/reference/matchers/).
227
227
 
228
228
  As a plural resource, all matchers beginning with `have_` will return true if _any_ of the selected users match.
@@ -271,3 +271,9 @@ The test passes if at least one user in the filtered set has MFA enabled (virtua
271
271
  describe aws_iam_users do
272
272
  it { should have_mfa_enabled }
273
273
  end
274
+
275
+ ## AWS Permissions
276
+
277
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `iam:ListUsers`, `iam:GetLoginProfile`, `iam:ListMFADevices`, `iam:ListAccessKeys`, `iam:ListUserPolicies`, and `iam:ListAttachedUserPolicies` action with Effect set to Allow.
278
+
279
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Identity And Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html).
@@ -22,7 +22,7 @@ An aws_kms_key resource block identifies a key by key_arn or the key id.
22
22
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
23
23
  it { should exist }
24
24
  end
25
-
25
+
26
26
  # Find a kms key by just the id
27
27
  describe aws_kms_key('4321dcba-21io-23de-85he-ab0987654321') do
28
28
  it { should exist }
@@ -79,7 +79,7 @@ The ARN identifier of the specified key. An ARN uniquely identifies the key with
79
79
 
80
80
  ### creation_date
81
81
 
82
- Specifies the date and time when the key was created.
82
+ Specifies the date and time when the key was created.
83
83
 
84
84
  # Makes sure that the key was created at least 10 days ago
85
85
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
@@ -138,14 +138,14 @@ The test will pass if the specified key's key_state is set to enabled.
138
138
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
139
139
  it { should be_enabled }
140
140
  end
141
-
141
+
142
142
  ### be\_external
143
143
  Provides whether the source of the key's key material is external or not. If it is not external than it was created by AWS KMS. When it is external, the key material was imported from an existing key management infrastructure or the key lacks key material.
144
144
 
145
145
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
146
146
  its { should be_external }
147
147
  end
148
-
148
+
149
149
  ### be\_managed\_by\_aws
150
150
 
151
151
  Provides whether or not the key manager is from AWS. If it is not managed by AWS, it is managed by the customer.
@@ -153,7 +153,7 @@ Provides whether or not the key manager is from AWS. If it is not managed by AWS
153
153
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
154
154
  its { should be_managed_by_aws }
155
155
  end
156
-
156
+
157
157
  ### have\_key\_expiration
158
158
 
159
159
  Specifies whether the key's key material expires. This value is null unless the keys Origin is External.
@@ -169,3 +169,9 @@ The test will pass if automatic rotation of the key material is enabled for the
169
169
  describe aws_kms_key('arn:aws:kms:us-east-1::key/4321dcba-21io-23de-85he-ab0987654321') do
170
170
  it { should have_rotation_enabled }
171
171
  end
172
+
173
+ ## AWS Permissions
174
+
175
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `kms:DescribeKey`, and `kms:GetKeyRotationStatus` actions set to allow.
176
+
177
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for AWS Key Management Service](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awskeymanagementservice.html).
@@ -7,7 +7,7 @@ platform: aws
7
7
 
8
8
  Use the `aws_kms_keys` InSpec audit resource to test properties of some or all AWS KMS Keys.
9
9
 
10
- AWS Key Management Service (KMS) is a managed service that makes creating and controlling your encryption keys for your data easier. KMS uses Hardware Security Modules (HSMs) to protect the security of your keys.
10
+ AWS Key Management Service (KMS) is a managed service that makes creating and controlling your encryption keys for your data easier. KMS uses Hardware Security Modules (HSMs) to protect the security of your keys.
11
11
 
12
12
  AWS Key Management Service is integrated with several other AWS services to help you protect the data you store with these services.
13
13
 
@@ -80,5 +80,10 @@ The control will pass if the filter returns at least one result. Use `should_not
80
80
  # Verify that at least one KMS Key exists.
81
81
  describe aws_kms_keys
82
82
  it { should exist }
83
- end
83
+ end
84
+
85
+ ## AWS Permissions
86
+
87
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `kms:ListKeys` action with Effect set to Allow.
84
88
 
89
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for AWS Key Management Service](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awskeymanagementservice.html).
@@ -58,3 +58,9 @@ The control will pass if the specified RDS instance was found. Use should_not i
58
58
  describe aws_rds_instance('nogood') do
59
59
  it { should_not exist }
60
60
  end
61
+
62
+ ## AWS Permissions
63
+
64
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `rds:DescribeDBInstances` action with Effect set to Allow.
65
+
66
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon RDS](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonrds.html).
@@ -45,3 +45,9 @@ Indicates that the Route Table provided was found. Use `should_not` to test for
45
45
  describe aws_route_table('should-not-be-there') do
46
46
  it { should_not exist }
47
47
  end
48
+
49
+ ## AWS Permissions
50
+
51
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `ec2:DescribeRouteTables` action with Effect set to Allow.
52
+
53
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon EC2](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html).
@@ -47,3 +47,9 @@ Lists all of the Route Table IDs.
47
47
  describe aws_route_tables do
48
48
  its('route_table_ids') { should include 'rtb-12345678' }
49
49
  end
50
+
51
+ ## AWS Permissions
52
+
53
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `ec2:DescribeRouteTables` action with Effect set to Allow.
54
+
55
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon EC2](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html).
@@ -79,7 +79,7 @@ The `bucket_acl` property is a low-level property that lists the individual Buck
79
79
 
80
80
  The value of bucket_acl is an array of simple objects. Each object has a `permission` property and a `grantee` property. The `permission` property will be a string such as 'READ', 'WRITE' etc (See the [AWS documentation](https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#get_bucket_acl-instance_method) for a full list). The `grantee` property contains sub-properties, such as `type` and `uri`.
81
81
 
82
-
82
+
83
83
  bucket_acl = aws_s3_bucket('my-bucket')
84
84
 
85
85
  # Look for grants to "AllUsers" (that is, the public)
@@ -138,3 +138,9 @@ The `have_access_logging_enabled` matcher tests if access logging is enabled for
138
138
  The `have_default_encryption_enabled` matcher tests if default encryption is enabled for the s3 bucket.
139
139
 
140
140
  it { should have_default_encryption_enabled }
141
+
142
+ ## AWS Permissions
143
+
144
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `s3:GetBucketAcl`, `s3:GetBucketLocation`, `s3:GetBucketLogging`, `s3:GetBucketPolicy`, and `s3:GetEncryptionConfiguration` actions set to allow.
145
+
146
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon S3](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazons3.html).
@@ -6,7 +6,7 @@ title: About the aws_s3_bucket_object Resource
6
6
 
7
7
  Use the `aws_s3_bucket_object` InSpec audit resource to test properties of a single AWS bucket object.
8
8
 
9
- Each S3 Object has a 'key' which can be thought of as the name of the S3 Object which uniquely identifies it.
9
+ Each S3 Object has a 'key' which can be thought of as the name of the S3 Object which uniquely identifies it.
10
10
 
11
11
 
12
12
  <br>
@@ -54,7 +54,7 @@ The `object_acl` property is a low-level property that lists the individual Obje
54
54
 
55
55
  The value of object_acl is an Array of simple objects. Each object has a `permission` property and a `grantee` property. The `permission` property will be a string such as 'READ', 'WRITE' etc (See the [AWS documentation](https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#get_bucket_acl-instance_method) for a full list). The `grantee` property contains sub-properties, such as `type` and `uri`.
56
56
 
57
-
57
+
58
58
  object_acl = aws_s3_bucket_object(bucket_name: 'my_bucket', key: 'object_key')
59
59
 
60
60
  # Look for grants to "AllUsers" (that is, the public)
@@ -81,3 +81,9 @@ The `be_public` matcher tests if the object has potentially insecure access cont
81
81
  Note: This resource does not detect insecure bucket ACLs.
82
82
 
83
83
  it { should_not be_public }
84
+
85
+ ## AWS Permissions
86
+
87
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `s3:GetObject`, and `s3:GetObjectAcl` actions set to allow.
88
+
89
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon S3](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazons3.html).
@@ -45,9 +45,15 @@ The control will pass if the resource contains at least one bucket.
45
45
 
46
46
  Provides an array of strings containing the names of the buckets.
47
47
 
48
- # Examine what buckets have been created.
48
+ # Examine what buckets have been created.
49
49
  describe aws_s3_buckets do
50
50
  its('bucket_names') { should eq ['my_bucket'] }
51
51
  # OR
52
52
  its('bucket_names') { should include 'my_bucket' }
53
53
  end
54
+
55
+ ## AWS Permissions
56
+
57
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `s3:ListAllMyBuckets` action with Effect set to Allow.
58
+
59
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon S3](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazons3.html).
@@ -20,7 +20,7 @@ While this resource provides facilities for searching inbound and outbound rules
20
20
 
21
21
  ## Syntax
22
22
 
23
- Resource parameters: group_id, group_name, id, vpc_id
23
+ Resource parameters: group_id, group_name, id, vpc_id
24
24
 
25
25
  An `aws_security_group` resource block uses resource parameters to search for and then test a Security Group. If no SGs match, no error is raised, but the `exists` matcher returns `false`, and all scalar properties are `nil`. List properties returned under these conditions are empty lists. If more than one SG matches (due to vague search parameters), an error is raised.
26
26
 
@@ -36,13 +36,13 @@ An `aws_security_group` resource block uses resource parameters to search for an
36
36
  it { should exist }
37
37
  end
38
38
 
39
- # Ensure you have a Security Group with a specific name. Names are
39
+ # Ensure you have a Security Group with a specific name. Names are
40
40
  # unique within a VPC but not across VPCs.
41
41
  # Using only Group returns an error if multiple SGs match.
42
42
  describe aws_security_group(group_name: 'my-group') do
43
43
  it { should exist }
44
44
  end
45
- # Add vpc_id to ensure uniqueness.
45
+ # Add vpc_id to ensure uniqueness.
46
46
  describe aws_security_group(group_name: 'my-group', vpc_id: 'vpc-12345678') do
47
47
  it { should exist }
48
48
  end
@@ -53,15 +53,15 @@ An `aws_security_group` resource block uses resource parameters to search for an
53
53
 
54
54
  The following examples show how to use this InSpec audit resource.
55
55
 
56
- # Ensure that the linux_servers Security Group permits
56
+ # Ensure that the linux_servers Security Group permits
57
57
  # SSH from the 10.5.0.0/16 range, but not the world.
58
58
  describe aws_security_group(group_name: linux_servers) do
59
- # This passes if any inbound rule exists that specifies
59
+ # This passes if any inbound rule exists that specifies
60
60
  # port 22 and the given IP range, regardless of protocol, etc.
61
61
  it { should allow_in(port: 22, ipv4_range: '10.5.0.0/16') }
62
62
 
63
63
  # This passes so long as no inbound rule that specifies port 22 exists
64
- # with a source IP range of 0.0.0.0/0. Other properties are ignored.
64
+ # with a source IP range of 0.0.0.0/0. Other properties are ignored.
65
65
  it { should_not allow_in(port: 22, ipv4_range: '0.0.0.0/0') }
66
66
 
67
67
  end
@@ -69,13 +69,13 @@ The following examples show how to use this InSpec audit resource.
69
69
  # Ensure that the careful_updates Security Group may only initiate contact with specific IPs.
70
70
  describe aws_security_group(group_name: 'careful_updates') do
71
71
 
72
- # If you have two rules, with one CIDR each:
72
+ # If you have two rules, with one CIDR each:
73
73
  [ '10.7.23.12/32', '10.8.23.12/32' ].each do |allowed_destination|
74
74
  # This doesn't care about which ports are enabled
75
75
  it { should allow_out(ipv4_range: allowed_destination) }
76
76
  end
77
77
 
78
- # If you have one rule with two CIDRs:
78
+ # If you have one rule with two CIDRs:
79
79
  it { should allow_out(ipv4_range: [ '10.7.23.12/32', '10.8.23.12/32' ] }
80
80
 
81
81
  # Expect exactly three rules.
@@ -185,7 +185,7 @@ If the Security Group could not be found (that is, `exists` is false), `inbound_
185
185
 
186
186
  A list of the rules that the Security Group applies to outgoing network traffic initiated by the AWS resource in the Security Group. This is a low-level property that is used by the [`allow_out`](#allow_out) matcher; see it for detailed examples. `outbound_rules` is provided here for those wishing to use Ruby code to inspect the rules directly, instead of using higher-level matchers.
187
187
 
188
- Order is critical in these rules, as the sequentially first rule to match is applied to network traffic. Outbound rules are typically used when it is desirable to restrict which portions of the internet, if any, a resource may access. By default, AWS includes an allow-all rule as the last outbound rule; note that Terraform removes this implicit rule.
188
+ Order is critical in these rules, as the sequentially first rule to match is applied to network traffic. Outbound rules are typically used when it is desirable to restrict which portions of the internet, if any, a resource may access. By default, AWS includes an allow-all rule as the last outbound rule; note that Terraform removes this implicit rule.
189
189
 
190
190
  If the Security Group could not be found (that is, `exists` is false), `outbound_rules` returns an empty list.
191
191
 
@@ -218,9 +218,9 @@ This InSpec audit resource has the following special matchers. For a full list o
218
218
 
219
219
  ### allow\_out\_only
220
220
 
221
- The `allow` series of matchers enable you to perform queries about what network traffic would be permitted through the Security Group rule set.
221
+ The `allow` series of matchers enable you to perform queries about what network traffic would be permitted through the Security Group rule set.
222
222
 
223
- `allow_in` and `allow_in_exactly` examine inbound rules, and `allow_out` and `allow_out_exactly` examine outbound rules.
223
+ `allow_in` and `allow_in_exactly` examine inbound rules, and `allow_out` and `allow_out_exactly` examine outbound rules.
224
224
 
225
225
  `allow_in` and `allow_out` examine if at least one rule that matches the criteria exists. `allow_in` and `allow_out` also perform inexact (ie, range-based or subset-based) matching on ports and IP addresses ranges, allowing you to specify a candidate port or IP address and determine if it is covered by a rule.
226
226
 
@@ -229,12 +229,12 @@ The `allow` series of matchers enable you to perform queries about what network
229
229
  The matchers accept a key-value list of search criteria. For a rule to match, it must match all provided criteria.
230
230
 
231
231
  * from_port - Determines if a rule exists whose port range begins at the specified number. The word 'from_' does *not* relate to inbound/outbound directionality; it relates to the port range ("counting _from_"). `from_port` is an exact criterion; so if the rule allows 1000-2000 and you specify a `from_port` of 1001, it does not match.
232
- * ipv4_range - Specifies an IPv4 address or subnet as a CIDR, or a list of them, to be checked as a permissible origin (for `allow_in`) or destination (for `allow_out`) for traffic. Each AWS Security Group rule may have multiple allowed source IP ranges.
232
+ * ipv4_range - Specifies an IPv4 address or subnet as a CIDR, or a list of them, to be checked as a permissible origin (for `allow_in`) or destination (for `allow_out`) for traffic. Each AWS Security Group rule may have multiple allowed source IP ranges.
233
233
  * port - Determines if a particular TCP/IP port is reachable. allow_in and allow_out examine whether the specified port is included in the port range of a rule, while allow_in. You may specify the port as a string (`'22'`) or as a number.
234
234
  * position - A one-based index into the list of rules. If provided, this restricts the evaluation to the rule at that position. You may also use the special values `:first` and `:last`. `position` may also be used to enable `allow_in_only` and `allow_out_only` to work with multi-rule Security Groups.
235
235
  * protocol - Specifies the IP protocol. 'tcp', 'udp', and 'icmp' are some typical values. The string "-1" or 'any' is used to indicate any protocol.
236
236
  * to_port - Determines if a rule exists whose port range ends at the specified number. The word 'to_' does *not* relate to inbound/outbound directionality; it relates to the port range ("counting _to_"). `to_port` is an exact criterion; so if the rule allows 1000-2000 and you specify a `to_port` of 1999, it does not match.
237
-
237
+
238
238
  describe aws_security_group(group_name: 'mixed-functionality-group') do
239
239
  # Allow RDP from defined range
240
240
  it { should allow_in(port: 3389, ipv4_range: '10.5.0.0/16') }
@@ -258,23 +258,23 @@ The matchers accept a key-value list of search criteria. For a rule to match, i
258
258
  it { should_not allow_in(ipv4_range: '0.0.0.0/0') }
259
259
  end
260
260
 
261
- # Suppose you have a Group that should allow SSH and RDP from
262
- # the admin network, 10.5.0.0/16. The resource has 2 rules to
261
+ # Suppose you have a Group that should allow SSH and RDP from
262
+ # the admin network, 10.5.0.0/16. The resource has 2 rules to
263
263
  # allow this, and you want to ensure no others have been added.
264
264
  describe aws_security_group(group_name: 'admin-group') do
265
265
  # Allow RDP from a defined range and nothing else
266
266
  # The SG must have this rule in position 1 and it must match this exactly
267
267
  it { should allow_in_only(port: 3389, ipv4_range: '10.5.0.0/16', position: 1) }
268
268
 
269
- # Specify position 2 for the SSH rule. Without `position`,
269
+ # Specify position 2 for the SSH rule. Without `position`,
270
270
  # allow_in_only only allows one rule, total.
271
271
  it { should allow_in_only(port: 22, ipv4_range: '10.5.0.0/16', position: 2) }
272
272
 
273
- # Because this is an _only matcher, this fails - _only matchers
273
+ # Because this is an _only matcher, this fails - _only matchers
274
274
  # use exact IP matching.
275
275
  it { should allow_in_only(port: 3389, ipv4_range: '10.5.1.34/32', position: 1) }
276
276
  end
277
-
277
+
278
278
  ### exists
279
279
 
280
280
  The control passes if the specified Security Group was found. Use `should_not` if you want to verify that the specified SG does not exist.
@@ -288,3 +288,9 @@ The control passes if the specified Security Group was found. Use `should_not`
288
288
  describe aws_security_group(group_name: 'nogood')
289
289
  it { should_not exist }
290
290
  end
291
+
292
+ ## AWS Permissions
293
+
294
+ Your [Principal](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) will need the `ec2:DescribeSecurityGroups` action with Effect set to Allow.
295
+
296
+ You can find detailed documentation at [Actions, Resources, and Condition Keys for Amazon EC2](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_amazonec2.html).