inspec 1.31.0 → 1.45.9

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 (194) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +2599 -1
  4. data/Gemfile +0 -1
  5. data/README.md +24 -34
  6. data/Rakefile +0 -31
  7. data/docs/dsl_inspec.md +10 -0
  8. data/docs/matchers.md +29 -0
  9. data/docs/plugin_kitchen_inspec.md +18 -24
  10. data/docs/profiles.md +101 -81
  11. data/docs/resources/aide_conf.md.erb +71 -0
  12. data/docs/resources/apache_conf.md.erb +19 -33
  13. data/docs/resources/apt.md.erb +22 -36
  14. data/docs/resources/audit_policy.md.erb +9 -24
  15. data/docs/resources/auditd.md.erb +78 -0
  16. data/docs/resources/auditd_conf.md.erb +20 -34
  17. data/docs/resources/auditd_rules.md.erb +8 -24
  18. data/docs/resources/bash.md.erb +4 -26
  19. data/docs/resources/bond.md.erb +25 -40
  20. data/docs/resources/bridge.md.erb +5 -25
  21. data/docs/resources/bsd_service.md.erb +5 -25
  22. data/docs/resources/command.md.erb +35 -50
  23. data/docs/resources/cpan.md.erb +62 -0
  24. data/docs/resources/cran.md.erb +54 -0
  25. data/docs/resources/crontab.md.erb +9 -23
  26. data/docs/resources/csv.md.erb +12 -27
  27. data/docs/resources/dh_params.md +1 -0
  28. data/docs/resources/directory.md.erb +5 -25
  29. data/docs/resources/docker.md.erb +61 -58
  30. data/docs/resources/docker_container.md.erb +23 -19
  31. data/docs/resources/docker_image.md.erb +20 -16
  32. data/docs/resources/elasticsearch.md.erb +245 -0
  33. data/docs/resources/etc_fstab.md.erb +120 -0
  34. data/docs/resources/etc_group.md.erb +29 -45
  35. data/docs/resources/etc_hosts.md.erb +68 -0
  36. data/docs/resources/etc_hosts_allow.md.erb +68 -0
  37. data/docs/resources/etc_hosts_deny.md.erb +68 -0
  38. data/docs/resources/file.md.erb +227 -216
  39. data/docs/resources/firewalld.md.erb +104 -0
  40. data/docs/resources/gem.md.erb +21 -35
  41. data/docs/resources/group.md.erb +16 -30
  42. data/docs/resources/grub_conf.md.erb +9 -24
  43. data/docs/resources/host.md.erb +32 -49
  44. data/docs/resources/http.md.erb +38 -44
  45. data/docs/resources/iis_app.md.erb +25 -35
  46. data/docs/resources/iis_site.md.erb +26 -40
  47. data/docs/resources/inetd_conf.md.erb +27 -42
  48. data/docs/resources/ini.md.erb +9 -23
  49. data/docs/resources/interface.md.erb +5 -25
  50. data/docs/resources/iptables.md.erb +15 -29
  51. data/docs/resources/json.md.erb +12 -27
  52. data/docs/resources/kernel_module.md.erb +47 -61
  53. data/docs/resources/kernel_parameter.md.erb +15 -29
  54. data/docs/resources/key_rsa.md.erb +3 -0
  55. data/docs/resources/launchd_service.md.erb +5 -25
  56. data/docs/resources/limits_conf.md.erb +15 -29
  57. data/docs/resources/login_def.md.erb +15 -30
  58. data/docs/resources/mount.md.erb +18 -33
  59. data/docs/resources/mssql_session.md.erb +9 -12
  60. data/docs/resources/mysql_conf.md.erb +28 -32
  61. data/docs/resources/mysql_session.md.erb +15 -29
  62. data/docs/resources/nginx.md.erb +78 -0
  63. data/docs/resources/nginx_conf.md.erb +127 -0
  64. data/docs/resources/npm.md.erb +19 -35
  65. data/docs/resources/ntp_conf.md.erb +20 -37
  66. data/docs/resources/oneget.md.erb +15 -30
  67. data/docs/resources/oracledb_session.md.erb +9 -11
  68. data/docs/resources/os.md.erb +29 -43
  69. data/docs/resources/os_env.md.erb +23 -44
  70. data/docs/resources/package.md.erb +34 -36
  71. data/docs/resources/parse_config.md.erb +5 -25
  72. data/docs/resources/parse_config_file.md.erb +31 -43
  73. data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +24 -39
  74. data/docs/resources/pip.md.erb +20 -35
  75. data/docs/resources/port.md.erb +43 -57
  76. data/docs/resources/postgres_conf.md.erb +17 -31
  77. data/docs/resources/postgres_hba_conf.md.erb +26 -38
  78. data/docs/resources/postgres_ident_conf.md.erb +25 -37
  79. data/docs/resources/postgres_session.md.erb +15 -29
  80. data/docs/resources/powershell.md.erb +27 -42
  81. data/docs/resources/processes.md.erb +17 -33
  82. data/docs/resources/rabbitmq_config.md.erb +9 -24
  83. data/docs/resources/registry_key.md.erb +27 -42
  84. data/docs/resources/runit_service.md.erb +5 -25
  85. data/docs/resources/security_policy.md.erb +12 -27
  86. data/docs/resources/service.md.erb +27 -42
  87. data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +41 -47
  88. data/docs/resources/ssh_config.md.erb +19 -34
  89. data/docs/resources/sshd_config.md.erb +19 -34
  90. data/docs/resources/ssl.md.erb +39 -54
  91. data/docs/resources/sys_info.md.erb +12 -26
  92. data/docs/resources/systemd_service.md.erb +5 -25
  93. data/docs/resources/sysv_service.md.erb +5 -25
  94. data/docs/resources/upstart_service.md.erb +5 -25
  95. data/docs/resources/user.md.erb +29 -44
  96. data/docs/resources/users.md.erb +12 -26
  97. data/docs/resources/vbscript.md.erb +9 -24
  98. data/docs/resources/virtualization.md.erb +8 -23
  99. data/docs/resources/windows_feature.md.erb +15 -30
  100. data/docs/resources/windows_hotfix.md.erb +50 -0
  101. data/docs/resources/windows_task.md.erb +12 -26
  102. data/docs/resources/wmi.md.erb +9 -24
  103. data/docs/resources/x509_certificate.md.erb +4 -0
  104. data/docs/resources/xinetd_conf.md.erb +65 -80
  105. data/docs/resources/xml.md.erb +61 -0
  106. data/docs/resources/yaml.md.erb +12 -27
  107. data/docs/resources/yum.md.erb +37 -51
  108. data/docs/resources/zfs_dataset.md.erb +15 -26
  109. data/docs/resources/zfs_pool.md.erb +9 -20
  110. data/docs/ruby_usage.md +0 -1
  111. data/examples/meta-profile/README.md +1 -1
  112. data/examples/profile-sensitive/README.md +29 -0
  113. data/examples/profile-sensitive/controls/sensitive-failures.rb +9 -0
  114. data/examples/profile-sensitive/controls/sensitive.rb +9 -0
  115. data/examples/profile-sensitive/inspec.yml +8 -0
  116. data/inspec.gemspec +3 -3
  117. data/lib/bundles/inspec-artifact/cli.rb +5 -5
  118. data/lib/bundles/inspec-compliance/README.md +24 -22
  119. data/lib/bundles/inspec-compliance/api/login.rb +152 -0
  120. data/lib/bundles/inspec-compliance/api.rb +46 -16
  121. data/lib/bundles/inspec-compliance/cli.rb +58 -165
  122. data/lib/bundles/inspec-compliance/target.rb +2 -3
  123. data/lib/bundles/inspec-habitat/cli.rb +7 -2
  124. data/lib/bundles/inspec-habitat/profile.rb +44 -20
  125. data/lib/bundles/inspec-init/templates/profile/README.md +1 -1
  126. data/lib/bundles/inspec-init/templates/profile/controls/example.rb +1 -1
  127. data/lib/bundles/inspec-supermarket/api.rb +1 -1
  128. data/lib/inspec/backend.rb +8 -0
  129. data/lib/inspec/cli.rb +1 -1
  130. data/lib/inspec/control_eval_context.rb +16 -6
  131. data/lib/inspec/dependencies/requirement.rb +22 -8
  132. data/lib/inspec/dependencies/resolver.rb +1 -1
  133. data/lib/inspec/exceptions.rb +4 -0
  134. data/lib/inspec/file_provider.rb +38 -9
  135. data/lib/inspec/metadata.rb +17 -3
  136. data/lib/inspec/objects/attribute.rb +16 -7
  137. data/lib/inspec/objects/control.rb +10 -2
  138. data/lib/inspec/plugins/resource.rb +34 -5
  139. data/lib/inspec/profile.rb +10 -1
  140. data/lib/inspec/profile_context.rb +3 -1
  141. data/lib/inspec/resource.rb +17 -5
  142. data/lib/inspec/rspec_json_formatter.rb +48 -14
  143. data/lib/inspec/rule.rb +4 -0
  144. data/lib/inspec/runner.rb +72 -30
  145. data/lib/inspec/shell.rb +24 -19
  146. data/lib/inspec/version.rb +1 -1
  147. data/lib/matchers/matchers.rb +40 -0
  148. data/lib/resources/aide_conf.rb +162 -0
  149. data/lib/resources/auditd.rb +231 -0
  150. data/lib/resources/auditd_rules.rb +3 -1
  151. data/lib/resources/command.rb +1 -1
  152. data/lib/resources/cpan.rb +60 -0
  153. data/lib/resources/cran.rb +66 -0
  154. data/lib/resources/docker.rb +8 -1
  155. data/lib/resources/docker_container.rb +19 -2
  156. data/lib/resources/elasticsearch.rb +172 -0
  157. data/lib/resources/etc_fstab.rb +102 -0
  158. data/lib/resources/etc_group.rb +1 -1
  159. data/lib/resources/etc_hosts.rb +81 -0
  160. data/lib/resources/etc_hosts_allow_deny.rb +122 -0
  161. data/lib/resources/file.rb +87 -10
  162. data/lib/resources/firewalld.rb +144 -0
  163. data/lib/resources/groups.rb +0 -1
  164. data/lib/resources/host.rb +30 -15
  165. data/lib/resources/http.rb +178 -22
  166. data/lib/resources/mssql_session.rb +3 -3
  167. data/lib/resources/mysql_conf.rb +10 -0
  168. data/lib/resources/mysql_session.rb +1 -1
  169. data/lib/resources/nginx.rb +97 -0
  170. data/lib/resources/nginx_conf.rb +134 -1
  171. data/lib/resources/oracledb_session.rb +9 -8
  172. data/lib/resources/os_env.rb +7 -4
  173. data/lib/resources/package.rb +14 -2
  174. data/lib/resources/packages.rb +1 -1
  175. data/lib/resources/pip.rb +28 -20
  176. data/lib/resources/port.rb +251 -3
  177. data/lib/resources/postgres.rb +1 -1
  178. data/lib/resources/postgres_session.rb +1 -1
  179. data/lib/resources/processes.rb +106 -20
  180. data/lib/resources/registry_key.rb +11 -2
  181. data/lib/resources/service.rb +5 -24
  182. data/lib/resources/ssh_conf.rb +1 -1
  183. data/lib/resources/ssl.rb +4 -3
  184. data/lib/resources/toml.rb +2 -2
  185. data/lib/resources/windows_hotfix.rb +35 -0
  186. data/lib/resources/xinetd.rb +4 -6
  187. data/lib/resources/xml.rb +27 -0
  188. data/lib/source_readers/inspec.rb +3 -3
  189. data/lib/utils/find_files.rb +2 -1
  190. data/lib/utils/nginx_parser.rb +10 -1
  191. data/lib/utils/object_traversal.rb +35 -10
  192. data/lib/utils/parser.rb +21 -3
  193. metadata +48 -18
  194. data/docs/cli.md +0 -392
