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
@@ -0,0 +1,245 @@
1
+ ---
2
+ title: The Elasticsearch Resource
3
+ ---
4
+
5
+ # elasticsearch
6
+
7
+ The `elasticsearch` resource allows testing of a node status against a running
8
+ Elasticsearch cluster. InSpec will retrieve the node list from the cluster node URL
9
+ provided (defaults to `http://localhost:9200`) and provide the ability to query
10
+ a variety of settings and statuses.
11
+
12
+ ## Syntax
13
+
14
+ describe elasticsearch do
15
+ its('property') { should cmp 'value' }
16
+ end
17
+
18
+ The `elasticsearch` resource accepts a number of optional values:
19
+
20
+ * `url`: the top-level URL of an Elasticsearch node in the cluster. If your Elasticsearch installation is not served out of the top-level directory at the host, be sure to specific the full URL; for example: `http://my-load-balancer/elasticsearch`. Default: `http://localhost:9200`
21
+ * `username`: a username to use to log in with HTTP-Basic authentication. If `username` is provided, a `password` must also be provided.
22
+ * `password`: a password to use to log in with HTTP-Basic authentication. If `password` is provided, a `username` must also be provided.
23
+ * `ssl_verify`: if `false`, SSL certificate validation will be disabled. Default: `true`
24
+
25
+ In addition, the `elasticsearch` resource allows for filtering the nodes returned by property before executing the tests:
26
+
27
+ describe elasticsearch.where { node_name == 'one-off-node' } do
28
+ its('version') { should eq '1.2.3' }
29
+ end
30
+
31
+ describe elasticsearch.where { process.mlockall == false } do
32
+ its('count') { should cmp 0 }
33
+ end
34
+
35
+ To simply check if nodes exist that match the criteria, use the `exist` matcher:
36
+
37
+ describe elasticsearch.where { cluster_name == 'my_cluster' } do
38
+ it { should exist }
39
+ end
40
+
41
+ ## Supported Properties
42
+
43
+ The following properties are provided:
44
+
45
+ * build_hash
46
+ * cluster_name
47
+ * host
48
+ * http
49
+ * ingest
50
+ * ip
51
+ * jvm
52
+ * module_list
53
+ * modules
54
+ * node_name
55
+ * node_id
56
+ * os
57
+ * plugin_list
58
+ * plugins
59
+ * process
60
+ * roles
61
+ * settings
62
+ * total_indexing_buffer
63
+ * transport
64
+ * transport_address
65
+ * version
66
+
67
+ Since the `elasticsearch` resource is meant for use on a cluster, each property will return an array of the values for each node that matches any provided search criteria. Using InSpec's `cmp` matcher will help avoid any issues when trying to compare values for when a single match is returned (i.e. when the cluster only contains a single node, or the `where` filter criteria provided only returns a single node).
68
+
69
+ ## Property Examples
70
+
71
+ ### build_hash
72
+
73
+ Returns the build hash for each of the nodes.
74
+
75
+ describe elasticsearch do
76
+ its('build_hash') { should cmp 'b2f0c09' }
77
+ end
78
+
79
+ ### cluster_name
80
+
81
+ Returns the cluster names of each of the nodes.
82
+
83
+ describe elasticsearch do
84
+ its('cluster_name') { should cmp 'my_cluster' }
85
+ end
86
+
87
+ ### host
88
+
89
+ Returns the hostname of each of the nodes. This may return an IP address of the node is not properly performing DNS resolution or has no hostname set.
90
+
91
+ describe elasticsearch do
92
+ its('host') { should cmp 'my.hostname.mycompany.biz' }
93
+ end
94
+
95
+ ### http
96
+
97
+ Returns a hash of HTTP-related settings for each of the nodes. In this example, the `first` method is used to grab only the first node's HTTP-related info and is a way of removing the item from the Array if only one node is being queried.
98
+
99
+ describe elasticsearch do
100
+ its('http.first.max_content_length_in_bytes') { should cmp 123456 }
101
+ end
102
+
103
+ ### ingest
104
+
105
+ Returns ingest-related settings and capabilities, such as available processors.
106
+
107
+ describe elasticsearch do
108
+ its('ingest.first.processors.count') { should be >= 1 }
109
+ end
110
+
111
+ ### ip
112
+
113
+ Returns the IP address of each of the nodes.
114
+
115
+ describe elasticsearch do
116
+ its('ip') { should cmp '192.168.1.100' }
117
+ end
118
+
119
+ ### jvm
120
+
121
+ Returns Java Virtual Machine related parameters for each of the nodes.
122
+
123
+ describe elasticsearch do
124
+ its('jvm.first.version') { should cmp '1.8.0_141' }
125
+ end
126
+
127
+ ### module_list
128
+
129
+ Returns a list of enabled modules for each node in the cluster. For more additional information about each module, use the `modules` property.
130
+
131
+ describe elasticsearch do
132
+ its('module_list.first') { should include 'my_module' }
133
+ end
134
+
135
+ ### modules
136
+
137
+ Returns detailed information about each enabled module for each node in the cluster. For a succint list of the names of each of the modules enabled, use the `module_list` property. This example uses a bit of additional Ruby to find a specific module and assert a value.
138
+
139
+ modules = elasticsearch.modules.first
140
+ lang_groovy_module = modules.find { |mod| mod.name == 'lang-groovy' }
141
+
142
+ describe 'lang-groovy module version' do
143
+ subject { lang_groovy_module }
144
+ its('version') { should cmp '5.5.2' }
145
+ end
146
+
147
+ ### node_name
148
+
149
+ Returns the node name for each node in the cluster.
150
+
151
+ describe elasticsearch do
152
+ its('node_name') { should cmp 'node1' }
153
+ end
154
+
155
+ ### node_id
156
+
157
+ Returns the node IDs of each of the nodes in the cluster.
158
+
159
+ describe elasticsearch do
160
+ its('node_id') { should include 'my_node_id' }
161
+ end
162
+
163
+ ### os
164
+
165
+ Returns OS-related information about each node in the cluster.
166
+
167
+ describe elasticsearch do
168
+ its('os.first.arch') { should cmp 'amd64' }
169
+ end
170
+
171
+ ### plugin_list
172
+
173
+ Returns a list of enabled plugins for each node in the cluster. For more additional information about each plugin, use the `plugins` property.
174
+
175
+ describe elasticsearch do
176
+ its('plugin_list.first') { should include 'my_plugin' }
177
+ end
178
+
179
+ ### plugins
180
+
181
+ Returns detailed information about each enabled plugin for each node in the cluster. For a succint list of the names of each of the plugins enabled, use the `plugin_list` property. This example uses a bit of additional Ruby to find a specific plugin and assert a value.
182
+
183
+ plugins = elasticsearch.plugins.first
184
+ my_plugin = plugins.find { |plugin| plugin.name == 'my_plugin' }
185
+
186
+ describe 'my_plugin plugin version' do
187
+ subject { my_plugin }
188
+ its('version') { should cmp '1.2.3' }
189
+ end
190
+
191
+ ### process
192
+
193
+ Returns process information for each node in the cluster, such as the process ID.
194
+
195
+ describe elasticsearch do
196
+ its('process.first.mlockall') { should cmp true }
197
+ end
198
+
199
+ ### roles
200
+
201
+ Returns the role for each of the nodes in the cluster.
202
+
203
+ describe elasticsearch.where { node_name == 'my_master_node' } do
204
+ it { should include 'master' }
205
+ end
206
+
207
+ ### settings
208
+
209
+ Returns all the configuration settings for each node in the cluster. These settings usually include those set in the elasticsearch.yml as well as those set via `-Des.` or `-E` flags at startup. Use the `inspec shell` to explore the various setting keys that are available.
210
+
211
+ describe elasticsearch do
212
+ its('settings.first.path.home') { should cmp '/usr/share/elasticsearch' }
213
+ end
214
+
215
+ ### total_indexing_buffer
216
+
217
+ Returns the total indexing buffer for each node in the cluster.
218
+
219
+ describe elasticsearch do
220
+ its('total_indexing_buffer') { should cmp 123456 }
221
+ end
222
+
223
+ ### transport
224
+
225
+ Returns transport-related settings for each node in the cluster, such as the bound and published addresses.
226
+
227
+ describe elasticsearch do
228
+ its('transport.first.bound_address') { should cmp '1.2.3.4:9200' }
229
+ end
230
+
231
+ ### transport_address
232
+
233
+ Returns the bound transport address for each node in the cluster.
234
+
235
+ describe elasticsearch do
236
+ its('transport_address') { should cmp '1.2.3.4:9200' }
237
+ end
238
+
239
+ ### version
240
+
241
+ Returns the version of Elasticsearch running on each node of the cluster.
242
+
243
+ describe elasticsearch do
244
+ its('version') { should cmp '5.5.2' }
245
+ end
@@ -0,0 +1,120 @@
1
+ ---
2
+ title: About the etc_fstab Resource
3
+ ---
4
+
5
+ # etc_fstab
6
+
7
+ Use the `etc_fstab` InSpec audit resource to test information about all partitions and storage devices on a system.
8
+
9
+ <br>
10
+
11
+ ## Syntax
12
+
13
+ An etc_fstab rule specifies a device name, its mount point, its mount type, the options its mounted with,
14
+ its dump options, and the order the files system should be checked.
15
+
16
+ Use the where clause to match a property to one or more rules in the fstab file.
17
+
18
+ describe etc_fstab.where { device_name == 'value' } do
19
+ its('mount_point') { should cmp 'hostname' }
20
+ its('file_system_type') { should cmp 'list' }
21
+ its('mount_options') { should cmp 'list' }
22
+ its('dump_options') { should cmp 'list' }
23
+ its('file_system_options') { should cmp 'list' }
24
+ end
25
+
26
+ Use the optional constructor parameter to give an alternative path to fstab file
27
+
28
+ describe etc_fstab(hosts_path).where { device_name == 'value' } do
29
+ its('mount_point') { should cmp 'hostname' }
30
+ its('file_system_type') { should cmp 'list' }
31
+ its('mount_options') { should cmp 'list' }
32
+ its('dump_options') { should cmp 'list' }
33
+ its('file_system_options') { should cmp 'list ' }
34
+ end
35
+
36
+ where
37
+
38
+ * `device_name` is the name associated with the device.
39
+ * `mount_point` is the directory at which the filesystem is configured to be mounted.
40
+ * `file_system_type` is the type of file system of the device or partition.
41
+ * `mount_options` is the options for the device or partition.
42
+ * `dump_options` is a number used by dump to decide if a file system should be backed up.
43
+ * `file_system_options` is a number that specifies the order the file system should be checked.
44
+
45
+ ## Property Examples and Return Types
46
+
47
+ ### device_name
48
+
49
+ `device_name` returns a string array of device names mounted on the system.
50
+
51
+ describe etc_fstab.where { mount_point == '/mnt/sr0' } do
52
+ its('device_name') { should cmp '/dev/sr0' }
53
+ end
54
+
55
+ ### mount_point
56
+
57
+ `mount_point` returns a string array of directorys at which filesystems are configured to be mounted.
58
+
59
+ describe etc_fstab.where { device_name == '/dev/sr0' } do
60
+ its('mount_point') { should cmp '/mnt/sr0' }
61
+ end
62
+
63
+ ### file_system_type
64
+
65
+ `file_system_type` returns a String array of each partitions file system type.
66
+
67
+ describe etc_fstab.where { device_name == '/dev/sr0' } do
68
+ its('file_system_type') { should cmp 'iso9660' }
69
+ end
70
+
71
+ ### mount_options
72
+
73
+ `mount_options` returns a two dimensional array of each partitions mount options.
74
+
75
+ describe etc_fstab.where { mount_point == '/' } do
76
+ its('mount_options') { should eq [['defaults', 'x-systemd.device-timeout=0']] }
77
+ end
78
+
79
+ ### dump_options
80
+
81
+ `dump_options` returns a integer array of each partitions dump option.
82
+
83
+ describe etc_fstab.where { device_name == '/dev/sr0' } do
84
+ its('dump_options') { should cmp 0 }
85
+ end
86
+
87
+ ### file_system_options
88
+
89
+ `file_system_options` returns a integer array of each partitions file system option.
90
+
91
+ describe etc_fstab.where { device_name == '/dev/sr0' } do
92
+ its('file_system_options') { should cmp 0 }
93
+ end
94
+
95
+ <br>
96
+
97
+ ## Examples
98
+
99
+ The following examples show how to use this InSpec resource.
100
+
101
+ ### Check all partitions that have type of 'nfs'.
102
+
103
+ nfs_systems = etc_fstab.nfs_file_systems.entries
104
+ nfs_systems.each do |partition|
105
+ describe partition do
106
+ its('mount_options') { should include 'nosuid' }
107
+ end
108
+ end
109
+
110
+ ### Check the partition mounted at /home contains 'nosuid' in its mount_options.
111
+
112
+ describe etc_fstab do
113
+ its('home_mount_options') { should include 'nosuid' }
114
+ end
115
+
116
+ ### Check if a partition is mounted at a point.
117
+
118
+ describe etc_fstab.where { mount_point == '/home' } do
119
+ it { should be_configured }
120
+ end
@@ -6,6 +6,8 @@ title: About the etc_group Resource
6
6
 
