inspec 2.1.43 → 2.1.54

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20615575585069d827d93b1bda43540f5cb7b0fc
4
- data.tar.gz: ba4ce3f0d578f97e2aee6304326bc81f40cc50f7
3
+ metadata.gz: 70091b75b95f9e09f83249bc3ed5de294da9989c
4
+ data.tar.gz: c481fe8cdd37aae2eecc2ce18481924d0f9dcead
5
5
  SHA512:
6
- metadata.gz: e55df70b1b8dd5bc9f86029354cbf3c179237a5a777dd73e60351286900ba13e97d9d2a60a5446928e2b1296563696e951cd2fca7c050a8c855a4e91950726f3
7
- data.tar.gz: f98ba1d732e28565113d7bc5eb91440736abc4c847954a0663cf9313773039cbef11814ad4d7b087cfd1a06fa094e33c67b832128dee504533a67abde8803017
6
+ metadata.gz: 43840caed0f0399d671b5514940f7c9dc2c73cdac09820609e9bd132cc0b7c30d4985690c8674638473aea52b5644a658eafb2feac4a399e3182078d4edd4693
7
+ data.tar.gz: 3d1e4c52daf5a58b8ea2b1f0705e7fb375a1579d4b279cc774058e015c6dfe9efea650ba2400e6ee8ec0aa78427975e13abac78ace6c8885fc35567572a462d9
@@ -1,36 +1,58 @@
1
1
  # Change Log
2
2
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
3
- <!-- latest_release 2.1.43 -->
4
- ## [v2.1.43](https://github.com/chef/inspec/tree/v2.1.43) (2018-04-12)
3
+ <!-- latest_release 2.1.54 -->
4
+ ## [v2.1.54](https://github.com/chef/inspec/tree/v2.1.54) (2018-04-19)
5
5
 