@@ -6,6 +6,8 @@ title: About the registry_key Resource
6
6
 
7
7
  Use the `registry_key` InSpec audit resource to test key values in the Windows registry.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `registry_key` resource block declares the item in the Windows registry, the path to a setting under that item, and then one (or more) name/value pairs to be tested.
@@ -61,13 +63,34 @@ Please make sure that you use backslashes instead of forward slashes. Forward sl
61
63
  its('Release') { should eq 378675 }
62
64
  end
63
65
 
64
- ## Matchers
66
+ <br>
67
+
68
+ ## Examples
69
+
70
+ The following examples show how to use this InSpec audit resource.
71
+
72
+ ### Test the start time for the Schedule service
65
73
 
66
- This InSpec audit resource has the following matchers:
74
+ describe registry_key('Task Scheduler','HKEY_LOCAL_MACHINE\...\Schedule') do
75
+ its('Start') { should eq 2 }
76
+ end
67
77
 
68
- ### be
78
+ where `'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule'` is the full path to the setting.
69
79
 
70
- <%= partial "/shared/matcher_be" %>
80
+ ### Use a regular expression in responses
81
+
82
+ describe registry_key({
83
+ hive: 'HKEY_LOCAL_MACHINE',
84
+ key: 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
85
+ }) do
86
+ its('ProductName') { should match /^[a-zA-Z0-9\(\)\s]*2012\s[rR]2[a-zA-Z0-9\(\)\s]*$/ }
87
+ end
88
+
89
+ <br>
90
+
91
+ ## Matchers
92
+
93
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
71
94
 