7
7
  Use the `etc_group` InSpec audit resource to test groups that are defined on Linux and Unix platforms. The `/etc/group` file stores details about each group---group name, password, group identifier, along with a comma-separate list of users that belong to the group.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `etc_group` resource block declares a collection of properties to be tested:
@@ -28,21 +30,40 @@ where
28
30
  * `.where()` may specify a specific item and value, to which the matchers are compared
29
31
  * `'gids'`, `'groups'`, and `'users'` are valid matchers for this resource
30
32
 
31
- ## Matchers
32
33
 
33
- This InSpec audit resource has the following matchers:
34
+ ## Examples
35
+
36
+ The following examples show how to use this InSpec audit resource.
37
+
38
+ ### Test group identifiers (GIDs) for duplicates
39
+
40
+ describe etc_group do
41
+ its('gids') { should_not contain_duplicates }
42
+ end
43
+
44
+ ### Test all groups to see if a specific user belongs to one (or more) groups
45
+
46
+ describe etc_group do
47
+ its('groups') { should include 'my_group' }
48
+ end
49
+
50
+ ### Test all groups for a specific user name
34
51
 
35
- ### be
52
+ describe etc_group do
53
+ its('users') { should include 'my_user' }
54
+ end
36
55
 
37
- <%= partial "/shared/matcher_be" %>
56
+ ### Filter a list of groups for a specific user
38
57
 