6
- #### Merged Pull Requests
7
- - powershell resource: Add support line for Unix [#2952](https://github.com/chef/inspec/pull/2952) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
6
+ #### Bug Fixes
7
+ - Add missing `git` to Dockerfile. [#2969](https://github.com/chef/inspec/pull/2969) ([miah](https://github.com/miah))
8
8
  <!-- latest_release -->
9
9
 
10
- <!-- release_rollup since=2.1.30 -->
11
- ### Changes since 2.1.30 release
12
-
13
- #### Enhancements
14
- - Add Cisco IOS `enable_password` support [#2905](https://github.com/chef/inspec/pull/2905) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 2.1.42 -->
15
- - Require a key attribute for the key_rsa resource [#2891](https://github.com/chef/inspec/pull/2891) ([omar-irizarry](https://github.com/omar-irizarry)) <!-- 2.1.41 -->
16
- - Ensure @params in shadow resource always has a valid value. [#2939](https://github.com/chef/inspec/pull/2939) ([miah](https://github.com/miah)) <!-- 2.1.39 -->
17
- - Add warning when returning DEFAULT_ATTRIBUTE [#2934](https://github.com/chef/inspec/pull/2934) ([TrevorBramble](https://github.com/TrevorBramble)) <!-- 2.1.35 -->
10
+ <!-- release_rollup since=2.1.43 -->
11
+ ### Changes since 2.1.43 release
18
12
 
19
13
  #### Merged Pull Requests
20
- - powershell resource: Add support line for Unix [#2952](https://github.com/chef/inspec/pull/2952) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 2.1.43 -->
21
- - Fixes configuration for Azure integrationt tests [#2941](https://github.com/chef/inspec/pull/2941) ([dmccown](https://github.com/dmccown)) <!-- 2.1.36 -->
22
- - Update filesystem.md.erb [#2909](https://github.com/chef/inspec/pull/2909) ([tlmikulski](https://github.com/tlmikulski)) <!-- 2.1.34 -->
14
+ - Add A2 support to the inspec-compliance toolset [#2963](https://github.com/chef/inspec/pull/2963) ([jquick](https://github.com/jquick)) <!-- 2.1.52 -->
23
15
 
24
16
  #### New Features
25
- - Basic fields for aws_vpcs [#2930](https://github.com/chef/inspec/pull/2930) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.40 -->
26
- - Policy Statement Search capability for aws_iam_policy [#2918](https://github.com/chef/inspec/pull/2918) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.38 -->
27
- - New attribute JUnit reporter - target [#2839](https://github.com/chef/inspec/pull/2839) ([piotrgo](https://github.com/piotrgo)) <!-- 2.1.37 -->
28
- - AWS Security Group Rules properties and matchers [#2876](https://github.com/chef/inspec/pull/2876) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.33 -->
29
- - aws_cloudtrail_trail feature: test how many days ago logs were delivered [#2887](https://github.com/chef/inspec/pull/2887) ([dromazmj](https://github.com/dromazmj)) <!-- 2.1.32 -->
30
- - aws_iam_group feature: test users in an iam group [#2888](https://github.com/chef/inspec/pull/2888) ([dromazmj](https://github.com/dromazmj)) <!-- 2.1.31 -->
17
+ - Inline and attached policies for aws_iam_user and aws_iam_users [#2947](https://github.com/chef/inspec/pull/2947) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.48 -->
18
+
19
+ #### Bug Fixes
20
+ - Add missing `git` to Dockerfile. [#2969](https://github.com/chef/inspec/pull/2969) ([miah](https://github.com/miah)) <!-- 2.1.54 -->
21
+ - updating kitchen-puppet example for the `puppet_apply` provisioner [#2972](https://github.com/chef/inspec/pull/2972) ([moutons](https://github.com/moutons)) <!-- 2.1.49 -->
22
+ - Policy statement search: don&#39;t stacktrace on missing field [#2962](https://github.com/chef/inspec/pull/2962) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.47 -->
23
+ - Fixed numerous naming errors in aws_iam_vpcs integration tests [#2961](https://github.com/chef/inspec/pull/2961) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.46 -->
24
+ - aws_iam_policy statement search fix for degenerate policies [#2958](https://github.com/chef/inspec/pull/2958) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.45 -->
25
+
26
+ #### Enhancements
27
+ - Make names for AWS Config service objects optional [#2928](https://github.com/chef/inspec/pull/2928) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.53 -->
28
+ - Upgrade Terraform version pins for integration testing [#2968](https://github.com/chef/inspec/pull/2968) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 2.1.51 -->
29
+ - Amazon linux service mgmt detection [#2970](https://github.com/chef/inspec/pull/2970) ([meringu](https://github.com/meringu)) <!-- 2.1.50 -->
30
+ - updating output for aws_iam_role to match other AWS resources [#2960](https://github.com/chef/inspec/pull/2960) ([tmonk42](https://github.com/tmonk42)) <!-- 2.1.44 -->
31
31
  <!-- release_rollup -->
32
32
 
33
33
  <!-- latest_stable_release -->
34
+ ## [v2.1.43](https://github.com/chef/inspec/tree/v2.1.43) (2018-04-12)
35
+
36
+ #### New Features
37
+ - aws_iam_group feature: test users in an iam group [#2888](https://github.com/chef/inspec/pull/2888) ([dromazmj](https://github.com/dromazmj))
38
+ - aws_cloudtrail_trail feature: test how many days ago logs were delivered [#2887](https://github.com/chef/inspec/pull/2887) ([dromazmj](https://github.com/dromazmj))
39
+ - AWS Security Group Rules properties and matchers [#2876](https://github.com/chef/inspec/pull/2876) ([clintoncwolfe](https://github.com/clintoncwolfe))
40
+ - New attribute JUnit reporter - target [#2839](https://github.com/chef/inspec/pull/2839) ([piotrgo](https://github.com/piotrgo))
41
+ - Policy Statement Search capability for aws_iam_policy [#2918](https://github.com/chef/inspec/pull/2918) ([clintoncwolfe](https://github.com/clintoncwolfe))
42
+ - Basic fields for aws_vpcs [#2930](https://github.com/chef/inspec/pull/2930) ([clintoncwolfe](https://github.com/clintoncwolfe))
43
+
44
+ #### Enhancements
45
+ - Add warning when returning DEFAULT_ATTRIBUTE [#2934](https://github.com/chef/inspec/pull/2934) ([TrevorBramble](https://github.com/TrevorBramble))
46
+ - Ensure @params in shadow resource always has a valid value. [#2939](https://github.com/chef/inspec/pull/2939) ([miah](https://github.com/miah))
47
+ - Require a key attribute for the key_rsa resource [#2891](https://github.com/chef/inspec/pull/2891) ([omar-irizarry](https://github.com/omar-irizarry))
48
+ - Add Cisco IOS `enable_password` support [#2905](https://github.com/chef/inspec/pull/2905) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
49
+
50
+ #### Merged Pull Requests
51
+ - Update filesystem.md.erb [#2909](https://github.com/chef/inspec/pull/2909) ([tlmikulski](https://github.com/tlmikulski))
52
+ - Fixes configuration for Azure integrationt tests [#2941](https://github.com/chef/inspec/pull/2941) ([dmccown](https://github.com/dmccown))
53
+ - powershell resource: Add support line for Unix [#2952](https://github.com/chef/inspec/pull/2952) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
54
+ <!-- latest_stable_release -->
55
+
34
56
  ## [v2.1.30](https://github.com/chef/inspec/tree/v2.1.30) (2018-04-05)
35
57
 
36
58
  #### New Resources
@@ -47,7 +69,6 @@
47
69
  - Added a description to steer people to correct resource [#2908](https://github.com/chef/inspec/pull/2908) ([username-is-already-taken2](https://github.com/username-is-already-taken2))
48
70
  - Update example resource syntax [#2904](https://github.com/chef/inspec/pull/2904) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
49
71
  - Add automate reporter [#2902](https://github.com/chef/inspec/pull/2902) ([jquick](https://github.com/jquick))
50
- <!-- latest_stable_release -->
51
72
 
52
73
  ## [v2.1.21](https://github.com/chef/inspec/tree/v2.1.21) (2018-03-29)
53
74
 
data/Rakefile CHANGED
@@ -105,10 +105,10 @@ namespace :test do
105
105
  abort("You must set the environment variable AWS_REGION") unless ENV['AWS_REGION']
106
106
  puts "----> Checking for required AWS profile..."
107
107
  sh("aws configure get aws_access_key_id --profile inspec-aws-test-#{account} > /dev/null")
108
- sh("cd #{integration_dir}/build/ && terraform init")
108
+ sh("cd #{integration_dir}/build/ && terraform init -upgrade")
109
109
  sh("cd #{integration_dir}/build/ && terraform workspace new #{tf_workspace}")
110
- sh("cd #{integration_dir}/build/ && AWS_PROFILE=inspec-aws-test-#{account} terraform plan")
111
- sh("cd #{integration_dir}/build/ && AWS_PROFILE=inspec-aws-test-#{account} terraform apply")
110
+ sh("cd #{integration_dir}/build/ && AWS_PROFILE=inspec-aws-test-#{account} terraform plan -out inspec-aws-#{account}.plan")
111
+ sh("cd #{integration_dir}/build/ && AWS_PROFILE=inspec-aws-test-#{account} terraform apply -auto-approve inspec-aws-#{account}.plan")
112
112
  Rake::Task["test:aws:dump_attrs:#{account}"].execute
113
113
  end
114
114
 
@@ -158,7 +158,7 @@ namespace :test do
158
158
  tf_workspace = args[:tf_workspace] || ENV['INSPEC_TERRAFORM_ENV']
159
159
  abort("You must either call the top-level test:azure task, or set the INSPEC_TERRAFORM_ENV variable.") unless tf_workspace
160
160
  puts '----> Setup'
161
- sh("cd #{integration_dir}/build/ && terraform init")
161
+ sh("cd #{integration_dir}/build/ && terraform init -upgrade")
162
162
  sh("cd #{integration_dir}/build/ && terraform workspace new #{tf_workspace}")
163
163
 
164
164
  # Generate Azure crendentials
@@ -4,16 +4,20 @@ title: About the aws_config_delivery_channel Resource
4
4
 
5
5
  # aws_config_delivery_channel
6
6
 
7
- The AWS Config service can monitor and record changes to your AWS resource configurations. A Delivery Channel can record the changes
7
+ The AWS Config service can monitor and record changes to your AWS resource configurations. A Delivery Channel can record the changes
8
8
  to an S3 Bucket, an SNS or both.
9
9
 
10
10
  Use the `aws_config_delivery_channel` InSpec audit resource to examine how the AWS Config service delivers those change notifications.
11
11
 
12
+ As of April 2018, each AWS region may have only one Delivery Channel.
13
+
12
14
  <br>
13
15
 
14
- ## Syntax
16
+ ## Resource Parameters
17
+
18
+ An `aws_config_delivery_channel` resource block declares the tests for a single AWS Config Delivery Channel.
15
19
 
16
- An `aws_config_delivery_channel` resource block declares the tests for a single AWS Config delivery channel.
20
+ You may specify the Delivery Channel name:
17
21
 
18
22
  describe aws_config_delivery_channel('my_channel') do
19
23
  it { should exist }
@@ -23,29 +27,52 @@ An `aws_config_delivery_channel` resource block declares the tests for a single
23
27
  it { should exist }
24
28
  end
25
29
 
30
+ However, since you may only have one Delivery Channel per region, and InSpec connections are per-region, you may also omit the `channel_name` to obtain the one Delivery Channel (if any) that exists:
31
+
32
+ describe aws_config_delivery_channel do
33
+ it { should exist }
34
+ end
35
+
26
36
  <br>
27
37
 
28
38
  ## Examples
29
39
 
30
40
  The following examples show how to use this InSpec audit resource.
31
41
 
32
- ### Test how frequent the channel writes configuration changes to the s3 bucket.
42
+ ### Test how frequently the channel writes configuration changes to the s3 bucket.
33
43
 
34
44
  describe aws_config_delivery_channel(channel_name: 'my-recorder') do
35
45
  its(delivery_frequency_in_hours) { should be > 3 }
36
46
  end
37
47
 
38
48
  ## Properties
39
-
40
- ### s3_bucket_name
41
49
 
42
- Provides the name of the s3 bucket that the channel sends configuration changes to. This is an optional value since a Delivery Channel can also talk to an SNS.
50
+ ### channel\_name
51
+
52
+ Returns the name of the Delivery Channel.
53
+
54
+ describe aws_config_delivery_channel do
55
+ its('channel_name') { should cmp 'my-channel' }
56
+ end
57
+
58
+ ### delivery\_frequency\_in\_hours
59
+
60
+ Provides how often the AWS Config sends configuration changes to the s3 bucket in the delivery channel.
61
+
62
+ describe aws_config_delivery_channel(channel_name: 'my_channel')
63
+ its('delivery_frequency_in_hours') { should eq 24 }
64
+ its('delivery_frequency_in_hours') { should be > 24 }
65
+ end
66
+
67
+ ### s3\_bucket\_name
68
+
69
+ Provides the name of the s3 bucket that the channel sends configuration changes to. This is an optional value since a Delivery Channel can also talk to an SNS.
43
70
 
44
71
  describe aws_config_delivery_channel(channel_name: 'my_channel')
45
72
  its('s3_bucket_name') { should eq 'my_bucket' }
46
73
  end
47
74
 
48
- ### s3_key_prefix
75
+ ### s3\_key\_prefix
49
76
 
50
77
  Provides the s3 object key prefix (or "path") under which configuration data will be recorded.
51
78
 
@@ -53,7 +80,7 @@ Provides the s3 object key prefix (or "path") under which configuration data wil
53
80
  its('s3_key_prefix') { should eq 'log/' }
54
81
  end
55
82
 
56
- ### sns_topic_arn
83
+ ### sns\_topic\_arn
57
84
 
58
85
  Provides the ARN of the SNS topic for which the channel sends notifications about configuration changes.
59
86
 
@@ -61,19 +88,9 @@ Provides the ARN of the SNS topic for which the channel sends notifications abou
61
88
  its('sns_topic_arn') { should eq 'arn:aws:sns:us-east-1:721741954427:sns_topic' }
62
89
  end
63
90
 
64
- ### delivery_frequency_in_hours
65
-
66
- Provides how often the AWS Config sends configuration changes to the s3 bucket in the delivery channel.
67
-
68
- describe aws_config_delivery_channel(channel_name: 'my_channel')
69
- its('delivery_frequency_in_hours') { should eq 24 }
70
- its('delivery_frequency_in_hours') { should be > 24 }
71
- end
72
-
73
-
74
91
  <br>
75
92
 
76
93
  ## Matchers
77
94
 
78
- This resource provides no matchers, aside from the standard exists matcher.
95
+ This resource provides no matchers, aside from the standard `exist` matcher.
79
96
 
@@ -8,12 +8,16 @@ Use the `aws_config_recorder` InSpec audit resource to test properties of your A
8
8
 
9
9
  The AWS Config service can monitor and record changes to your AWS resource configurations. The Aws Config Recorder is used to detect changes in resource configurations and capture these changes as configuration items.
10
10
 
11
+ As of April 2018, you are only permitted one configuration recorder per region.
12
+
11
13
  <br>
12
14
 
13
- ## Syntax
15
+ ## Resource Parameters
14
16
 
15
17
  An `aws_config_recorder` resource block declares the tests for a single AWS configuration recorder.
16
18
 
19
+ You may specify a recorder by name:
20
+
17
21
  describe aws_config_recorder('my_recorder') do
18
22
  it { should exist }
19
23
  end
@@ -22,6 +26,12 @@ An `aws_config_recorder` resource block declares the tests for a single AWS conf
22
26
  it { should exist }
23
27
  end
24
28
 
29
+ However, since you may only have one recorder per region, and InSpec connections are per-region, you may also omit the `recorder_name` to obtain the one recorder (if any) that exists:
30
+
31
+ describe aws_config_recorder do
32
+ it { should exist }
33
+ end
34
+
25
35
  <br>
26
36
 
27
37
  ## Examples
@@ -13,7 +13,7 @@ To test properties of the special AWS root user (which owns the account), use th
13
13
 
14
14
  <br>
15
15
 
16
- ## Syntax
16
+ ## Resource Parameters
17
17
 
18
18
  An `aws_iam_user` resource block declares a user by name, and then lists tests to be performed.
19
19
 
@@ -47,9 +47,51 @@ The following examples show how to use this InSpec audit resource.
47
47
 
48
48
  <br>
49
49
 
50
+ ## Properties
51
+
52
+ ### attached\_policy\_arns
53
+
54
+ Returns a list of IAM Managed Policy ARNs as strings that identify the policies that are attached to the user. If there are no attached policies, returns an empty list.
55
+
56
+ describe aws_iam_user('bob') do
57
+ # This is a customer-managed policy
58
+ its('attached_policy_arns') { should include 'arn:aws:iam::123456789012:policy/test-inline-policy-01' }
59
+ # This is an AWS-managed policy
60
+ its('attached_policy_arns') { should include 'arn:aws:iam::aws:policy/AlexaForBusinessGatewayExecution' }
61
+ end
62
+
63
+ ### attached\_policy\_names
64
+
65
+ Returns a list of IAM Managed Policy Names as strings that identify the policies that are attached to the user. If there are no attached policies, returns an empty list.
66
+
67
+ describe aws_iam_user('bob') do
68
+ # This is a customer-managed policy
69
+ its('attached_policy_names') { should include 'test-inline-policy-01' }
70
+ # This is an AWS-managed policy
71
+ its('attached_policy_names') { should include 'AlexaForBusinessGatewayExecution' }
72
+ end
73
+
74
+ ### inline\_policy\_names
75
+
76
+ Returns a list of IAM Inline Policy Names as strings that identify the inline policies that are directly embedded in the user. If there are no embedded policies, returns an empty list.
77
+
78
+ describe aws_iam_user('bob') do
79
+ its('inline_policy_names') { should include 'test-inline-policy-01' }
80
+ its('inline_policy_names.count') { should eq 1 }
81
+ end
82
+
83
+
50
84
  ## Matchers
51
85
 
52
- This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
86
+ This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [universal matchers page](https://www.inspec.io/docs/reference/matchers/).
87
+
88
+ ### have\_attached\_policies
89
+
90
+ The `have\_attached\_policies` matcher tests if the user has at least one IAM managed policy attached to the user.
91
+
92
+ describe aws_iam_user('bob') do
93
+ it { should_not have_attached_policies }
94
+ end
53
95
 
54
96
  ### have\_console\_password
55
97
 
@@ -57,8 +99,17 @@ The `have_console_password` matcher tests if the user has a password that could
57
99
 
58
100
  it { should have_console_password }
59
101
 
102
+ ### have\_inline\_policies
103
+
104
+ The `have\_inline\_policies` matcher tests if the user has at least one IAM policy embedded directly in the user record.
105
+
106
+ describe aws_iam_user('bob') do
107
+ it { should_not have_inline_policies }
108
+ end
109
+
60
110
  ### have\_mfa\_enabled
61
111
 
62
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.
63
113
 
64
114
  it { should have_mfa_enabled }
115
+
@@ -15,20 +15,20 @@ To test properties of the special AWS root user (which owns the account), use th
15
15
 
16
16
  ## Syntax
17
17
 
18
- An `aws_iam_users` resource block users a filter to select a group of users and then tests that group
18
+ An `aws_iam_users` resource block uses a filter to select a group of users and then tests that group. With no filter, it returns all AWS IAM users.
19
19
 
20
+ # No filter
21
+ # We expect 42 users
22
+ describe aws_iam_users do
23
+ its('usernames.count') { should eq 42 }
24
+ end
25
+
26
+ # Using a filter
27
+ # All users should have MFA (no user without MFA should exist)
20
28
  describe aws_iam_users.where(has_mfa_enabled?: false) do
21
29
  it { should_not exist }
22
30
  end
23
31
 
24
- <br>
25
-
26
- ## Filter Criteria
27
-
28
- * `has_mfa_enabled`, `has_console_password`, `password_ever_used?`, `password_never_used?`, `password_last_used_days_ago`, `username`
29
-
30
- <br>
31
-
32
32
  ## Examples
33
33
 
34
34
  The following examples show how to use this InSpec audit resource.
@@ -84,7 +84,190 @@ The following examples show how to use this InSpec audit resource.
84
84
 
85
85
  <br>
86
86
 
87
+ ## Filter Criteria
88
+
89
+ You may pass filter criteria to `where` to narrow down the result set.
90
+
91
+ ### has\_attached\_policies
92
+
93
+ True or false. Filters the users to include only those that have at least one IAM managed policy attached to the user.
94
+
95
+ # Don't attach policies to users
96
+ describe aws_iam_users.where(has_attached_policies: true) do
97
+ it { should_not exist }
98
+ end
99
+
100
+ ### has\_console\_password
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).
103
+
104
+ # No console passwords for anyone
105
+ describe aws_iam_users.where(has_console_password: true) do
106
+ it { should_not exist }
107
+ end
108
+
109
+ ### has\_inline\_policies
110
+
111
+ True or false. Filters the users to include only those that have at least one IAM policy directly embedded in the user record.
112
+
113
+ # Embedding policies is usually hard to manage
114
+ describe aws_iam_users.where(has_inline_policies: true) do
115
+ it { should_not exist }
116
+ end
117
+
118
+ ### has\_mfa\_enabled
119
+
120
+ True or false. Filters the users to include only those that have some kind of Mult-Factor Authentication enabled (virtual or hardware).
121
+
122
+ # Require MFA for everyone
123
+ describe aws_iam_users.where(has_mfa_enabled: false) do
124
+ it { should_not exist }
125
+ end
126
+
127
+ ### password\_ever\_used
128
+
129
+ True or false. Filters the users to include only those that have used their password at least once.
130
+
131
+ # Someone should have used their password
132
+ describe aws_iam_users.where(password_ever_used: true) do
133
+ it { should exist }
134
+ end
135
+
136
+ ### password\_last\_used_days\_ago
137
+
138
+ Integer. Filters the users to include only those who used their password a certain number of days ago. '0' means today.
139
+
140
+ # Bob should login every day
141
+ describe aws_iam_users.where(password_ever_used: true, password_last_used_days_ago:0) do
142
+ its('usernames') { should include 'bob' }
143
+ end
144
+
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
148
+ password_ever_used && password_last_used_days_ago > 30
149
+ end do
150
+ it { should_not exist' }
151
+ end
152
+
153
+ ### password\_never\_used
154
+
155
+ True or false. Filters the users to include only those that have used _never_ their password.
156
+
157
+ # No zombie accounts!
158
+ describe aws_iam_users.where(password_never_used: true) do
159
+ it { should_not exist }
160
+ end
161
+
162
+ ### username
163
+
164
+ String. Filters the users to include only those whose username matches the value you provide.
165
+
166
+ # Block mode example (recommended)
167
+ # Service users should not have a password
168
+ describe aws_iam_users.where { username.start_with?('service') } do
169
+ it { should_not have_console_password }
170
+ end
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
174
+ # aws_iam_user (singular)
175
+ # Verify Bob exists
176
+ describe aws_iam_users.where(username: 'bob') do
177
+ it { should exist }
178
+ end
179
+
180
+ ## Properties
181
+
182
+ Properties are used with the `its` test to obtain information about the matched users. Properties always return arrays, though they may be empty.
183
+
184
+ ### attached\_policy\_arns
185
+
186
+ Array of strings. Each entry is the ARN of an IAM managed policy that is attached to at least one matched user. The list is de-duplicated, so if you have five users that are all attached to the same policy, `attached_policy_arns` will return only one ARN, not five.
187
+
188
+ # Service users should be attached to a custom service policy
189
+ describe aws_iam_users.where { username.start_with?('service') } do
190
+ its('attached_policy_arns') { should include 'arn:aws:iam::123456789012:policy/MyServicePolicy' }
191
+ end
192
+
193
+ ### attached\_policy\_names
194
+
195
+ Array of strings. Each entry is the friendly name of an IAM managed policy that is attached to at least one matched user. The list is de-duplicated, so if you have five users that are all attached to the same policy, `attached_policy_names` will return only one name, not five.
196
+
197
+ # Service users should be attached to a custom service policy
198
+ # and not include Admin policy!
199
+ describe aws_iam_users.where { username.start_with?('service') } do
200
+ its('attached_policy_names') { should include 'MyServicePolicy' }
201
+ its('attached_policy_names') { should_not include 'AdministratorAccess' }
202
+ end
203
+
204
+ ### inline\_policy\_names
205
+
206
+ Array of strings. Each entry is the name of an embedded policy that is embedded in at least one matched user. Keep in mind that each user has a copy of a policy (which can then be modified). This means that two users can have an embedded policy with the same name, but very different contents. The list is de-duplicated, so if you have five users that have an inline policy with the same name, `inline_policy_names` will return only one name, not five.
207
+
208
+ # Service users should have a bespoke policy
209
+ describe aws_iam_users.where { username.start_with?('service') } do
210
+ its('inline_policy_names') { should include 'some-bespoke-policy' }
211
+ end
212
+
213
+ ### usernames
214
+
215
+ Array of strings. Each entry is the name of a user that matched. There will be exactly as many usernames here as there were users that matched, though it is possible to have non-unique usernames.
216
+
217
+ # 42 Users, including Bob, should have a password.
218
+ describe aws_iam_users.where(has_console_password: true) do
219
+ its('usernames') { should include 'bob' }
220
+ its('usernames.count') { should eq 42 }
221
+ end
222
+
87
223
  ## Matchers
88
224
 
89
- This InSpec audit resource has no specific matchers.
90
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
225
+ This InSpec audit resource has the following resource-specific matchers.
226
+ For a full list of available matchers, please visit our [universal matchers page](https://www.inspec.io/docs/reference/matchers/).
227
+
228
+ As a plural resource, all matchers beginning with `have_` will return true if _any_ of the selected users match.
229
+
230
+ ### exist
231
+
232
+ The test passes if the filtered user set is not empty. This basic matcher is frequently used with `should_not` to detect undesired conditions.
233
+
234
+ # Require MFA for everyone
235
+ describe aws_iam_users.where(has_mfa_enabled: false) do
236
+ it { should_not exist }
237
+ end
238
+
239
+ ### have\_attached\_policies
240
+
241
+ The test passes if at least one user in the filtered set has at least one attached IAM managed policy.
242
+
243
+ # Bachelors don't have attachments
244
+ describe aws_iam_users.where { username =~ /bachelor/ } do
245
+ it { should_not have_attached_policies }
246
+ end
247
+
248
+ ### have\_console\_password
249
+
250
+ The test passes if at least one user in the filtered set has a console password.
251
+
252
+ describe aws_iam_users do
253
+ it { should_not have_console_password }
254
+ end
255
+
256
+ ### have\_inline\_policies
257
+
258
+ The test passes if at least one user in the filtered set has at least one embedded policy.
259
+
260
+ # No one should have an inline policy
261
+ describe aws_iam_users do
262
+ it { should_not have_inline_policies }
263
+ end
264
+
265
+ ### have\_mfa\_enabled
266
+
267
+ The test passes if at least one user in the filtered set has MFA enabled (virtual or hardware).
268
+
269
+ # At least one person should use MFA.
270
+ # This does not mean ALL users have MFA.
271
+ describe aws_iam_users do
272
+ it { should have_mfa_enabled }
273
+ end