72
95
  ### children
73
96
 
@@ -93,14 +116,6 @@ The following example shows how find a property that may exist against multiple
93
116
  end
94
117
  }
95
118
 
96
- ### cmp
97
-
98
- <%= partial "/shared/matcher_cmp" %>
99
-
100
- ### eq
101
-
102
- <%= partial "/shared/matcher_eq" %>
103
-
104
119
  ### exist
105
120
 
106
121
  The `exist` matcher tests if the registry key is present:
@@ -125,14 +140,6 @@ The `have_value` matcher tests if a value exists for a registry key:
125
140
 
126
141
  it { should have_value 'value' }
127
142
 
128
- ### include
129
-
130
- <%= partial "/shared/matcher_include" %>
131
-
132
- ### match
133
-
134
- <%= partial "/shared/matcher_match" %>
135
-
136
143
  ### name
137
144
 
138
145
  The `name` matcher tests the value for the specified registry setting:
@@ -148,25 +155,3 @@ Any name with a dot will not work as expected: <code>its('explorer.exe') { shoul
148
155
  # its('explorer.exe') { should eq 'test' }
149
156
  # use the following solution:
150
157
  it { should have_property_value('explorer.exe', :string, 'test') }
151
-
152
-
153
- ## Examples
154
-
155
- The following examples show how to use this InSpec audit resource.
156
-
157
- ### Test the start time for the Schedule service
158
-
159
- describe registry_key('Task Scheduler','HKEY_LOCAL_MACHINE\...\Schedule') do
160
- its('Start') { should eq 2 }
161
- end
162
-
163
- where `'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule'` is the full path to the setting.
164
-
165
- ### Use a regular expression in responses
166
-
167
- describe registry_key({
168
- hive: 'HKEY_LOCAL_MACHINE',
169
- key: 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
170
- }) do
171
- its('ProductName') { should match /^[a-zA-Z0-9\(\)\s]*2012\s[rR]2[a-zA-Z0-9\(\)\s]*$/ }
172
- end
@@ -6,6 +6,8 @@ title: About the runit_service Resource
6
6
 
7
7
  Use the `runit_service` InSpec audit resource to test a service using runit.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `runit_service` resource block declares the name of a service and then one (or more) matchers to test the state of the service:
@@ -29,13 +31,11 @@ The path to the service manager's control may be specified for situations where
29
31
  it { should be_running }
30
32
  end
31
33
 
32
- ## Matchers
33
-
34
- This InSpec audit resource has the following matchers:
34
+ <br>
35
35
 
36
- ### be
36
+ ## Matchers
37
37
 
38
- <%= partial "/shared/matcher_be" %>
38
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
39
39
 
40
40
  ### be_enabled
41
41
 
@@ -54,23 +54,3 @@ The `be_installed` matcher tests if the named service is installed:
54
54
  The `be_running` matcher tests if the named service is running:
55
55
 
56
56
  it { should be_running }
57
-
58
- ### cmp
59
-
60
- <%= partial "/shared/matcher_cmp" %>
61
-
62
- ### eq
63
-
64
- <%= partial "/shared/matcher_eq" %>
65
-
66
- ### include
67
-
68
- <%= partial "/shared/matcher_include" %>
69
-
70
- ### match
71
-
72
- <%= partial "/shared/matcher_match" %>
73
-
74
- ## Examples
75
-
76
- None.
@@ -6,6 +6,8 @@ title: About the security_policy Resource
6
6
 
7
7
  Use the `security_policy` InSpec audit resource to test security policies on the Windows platform.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `security_policy` resource block declares the name of a security policy and the value to be tested:
@@ -19,43 +21,26 @@ where
19
21
  * `'policy_name'` must specify a security policy
20
22
  * `{ should eq 'value' }` tests the value of `policy_name` against the value declared in the test
21
23
 
24
+ <br>
22
25
 
23
- ## Matchers
24
-
25
- This InSpec audit resource has the following matchers:
26
-
27
- ### be
28
-
29
- <%= partial "/shared/matcher_be" %>
30
-
31
- ### cmp
32
-
33
- <%= partial "/shared/matcher_cmp" %>
26
+ ## Examples
34
27
 
35
- ### eq
28
+ The following examples show how to use this InSpec audit resource.
36
29
 
37
- <%= partial "/shared/matcher_eq" %>
30
+ ### Verify that only the Administrators group has remote access
38
31
 
39
- ### include
32
+ describe security_policy do
33
+ its('SeRemoteInteractiveLogonRight') { should eq '*S-1-5-32-544' }
34
+ end
40
35
 
41
- <%= partial "/shared/matcher_include" %>
36
+ <br>
42
37
 
43
- ### match
38
+ ## Matchers
44
39
 
45
- <%= partial "/shared/matcher_match" %>
40
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
46
41
 
47
42
  ### policy_name
48
43
 
49
44
  The `policy_name` matcher must be the name of a security policy:
50
45
 
51
46
  its('SeNetworkLogonRight') { should eq '*S-1-5-11' }
52
-
53
- ## Examples
54
-
55
- The following examples show how to use this InSpec audit resource.
56
-
57
- ### Verify that only the Administrators group has remote access
58
-
59
- describe security_policy do
60
- its('SeRemoteInteractiveLogonRight') { should eq '*S-1-5-32-544' }
61
- end
@@ -8,6 +8,8 @@ Use the `service` InSpec audit resource to test if the named service is installe
8
8
 
9
9
  Under some circumstances, it may be necessary to specify the service manager by using one of the following service manager-specific resources: `bsd_service`, `launchd_service`, `runit_service`, `systemd_service`, `sysv_service`, or `upstart_service`. These resources are based on the `service` resource.
10
10
 
11
+ <br>
12
+
11
13
  ## Syntax
12
14
 
13
15
  A `service` resource block declares the name of a service and then one (or more) matchers to test the state of the service:
@@ -23,48 +25,7 @@ where
23
25
  * `('service_name')` must specify a service name
24
26
  * `be_installed`, `be_enabled`, and `be_running` are valid matchers for this resource
25
27
 
26
-
27
- ## Matchers
28
-
29
- This InSpec audit resource has the following matchers:
30
-
31
- ### be
32
-
33
- <%= partial "/shared/matcher_be" %>
34
-
35
- ### be_enabled
36
-
37
- The `be_enabled` matcher tests if the named service is enabled:
38
-
39
- it { should be_enabled }
40
-
41
- ### be_installed
42
-
43
- The `be_installed` matcher tests if the named service is installed:
44
-
45
- it { should be_installed }
46
-
47
- ### be_running
48
-
49
- The `be_running` matcher tests if the named service is running:
50
-
51
- it { should be_running }
52
-
53
- ### cmp
54
-
55
- <%= partial "/shared/matcher_cmp" %>
56
-
57
- ### eq
58
-
59
- <%= partial "/shared/matcher_eq" %>
60
-
61
- ### include
62
-
63
- <%= partial "/shared/matcher_include" %>
64
-
65
- ### match
66
-
67
- <%= partial "/shared/matcher_match" %>
28
+ <br>
68
29
 
69
30
  ## Examples
70
31
 
@@ -133,3 +94,27 @@ This is also possible with `systemd_service`, `runit_service`, `sysv_service`, `
133
94
  it { should be_installed }
134
95
  it { should be_running }
135
96
  end
97
+
98
+ <br>
99
+
100
+ ## Matchers
101
+
102
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
103
+
104
+ ### be_enabled
105
+
106
+ The `be_enabled` matcher tests if the named service is enabled:
107
+
108
+ it { should be_enabled }
109
+
110
+ ### be_installed
111
+
112
+ The `be_installed` matcher tests if the named service is installed:
113
+
114
+ it { should be_installed }
115
+
116
+ ### be_running
117
+
118
+ The `be_running` matcher tests if the named service is running:
119
+
120
+ it { should be_running }
@@ -19,6 +19,8 @@ These entries are defined as a colon-delimited row in the file, one row per user
19
19
 
20
20
  dannos:Gb7crrO5CDF.:10063:0:99999:7:::
21
21
 
22
+ <br>
23
+
22
24
  ## Syntax
23
25
 
24
26
  A `shadow` resource block declares one (or more) users and associated user information to be tested:
@@ -27,30 +29,56 @@ A `shadow` resource block declares one (or more) users and associated user infor
27
29
  its('users') { should_not include 'forbidden_user' }
28
30
  end
29
31
 
32
+ or with a single query:
33
+
34
+ describe shadow.users('root') do
35
+ its('count') { should eq 1 }
36
+ end
37
+
30
38
  or with a filter:
31
39
 
32
- describe shadow.uid(filter) do
33
- its('users') { should cmp 'root' }
40
+ describe shadow.filter(min_days: '0', max_days: '99999') do
34
41
  its('count') { should eq 1 }
35
42
  end
36
43
 
37
- where
44
+ The following properties are available:
38
45
 
39
- * `homes`, `gids`, `passwords`, `shells`, `uids`, and `users` are valid accessors for `passwd`
40
- * `filter` one (or more) arguments, for example: `passwd.users(/name/)` used to define filtering; `filter` may take any of the following arguments: `count` (retrieves the number of entries), `lines` (provides raw `passwd` lines), and `params` (returns an array of maps for all entries)
46
+ * `users`
47
+ * `passwords`
48
+ * `last_changes`
49
+ * `min_days`
50
+ * `max_days`
51
+ * `warn_days`
52
+ * `inactive_days`
53
+ * `expiry_date`
54
+ * `reserved`
41
55
 
56
+ Properties can be used as a single query or can be joined together with the `.filter` method.
42
57
 
43
- ## Matchers
58
+ <br>
44
59
 
45
- This InSpec audit resource has the following matchers:
60
+ ## Examples
46
61
 
47
- ### be
62
+ The following examples show how to use this InSpec audit resource.
48
63
 
49
- <%= partial "/shared/matcher_be" %>
64
+ ### Test for a forbidden user
50
65
 
51
- ### cmp
66
+ describe shadow do
67
+ its('users') { should_not include 'forbidden_user' }
68
+ end
52
69
 
53
- <%= partial "/shared/matcher_cmp" %>
70
+ ### Test that a user appears one time
71
+
72
+ describe shadow.users('bin') do
73
+ its('passwords') { should cmp 'x' }
74
+ its('count') { should eq 1 }
75
+ end
76
+
77
+ <br>
78
+
79
+ ## Matchers
80
+
81
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
54
82
 
55
83
  ### count
56
84
 
@@ -58,16 +86,12 @@ The `count` matcher tests the number of times the named user appears in `/etc/sh
58
86
 
59
87
  its('count') { should eq 1 }
60
88
 
61
- TThis matcher is best used in conjunction with filters. For example:
89
+ This matcher is best used in conjunction with filters. For example:
62
90
 
63
91
  describe shadow.users('dannos') do
64
92
  its('count') { should eq 1 }
65
93
  end
66
94
 
67
- ### eq
68
-
69
- <%= partial "/shared/matcher_eq" %>
70
-
71
95
  ### expiry_dates
72
96
 
73
97
  The `expiry_dates` matcher tests the number of days a user account has been disabled:
@@ -80,20 +104,12 @@ The `inactive_days` matcher tests the number of days a user must be inactive bef
80
104
 
81
105
  its('inactive_days') { should eq '' }
82
106
 
83
- ### include
84
-
85
- <%= partial "/shared/matcher_include" %>
86
-
87
107
  ### last_changes
88
108
 
89
109
  The `last_changes` matcher tests the last time a password was changed:
90
110
 
91
111
  its('last_changes') { should eq '' }
92
112
 
93
- ### match
94
-
95
- <%= partial "/shared/matcher_match" %>
96
-
97
113
  ### max_days
98
114
 
99
115
  The `max_days` matcher tests the maximum number of days after which a password must be changed:
@@ -108,15 +124,10 @@ The `min_days` matcher tests the minimum number of days a password must exist, b
108
124
 
109
125
  ### passwords
110
126
 
111
- The `passwords` matcher tests if passwords are
112
-
113
- * Encrypted
114
- * Have direct logins disabled, as indicated by an asterisk (`*`)
115
- * In the `/etc/shadow` file, as indicated by the letter x (`x`)
127
+ The `passwords` matcher returns the encrypted password string from the shadow file. The returned string may not be an encrypted password, but rather a `*` or similar which indicates that direct logins are not allowed.
116
128
 
117
129
  For example:
118
130
 
119
- its('passwords') { should eq ['x'] }
120
131
  its('passwords') { should cmp '*' }
121
132
 
122
133
  ### users
@@ -130,20 +141,3 @@ The `users` matcher tests if the user name exists `/etc/shadow`:
130
141
  The `warn_days` matcher tests the number of days a user is warned about an expiring password:
131
142
 
132
143
  its('warn_days') { should eq 7 }
133
-
134
- ## Examples
135
-
136
- The following examples show how to use this InSpec audit resource.
137
-
138
- ### Test for a forbidden user
139
-
140
- describe shadow do
141
- its('users') { should_not include 'forbidden_user' }
142
- end
143
-
144
- ### Test that a user appears one time
145
-
146
- describe shadow.users('bin') do
147
- its('passwords') { should cmp 'x' }
148
- its('count') { should eq 1 }
149
- end
@@ -6,6 +6,8 @@ title: About the ssh_config Resource
6
6
 
7
7
  Use the `ssh_config` InSpec audit resource to test OpenSSH client configuration data located at `/etc/ssh/ssh_config` on Linux and Unix platforms.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `ssh_config` resource block declares the client OpenSSH configuration data to be tested:
@@ -20,40 +22,7 @@ where
20
22
  * `('path')` is the non-default `/path/to/ssh_config`
21
23
  * `{ should include('foo') }` tests the value of `name` as read from `ssh_config` versus the value declared in the test
22
24
 
23
-
24
- ## Matchers
25
-
26
- This InSpec audit resource has the following matchers:
27
-
28
- ### be
29
-
30
- <%= partial "/shared/matcher_be" %>
31
-
32
- ### cmp
33
-
34
- <%= partial "/shared/matcher_cmp" %>
35
-
36
- ### eq
37
-
38
- <%= partial "/shared/matcher_eq" %>
39
-
40
- ### include
41
-
42
- <%= partial "/shared/matcher_include" %>
43
-
44
- ### match
45
-
46
- <%= partial "/shared/matcher_match" %>
47
-
48
- ### name
49
-
50
- The `name` matcher tests the value of `name` as read from `ssh_config` versus the value declared in the test:
51
-
52
- its('name') { should eq 'foo' }
53
-
54
- or:
55
-
56
- its('name') { should include('bar') }
25
+ <br>
57
26
 
58
27
  ## Examples
59
28
 
@@ -92,3 +61,19 @@ The following examples show how to use this InSpec audit resource.
92
61
  its('SendEnv') { should eq 'LANG LC_*' }
93
62
  its('HashKnownHosts') { should eq 'yes' }
94
63
  end
64
+
65
+ <br>
66
+
67
+ ## Matchers
68
+
69
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
70
+
71
+ ### name
72
+
73
+ The `name` matcher tests the value of `name` as read from `ssh_config` versus the value declared in the test:
74
+
75
+ its('name') { should eq 'foo' }
76
+
77
+ or:
78
+
79
+ its('name') { should include('bar') }
@@ -6,6 +6,8 @@ title: About the sshd_config Resource
6
6
 
7
7
  Use the `sshd_config` InSpec audit resource to test configuration data for the OpenSSH daemon located at `/etc/ssh/sshd_config` on Linux and Unix platforms. sshd---the OpenSSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command execution, and data exchanges.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `sshd_config` resource block declares the client OpenSSH configuration data to be tested:
@@ -20,40 +22,7 @@ where
20
22
  * `('path')` is the non-default `/path/to/sshd_config`
21
23
  * `{ should include('foo') }` tests the value of `name` as read from `sshd_config` versus the value declared in the test
22
24
 
23
-
24
- ## Matchers
25
-
26
- This InSpec audit resource has the following matchers:
27
-
28
- ### be
29
-
30
- <%= partial "/shared/matcher_be" %>
31
-
32
- ### cmp
33
-
34
- <%= partial "/shared/matcher_cmp" %>
35
-
36
- ### eq
37
-
38
- <%= partial "/shared/matcher_eq" %>
39
-
40
- ### include
41
-
42
- <%= partial "/shared/matcher_include" %>
43
-
44
- ### match
45
-
46
- <%= partial "/shared/matcher_match" %>
47
-
48
- ### name
49
-
50
- The `name` matcher tests the value of `name` as read from `sshd_config` versus the value declared in the test:
51
-
52
- its('name') { should cmp 'foo' }
53
-
54
- or:
55
-
56
- its('name') {should include('bar') }
25
+ <br>
57
26
 
58
27
  ## Examples
59
28
 
@@ -95,3 +64,19 @@ The following examples show how to use this InSpec audit resource.
95
64
  '/etc/ssh/ssh_host_ecdsa_key',
96
65
  ] }