39
- ### cmp
58
+ describe etc_group.where(name: 'my_group') do
59
+ its('users') { should include 'my_user' }
60
+ end
40
61
 
41
- <%= partial "/shared/matcher_cmp" %>
62
+ <br>
42
63
 
43
- ### eq
64
+ ## Matchers
44
65
 
45
- <%= partial "/shared/matcher_eq" %>
66
+ 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
67
 
47
68
  ### gids
48
69
 
@@ -56,14 +77,6 @@ The `groups` matcher tests all groups for the named user:
56
77
 
57
78
  its('groups') { should include 'my_group' }
58
79
 
59
- ### include
60
-
61
- <%= partial "/shared/matcher_include" %>
62
-
63
- ### match
64
-
65
- <%= partial "/shared/matcher_match" %>
66
-
67
80
  ### users
68
81
 
69
82
  The `users` matcher tests all groups for the named user:
@@ -85,32 +98,3 @@ where `item` may be one (or more) of:
85
98
  * `group_id: 'gid'`
86
99
  * `users: 'user_name'`
87
100
  * `members: 'member_name'`
88
-
89
-
90
- ## Examples
91
-
92
- The following examples show how to use this InSpec audit resource.
93
-
94
- ### Test group identifiers (GIDs) for duplicates
95
-
96
- describe etc_group do
97
- its('gids') { should_not contain_duplicates }
98
- end
99
-
100
- ### Test all groups to see if a specific user belongs to one (or more) groups
101
-
102
- describe etc_group do
103
- its('groups') { should include 'my_group' }
104
- end
105
-
106
- ### Test all groups for a specific user name
107
-
108
- describe etc_group do
109
- its('users') { should include 'my_user' }
110
- end
111
-
112
- ### Filter a list of groups for a specific user
113
-
114
- describe etc_group.where(name: 'my_group') do
115
- its('users') { should include 'my_user' }
116
- end
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: About the etc_hosts Resource
3
+ ---
4
+
5
+ # etc_hosts
6
+
7
+ Use the `etc_hosts` InSpec audit resource to test rules set to match IP addresses with hostnames.
8
+ ## Syntax
9
+
10
+ An etc/hosts rule specifies an IP address and what its hostname is along with optional aliases it can have.
11
+
12
+ <br>
13
+
14
+ ## Syntax
15
+
16
+ Use the where clause to match a property to one or more rules in the hosts file.
17
+
18
+ describe etc_hosts.where { ip_address == 'value' } do
19
+ its('primary_name') { should cmp 'hostname' }
20
+ its('all_host_names') { should cmp 'list' }
21
+ end
22
+
23
+ Use the optional constructor parameter to give an alternative path to hosts file
24
+
25
+ describe etc_hosts('path/to/hosts').where { ip_address == 'value' } do
26
+ its('primary_name') { should cmp 'hostname' }
27
+ its('all_host_names') { should cmp 'list' }
28
+ end
29
+
30
+ where
31
+
32
+ * `ip_address` is the ip address of the hostname in either ipv4 or ipv6 format.
33
+ * `primary_name` is the name associated with the ip address.
34
+ * `all_host_names` is a list including the primary_name as the first entry followed by any aliase names the host has.
35
+
36
+ <br>
37
+
38
+ ## Supported Properties
39
+
40
+ 'ip_address', 'primary_name', 'all_host_names'
41
+
42
+ <br>
43
+
44
+ ## Property Examples and Return Types
45
+
46
+ ### ip_address
47
+
48
+ `ip_address` returns a string array of ip addresses specified in the etc/hosts file.
49
+
50
+ describe etc_hosts.where { primary_name == 'localhost' } do
51
+ its('ip_address') { should cmp '127.0.1.154' }
52
+ end
53
+
54
+ ### primary_name
55
+
56
+ `primary_name` returns a string array of primary_names specified in the etc/hosts file.
57
+
58
+ describe etc_hosts.where { ip_address == '::1' } do
59
+ its('primary_name') { should cmp 'localhost' }
60
+ end
61
+
62
+ ### all_host_names
63
+
64
+ `all_host_names` returns a two dimensional string array where each entry has the primary_name first followed by any aliases.
65
+
66
+ describe etc_hosts.where { ip_address == '127.0.1.154' } do
67
+ its('all_host_names') { should eq [['localhost', 'localhost.localdomain', 'localhost4', 'localhost4.localdomain4'], ['localhost', 'localhost.localdomain', 'localhost6', 'localhost6.localdomain6']] }
68
+ end
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: About the etc_hosts_allow Resource
3
+ ---
4
+
5
+ # etc_hosts_allow
6
+
7
+ Use the `etc_hosts_allow` InSpec audit resource to test rules set to accept daemon and client traffic set in /etc/hosts.allow file.
8
+
9
+ <br>
10
+
11
+ ## Syntax
12
+
13
+ An etc/hosts.allow rule specifies one or more daemons mapped to one or more clients,
14
+ with zero or more options to use to accept traffic when found.
15
+
16
+ Use the where clause to match a property to one or more rules in the hosts.allow file.
17
+
18
+ describe etc_hosts_allow.where { daemon == 'value' } do
19
+ its ('client_list') { should include ['values'] }
20
+ its ('options') { should include ['values'] }
21
+ end
22
+
23
+ Use the optional constructor parameter to give an alternative path to hosts.allow
24
+
25
+ describe etc_hosts_allow(hosts_path).where { daemon == 'value' } do
26
+ its ('client_list') { should include ['values'] }
27
+ its ('options') { should include ['values'] }
28
+ end
29
+
30
+ where
31
+
32
+ * `daemon` is a daemon that will be allowed to pass traffic in.
33
+ * `client_list` is a list of clients will be allowed to pass traffic in.
34
+ * `options` is a list of tasks that to be done with the rule when traffic is found.
35
+
36
+ <br>
37
+
38
+ ## Supported Properties
39
+
40
+ 'daemon', 'client_list', 'options'
41
+
42
+ <br>
43
+
44
+ ## Property Examples and Return Types
45
+
46
+ ### daemon
47
+
48
+ `daemon` returns a string containing the daemon that is allowed in the rule.
49
+
50
+ describe etc_hosts_allow.where { client_list == ['127.0.1.154', '[:fff:fAb0::]'] } do
51
+ its('daemon') { should eq ['vsftpd', 'sshd'] }
52
+ end
53
+
54
+ ### client_list
55
+
56
+ `client_list` returns a 2d string array where each entry contains the clients specified for the rule.
57
+
58
+ describe etc_hosts_allow.where { daemon == 'sshd' } do
59
+ its('client_list') { should include ['192.168.0.0/16', '[abcd::0000:1234]'] }
60
+ end
61
+
62
+ ### options
63
+
64
+ `options` returns a 2d string array where each entry contains any options specified for the rule.
65
+
66
+ describe etc_hosts_allow.where { daemon == 'sshd' } do
67
+ its('options') { should include ['deny', 'echo "REJECTED"'] }
68
+ end
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: About the etc_hosts_deny Resource
3
+ ---
4
+
5
+ # etc_hosts_deny
6
+
7
+ Use the `etc_hosts_deny` InSpec audit resource to test rules set to reject daemon and client traffic set in /etc/hosts.deny.
8
+
9
+ <br>
10
+
11
+ ## Syntax
12
+
13
+ An etc/hosts.deny rule specifies one or more daemons mapped to one or more clients,
14
+ with zero or more options to use to reject traffic when found.
15
+
16
+ Use the where clause to match a property to one or more rules in the hosts.deny file.
17
+
18
+ describe etc_hosts_deny.where { daemon == 'value' } do
19
+ its ('client_list') { should include ['values'] }
20
+ its ('options') { should include ['values'] }
21
+ end
22
+
23
+ Use the optional constructor parameter to give an alternative path to hosts.deny
24
+
25
+ describe etc_hosts_deny(hosts_path).where { daemon == 'value' } do
26
+ its ('client_list') { should include ['values'] }
27
+ its ('options') { should include ['values'] }
28
+ end
29
+
30
+ where
31
+
32
+ * `daemon` is a daemon that will be rejected to pass traffic in.
33
+ * `client_list` is a list of clients will be rejected to pass traffic in.
34
+ * `options` is a list of tasks that to be done with the rule when traffic is found.
35
+
36
+ <br>
37
+
38
+ ## Supported Properties
39
+
40
+ 'daemon', 'client_list', 'options'
41
+
42
+ <br>
43
+
44
+ ## Property Examples and Return Types
45
+
46
+ ### daemon
47
+
48
+ `daemon` returns a string containing the daemon that is allowed in the rule.
49
+
50
+ describe etc_hosts_deny.where { client_list == ['127.0.1.154', '[:fff:fAb0::]'] } do
51
+ its('daemon') { should eq ['vsftpd', 'sshd'] }
52
+ end
53
+
54
+ ### client_list
55
+
56
+ `client_list` returns a 2d string array where each entry contains the clients specified for the rule.
57
+
58
+ describe etc_hosts_deny.where { daemon == 'sshd' } do
59
+ its('client_list') { should include ['192.168.0.0/16', '[abcd::0000:1234]'] }
60
+ end
61
+
62
+ ### options
63
+
64
+ `options` returns a 2d string array where each entry contains any options specified for the rule.
65
+
66
+ describe etc_hosts_deny.where { daemon == 'sshd' } do
67
+ its('options') { should include ['deny', 'echo "REJECTED"'] }
68
+ end