97
66
  end
67
+
68
+ <br>
69
+
70
+ ## Matchers
71
+
72
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
73
+
74
+ ### name
75
+
76
+ The `name` matcher tests the value of `name` as read from `sshd_config` versus the value declared in the test:
77
+
78
+ its('name') { should cmp 'foo' }
79
+
80
+ or:
81
+
82
+ its('name') {should include('bar') }
@@ -6,6 +6,8 @@ title: About the ssl Resource
6
6
 
7
7
  Use the `ssl` InSpec audit resource to test SSL settings for the named port.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `ssl` resource block declares an SSL port, and then other properties of the test like cipher and/or protocol:
@@ -25,60 +27,7 @@ where
25
27
  * `ssl(port: #)` is the port number, such as `ssl(port: 443)`
26
28
  * `filter` may take any of the following arguments: `ciphers`, `protocols`, and `handshake`
27
29
 
28
-
29
- ## Matchers
30
-
31
- This InSpec audit resource has the following matchers:
32
-
33
- ### be
34
-
35
- <%= partial "/shared/matcher_be" %>
36
-
37
- ### be_enabled
38
-
39
- The `be_enabled` matcher tests if SSL is enabled:
40
-
41
- it { should be_enabled }
42
-
43
- ### ciphers
44
-
45
- The `ciphers` matcher tests the named cipher:
46
-
47
- its('ciphers') { should_not eq '/rc4/i' }
48
-
49
- or:
50
-
51
- describe ssl(port: 443).ciphers(/rc4/i) do
52
- it { should_not be_enabled }
53
- end
54
-
55
- ### cmp
56
-
57
- <%= partial "/shared/matcher_cmp" %>
58
-
59
- ### eq
60
-
61
- <%= partial "/shared/matcher_eq" %>
62
-
63
- ### include
64
-
65
- <%= partial "/shared/matcher_include" %>
66
-
67
- ### match
68
-
69
- <%= partial "/shared/matcher_match" %>
70
-
71
- ### protocols
72
-
73
- The `protocols` matcher tests what protocol versions (SSLv3, TLSv1.1, etc) are enabled:
74
-
75
- its('protocols') { should eq 'ssl2' }
76
-
77
- or:
78
-
79
- describe ssl(port: 443).protocols('ssl2') do
80
- it { should_not be_enabled }
81
- end
30
+ <br>
82
31
 
83
32
  ## Examples
84
33
 
@@ -131,3 +80,39 @@ and then run:
131
80
  Or execute the profile directly via URL:
132
81
 
133
82
  $ inspec exec https://github.com/dev-sec/ssl-benchmark
83
+
84
+ <br>
85
+
86
+ ## Matchers
87
+
88
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
89
+
90
+ ### be_enabled
91
+
92
+ The `be_enabled` matcher tests if SSL is enabled:
93
+
94
+ it { should be_enabled }
95
+
96
+ ### ciphers
97
+
98
+ The `ciphers` matcher tests the named cipher:
99
+
100
+ its('ciphers') { should_not eq '/rc4/i' }
101
+
102
+ or:
103
+
104
+ describe ssl(port: 443).ciphers(/rc4/i) do
105
+ it { should_not be_enabled }
106
+ end
107
+
108
+ ### protocols
109
+
110
+ The `protocols` matcher tests what protocol versions (SSLv3, TLSv1.1, etc) are enabled:
111
+
112
+ its('protocols') { should eq 'ssl2' }
113
+
114
+ or:
115
+
116
+ describe ssl(port: 443).protocols('ssl2') do
117
+ it { should_not be_enabled }
118
+ end