inspec 1.0.0 → 1.35.1

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 (286) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +933 -101
  3. data/Gemfile +8 -17
  4. data/MAINTAINERS.md +2 -1
  5. data/MAINTAINERS.toml +9 -4
  6. data/README.md +49 -28
  7. data/Rakefile +54 -39
  8. data/bin/inspec +1 -1
  9. data/docs/dsl_inspec.md +17 -4
  10. data/docs/dsl_resource.md +1 -1
  11. data/docs/habitat.md +192 -0
  12. data/docs/inspec_and_friends.md +4 -2
  13. data/docs/matchers.md +11 -0
  14. data/docs/migration.md +293 -0
  15. data/docs/profiles.md +124 -76
  16. data/docs/resources/aide_conf.md.erb +81 -0
  17. data/docs/resources/apache_conf.md.erb +10 -10
  18. data/docs/resources/apt.md.erb +13 -13
  19. data/docs/resources/audit_policy.md.erb +10 -10
  20. data/docs/resources/auditd_conf.md.erb +10 -10
  21. data/docs/resources/auditd_rules.md.erb +11 -11
  22. data/docs/resources/bash.md.erb +12 -12
  23. data/docs/resources/bond.md.erb +15 -15
  24. data/docs/resources/bridge.md.erb +11 -11
  25. data/docs/resources/bsd_service.md.erb +11 -11
  26. data/docs/resources/command.md.erb +23 -23
  27. data/docs/resources/crontab.md.erb +84 -0
  28. data/docs/resources/csv.md.erb +10 -10
  29. data/docs/resources/dh_params.md +191 -0
  30. data/docs/resources/directory.md.erb +8 -8
  31. data/docs/resources/docker.md.erb +160 -0
  32. data/docs/resources/docker_container.md.erb +89 -0
  33. data/docs/resources/docker_image.md.erb +86 -0
  34. data/docs/resources/etc_group.md.erb +16 -16
  35. data/docs/resources/etc_hosts.md.erb +62 -0
  36. data/docs/resources/file.md.erb +80 -58
  37. data/docs/resources/gem.md.erb +32 -13
  38. data/docs/resources/group.md.erb +12 -12
  39. data/docs/resources/grub_conf.md.erb +11 -11
  40. data/docs/resources/host.md.erb +27 -18
  41. data/docs/resources/http.md.erb +104 -0
  42. data/docs/resources/iis_app.md.erb +126 -0
  43. data/docs/resources/iis_site.md.erb +17 -17
  44. data/docs/resources/inetd_conf.md.erb +10 -10
  45. data/docs/resources/ini.md.erb +9 -9
  46. data/docs/resources/interface.md.erb +13 -13
  47. data/docs/resources/iptables.md.erb +21 -14
  48. data/docs/resources/json.md.erb +11 -11
  49. data/docs/resources/kernel_module.md.erb +73 -12
  50. data/docs/resources/kernel_parameter.md.erb +12 -12
  51. data/docs/resources/key_rsa.md.erb +70 -0
  52. data/docs/resources/launchd_service.md.erb +11 -11
  53. data/docs/resources/limits_conf.md.erb +10 -10
  54. data/docs/resources/login_def.md.erb +12 -12
  55. data/docs/resources/mount.md.erb +14 -14
  56. data/docs/resources/mssql_session.md.erb +62 -0
  57. data/docs/resources/mysql_conf.md.erb +14 -14
  58. data/docs/resources/mysql_session.md.erb +22 -10
  59. data/docs/resources/npm.md.erb +13 -13
  60. data/docs/resources/ntp_conf.md.erb +9 -9
  61. data/docs/resources/oneget.md.erb +11 -11
  62. data/docs/resources/oracledb_session.md.erb +53 -0
  63. data/docs/resources/os.md.erb +17 -17
  64. data/docs/resources/os_env.md.erb +12 -12
  65. data/docs/resources/package.md.erb +29 -16
  66. data/docs/resources/parse_config.md.erb +18 -18
  67. data/docs/resources/parse_config_file.md.erb +29 -23
  68. data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +17 -17
  69. data/docs/resources/pip.md.erb +15 -15
  70. data/docs/resources/port.md.erb +23 -23
  71. data/docs/resources/postgres_conf.md.erb +15 -13
  72. data/docs/resources/postgres_hba_conf.md.erb +104 -0
  73. data/docs/resources/postgres_ident_conf.md.erb +87 -0
  74. data/docs/resources/postgres_session.md.erb +28 -21
  75. data/docs/resources/powershell.md.erb +14 -14
  76. data/docs/resources/processes.md.erb +123 -0
  77. data/docs/resources/rabbitmq_config.md.erb +55 -0
  78. data/docs/resources/registry_key.md.erb +44 -21
  79. data/docs/resources/runit_service.md.erb +11 -11
  80. data/docs/resources/security_policy.md.erb +10 -10
  81. data/docs/resources/service.md.erb +18 -18
  82. data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +19 -19
  83. data/docs/resources/ssh_config.md.erb +13 -13
  84. data/docs/resources/sshd_config.md.erb +15 -15
  85. data/docs/resources/ssl.md.erb +13 -13
  86. data/docs/resources/sys_info.md.erb +10 -10
  87. data/docs/resources/systemd_service.md.erb +11 -11
  88. data/docs/resources/sysv_service.md.erb +11 -11
  89. data/docs/resources/upstart_service.md.erb +11 -11
  90. data/docs/resources/user.md.erb +20 -20
  91. data/docs/resources/users.md.erb +19 -19
  92. data/docs/resources/vbscript.md.erb +13 -13
  93. data/docs/resources/virtualization.md.erb +71 -0
  94. data/docs/resources/windows_feature.md.erb +10 -10
  95. data/docs/resources/windows_task.md.erb +103 -0
  96. data/docs/resources/wmi.md.erb +10 -10
  97. data/docs/resources/x509_certificate.md.erb +146 -0
  98. data/docs/resources/xinetd_conf.md.erb +17 -17
  99. data/docs/resources/xml.md.erb +75 -0
  100. data/docs/resources/yaml.md.erb +25 -11
  101. data/docs/resources/yum.md.erb +24 -16
  102. data/docs/resources/zfs_dataset.md.erb +63 -0
  103. data/docs/resources/zfs_pool.md.erb +57 -0
  104. data/docs/ruby_usage.md +50 -0
  105. data/docs/shared/matcher_cmp.md.erb +4 -6
  106. data/examples/inheritance/README.md +49 -3
  107. data/examples/inheritance/controls/example.rb +4 -1
  108. data/examples/inheritance/inspec.yml +3 -1
  109. data/examples/meta-profile/README.md +29 -3
  110. data/examples/meta-profile/controls/example.rb +10 -5
  111. data/examples/meta-profile/inspec.yml +4 -8
  112. data/examples/profile/README.md +1 -1
  113. data/examples/profile/controls/example.rb +0 -1
  114. data/examples/profile/controls/gordon.rb +0 -1
  115. data/examples/profile/inspec.yml +1 -1
  116. data/examples/profile-attribute/inspec.yml +1 -1
  117. data/examples/profile-sensitive/README.md +29 -0
  118. data/examples/profile-sensitive/controls/sensitive-failures.rb +9 -0
  119. data/examples/profile-sensitive/controls/sensitive.rb +9 -0
  120. data/examples/profile-sensitive/inspec.yml +8 -0
  121. data/inspec.gemspec +10 -2
  122. data/lib/bundles/inspec-artifact/README.md +1 -0
  123. data/lib/bundles/inspec-artifact/cli.rb +284 -0
  124. data/lib/bundles/inspec-artifact.rb +7 -0
  125. data/lib/bundles/inspec-compliance/README.md +44 -15
  126. data/lib/bundles/inspec-compliance/api.rb +135 -29
  127. data/lib/bundles/inspec-compliance/cli.rb +128 -21
  128. data/lib/bundles/inspec-compliance/configuration.rb +8 -0
  129. data/lib/bundles/inspec-compliance/http.rb +26 -19
  130. data/lib/bundles/inspec-compliance/target.rb +50 -25
  131. data/lib/bundles/inspec-habitat/cli.rb +31 -0
  132. data/lib/bundles/inspec-habitat/log.rb +10 -0
  133. data/lib/bundles/inspec-habitat/profile.rb +372 -0
  134. data/lib/bundles/inspec-habitat.rb +12 -0
  135. data/lib/bundles/inspec-init/templates/profile/controls/example.rb +0 -1
  136. data/lib/bundles/inspec-init/templates/profile/inspec.yml +1 -1
  137. data/lib/bundles/inspec-supermarket/api.rb +7 -5
  138. data/lib/bundles/inspec-supermarket/cli.rb +2 -2
  139. data/lib/fetchers/git.rb +4 -2
  140. data/lib/fetchers/local.rb +4 -1
  141. data/lib/fetchers/url.rb +64 -10
  142. data/lib/inspec/archive/tar.rb +1 -1
  143. data/lib/inspec/backend.rb +26 -3
  144. data/lib/inspec/base_cli.rb +44 -7
  145. data/lib/inspec/cached_fetcher.rb +2 -2
  146. data/lib/inspec/cli.rb +34 -12
  147. data/lib/inspec/completions/fish.sh.erb +34 -0
  148. data/lib/inspec/control_eval_context.rb +0 -2
  149. data/lib/inspec/dependencies/cache.rb +0 -1
  150. data/lib/inspec/dependencies/dependency_set.rb +2 -2
  151. data/lib/inspec/dependencies/lockfile.rb +13 -6
  152. data/lib/inspec/dependencies/requirement.rb +6 -6
  153. data/lib/inspec/dependencies/resolver.rb +4 -4
  154. data/lib/inspec/dsl.rb +3 -5
  155. data/lib/inspec/env_printer.rb +9 -1
  156. data/lib/inspec/exceptions.rb +8 -0
  157. data/lib/inspec/fetcher.rb +1 -1
  158. data/lib/inspec/file_provider.rb +47 -11
  159. data/lib/inspec/library_eval_context.rb +1 -1
  160. data/lib/inspec/metadata.rb +62 -18
  161. data/lib/inspec/method_source.rb +24 -0
  162. data/lib/inspec/objects/attribute.rb +21 -0
  163. data/lib/inspec/objects/control.rb +21 -3
  164. data/lib/inspec/objects/each_loop.rb +2 -1
  165. data/lib/inspec/objects/list.rb +1 -1
  166. data/lib/inspec/objects/or_test.rb +17 -2
  167. data/lib/inspec/objects/tag.rb +27 -0
  168. data/lib/inspec/objects/test.rb +9 -8
  169. data/lib/inspec/objects.rb +1 -0
  170. data/lib/inspec/plugins/fetcher.rb +4 -5
  171. data/lib/inspec/plugins/resource.rb +1 -2
  172. data/lib/inspec/plugins/source_reader.rb +3 -3
  173. data/lib/inspec/plugins.rb +1 -1
  174. data/lib/inspec/polyfill.rb +0 -1
  175. data/lib/inspec/profile.rb +92 -23
  176. data/lib/inspec/profile_context.rb +1 -1
  177. data/lib/inspec/profile_vendor.rb +66 -0
  178. data/lib/inspec/resource.rb +29 -3
  179. data/lib/inspec/rspec_json_formatter.rb +672 -285
  180. data/lib/inspec/rule.rb +12 -16
  181. data/lib/inspec/runner.rb +26 -15
  182. data/lib/inspec/runner_rspec.rb +1 -0
  183. data/lib/inspec/runtime_profile.rb +26 -0
  184. data/lib/inspec/schema.rb +185 -0
  185. data/lib/inspec/secrets/yaml.rb +8 -1
  186. data/lib/inspec/secrets.rb +1 -1
  187. data/lib/inspec/shell.rb +92 -22
  188. data/lib/inspec/source_reader.rb +1 -1
  189. data/lib/inspec/version.rb +1 -1
  190. data/lib/inspec.rb +1 -1
  191. data/lib/matchers/matchers.rb +67 -17
  192. data/lib/resources/aide_conf.rb +162 -0
  193. data/lib/resources/apache.rb +0 -1
  194. data/lib/resources/apache_conf.rb +3 -3
  195. data/lib/resources/apt.rb +2 -1
  196. data/lib/resources/audit_policy.rb +0 -1
  197. data/lib/resources/auditd_conf.rb +1 -2
  198. data/lib/resources/auditd_rules.rb +5 -5
  199. data/lib/resources/bond.rb +1 -1
  200. data/lib/resources/bridge.rb +1 -1
  201. data/lib/resources/command.rb +5 -3
  202. data/lib/resources/crontab.rb +102 -0
  203. data/lib/resources/csv.rb +18 -1
  204. data/lib/resources/dh_params.rb +84 -0
  205. data/lib/resources/directory.rb +7 -3
  206. data/lib/resources/docker.rb +198 -0
  207. data/lib/resources/docker_container.rb +114 -0
  208. data/lib/resources/docker_image.rb +96 -0
  209. data/lib/resources/etc_group.rb +2 -3
  210. data/lib/resources/etc_hosts.rb +81 -0
  211. data/lib/resources/file.rb +88 -30
  212. data/lib/resources/gem.rb +26 -6
  213. data/lib/resources/groups.rb +4 -5
  214. data/lib/resources/grub_conf.rb +3 -4
  215. data/lib/resources/host.rb +175 -35
  216. data/lib/resources/http.rb +73 -0
  217. data/lib/resources/iis_app.rb +103 -0
  218. data/lib/resources/iis_site.rb +23 -0
  219. data/lib/resources/inetd_conf.rb +9 -4
  220. data/lib/resources/interface.rb +4 -3
  221. data/lib/resources/json.rb +37 -14
  222. data/lib/resources/kernel_module.rb +77 -10
  223. data/lib/resources/kernel_parameter.rb +0 -1
  224. data/lib/resources/key_rsa.rb +67 -0
  225. data/lib/resources/limits_conf.rb +3 -4
  226. data/lib/resources/login_def.rb +2 -3
  227. data/lib/resources/mount.rb +34 -4
  228. data/lib/resources/mssql_session.rb +81 -12
  229. data/lib/resources/mysql.rb +0 -1
  230. data/lib/resources/mysql_conf.rb +1 -2
  231. data/lib/resources/mysql_session.rb +18 -7
  232. data/lib/resources/nginx_conf.rb +95 -0
  233. data/lib/resources/ntp_conf.rb +2 -3
  234. data/lib/resources/oracledb_session.rb +138 -0
  235. data/lib/resources/os_env.rb +7 -5
  236. data/lib/resources/package.rb +70 -13
  237. data/lib/resources/packages.rb +111 -0
  238. data/lib/resources/parse_config.rb +3 -4
  239. data/lib/resources/passwd.rb +4 -5
  240. data/lib/resources/pip.rb +29 -21
  241. data/lib/resources/port.rb +133 -14
  242. data/lib/resources/postgres.rb +53 -43
  243. data/lib/resources/postgres_conf.rb +40 -13
  244. data/lib/resources/postgres_hba_conf.rb +101 -0
  245. data/lib/resources/postgres_ident_conf.rb +79 -0
  246. data/lib/resources/postgres_session.rb +28 -20
  247. data/lib/resources/powershell.rb +2 -2
  248. data/lib/resources/processes.rb +61 -26
  249. data/lib/resources/rabbitmq_conf.rb +53 -0
  250. data/lib/resources/registry_key.rb +34 -11
  251. data/lib/resources/security_policy.rb +2 -2
  252. data/lib/resources/service.rb +17 -7
  253. data/lib/resources/ssh_conf.rb +17 -6
  254. data/lib/resources/ssl.rb +3 -4
  255. data/lib/resources/sys_info.rb +1 -1
  256. data/lib/resources/toml.rb +26 -0
  257. data/lib/resources/users.rb +41 -41
  258. data/lib/resources/virtualization.rb +252 -0
  259. data/lib/resources/windows_task.rb +106 -0
  260. data/lib/resources/x509_certificate.rb +143 -0
  261. data/lib/resources/xinetd.rb +18 -2
  262. data/lib/resources/xml.rb +27 -0
  263. data/lib/resources/yaml.rb +10 -2
  264. data/lib/resources/yum.rb +25 -7
  265. data/lib/resources/zfs_dataset.rb +60 -0
  266. data/lib/resources/zfs_pool.rb +49 -0
  267. data/lib/source_readers/flat.rb +2 -1
  268. data/lib/source_readers/inspec.rb +30 -11
  269. data/lib/utils/command_wrapper.rb +3 -3
  270. data/lib/utils/database_helpers.rb +77 -0
  271. data/lib/utils/erlang_parser.rb +192 -0
  272. data/lib/utils/filter.rb +2 -1
  273. data/lib/utils/filter_array.rb +0 -1
  274. data/lib/utils/find_files.rb +1 -2
  275. data/lib/utils/latest_version.rb +21 -0
  276. data/lib/utils/nginx_parser.rb +76 -0
  277. data/lib/utils/object_traversal.rb +5 -4
  278. data/lib/utils/parser.rb +23 -4
  279. data/lib/utils/plugin_registry.rb +3 -3
  280. data/lib/utils/simpleconfig.rb +25 -8
  281. data/lib/utils/spdx.rb +13 -0
  282. data/lib/utils/spdx.txt +344 -0
  283. metadata +168 -22
  284. data/docs/cli.md +0 -342
  285. data/docs/resources/process.md.erb +0 -73
  286. /data/docs/{plugin_kitchen_inspec.html.md → plugin_kitchen_inspec.md} +0 -0
@@ -6,7 +6,7 @@ title: About the file Resource
6
6
 
7
7
  Use the `file` InSpec audit resource to test all system file types, including files, directories, symbolic links, named pipes, sockets, character devices, block devices, and doors.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `file` resource block declares the location of the file type to be tested, what type that file should be (if required), and then one (or more) matchers:
12
12
 
@@ -21,33 +21,33 @@ where
21
21
  * `'value'` is the value to be tested
22
22
 
23
23
 
24
- # Matchers
24
+ ## Matchers
25
25
 
26
26
  This InSpec audit resource has the following matchers:
27
27
 
28
- ## be
28
+ ### be
29
29
 
30
30
  <%= partial "/shared/matcher_be" %>
31
31
 
32
- ## be_block_device
32
+ ### be\_block\_device
33
33
 
34
34
  The `be_block_device` matcher tests if the file exists as a block device, such as `/dev/disk0` or `/dev/disk0s9`:
35
35
 
36
36
  it { should be_block_device }
37
37
 
38
- ## be_character_device
38
+ ### be\_character\_device
39
39
 
40
40
  The `be_character_device` matcher tests if the file exists as a character device (that corresponds to a block device), such as `/dev/rdisk0` or `/dev/rdisk0s9`:
41
41
 
42
42
  it { should be_character_device }
43
43
 
44
- ## be_directory
44
+ ### be_directory
45
45
 
46
46
  The `be_directory` matcher tests if the file exists as a directory, such as `/etc/passwd`, `/etc/shadow`, or `/var/log/httpd`:
47
47
 
48
48
  it { should be_directory }
49
49
 
50
- ## be_executable
50
+ ### be_executable
51
51
 
52
52
  The `be_executable` matcher tests if the file exists as an executable:
53
53
 
@@ -65,49 +65,49 @@ a user:
65
65
 
66
66
  it { should be_executable.by_user('user') }
67
67
 
68
- ## be_file
68
+ ### be_file
69
69
 
70
70
  The `be_file` matcher tests if the file exists as a file. This can be useful with configuration files like `/etc/passwd` where there typically is not an associated file extension---`passwd.txt`:
71
71
 
72
72
  it { should be_file }
73
73
 
74
- ## be_grouped_into
74
+ ### be\_grouped\_into
75
75
 
76
76
  The `be_grouped_into` matcher tests if the file exists as part of the named group:
77
77
 
78
78
  it { should be_grouped_into 'group' }
79
79
 
80
- ## be_immutable
80
+ ### be_immutable
81
81
 
82
82
  The `be_immutable` matcher tests if the file is immutable, i.e. "cannot be changed":
83
83
 
84
84
  it { should be_immutable }
85
85
 
86
- ## be_linked_to
86
+ ### be\_linked\_to
87
87
 
88
88
  The `be_linked_to` matcher tests if the file is linked to the named target:
89
89
 
90
90
  it { should be_linked_to '/etc/target-file' }
91
91
 
92
- ## be_mounted
92
+ ### be_mounted
93
93
 
94
94
  The `be_mounted` matcher tests if the file is accessible from the file system:
95
95
 
96
96
  it { should be_mounted }
97
97
 
98
- ## be_owned_by
98
+ ### be\_owned\_by
99
99
 
100
100
  The `be_owned_by` matcher tests if the file is owned by the named user, such as `root`:
101
101
 
102
102
  it { should be_owned_by 'root' }
103
103
 
104
- ## be_pipe
104
+ ### be_pipe
105
105
 
106
106
  The `be_pipe` matcher tests if the file exists as first-in, first-out special file (`.fifo`) that is typically used to define a named pipe, such as `/var/log/nginx/access.log.fifo`:
107
107
 
108
108
  it { should be_pipe }
109
109
 
110
- ## be_readable
110
+ ### be_readable
111
111
 
112
112
  The `be_readable` matcher tests if the file is readable:
113
113
 
@@ -125,25 +125,25 @@ a user:
125
125
 
126
126
  it { should be_readable.by_user('user') }
127
127
 
128
- ## be_socket
128
+ ### be_socket
129
129
 
130
130
  The `be_socket` matcher tests if the file exists as socket (`.sock`), such as `/var/run/php-fpm.sock`:
131
131
 
132
132
  it { should be_socket }
133
133
 
134
- ## be_symlink
134
+ ### be_symlink
135
135
 
136
136
  The `be_symlink` matcher tests if the file exists as a symbolic, or soft link that contains an absolute or relative path reference to another file:
137
137
 
138
138
  it { should be_symlink }
139
139
 
140
- ## be_version
140
+ ### be_version
141
141
 
142
142
  The `be_version` matcher tests the version of the file:
143
143
 
144
144
  it { should be_version '1.2.3' }
145
145
 
146
- ## be_writable
146
+ ### be_writable
147
147
 
148
148
  The `be_writable` matcher tests if the file is writable:
149
149
 
@@ -161,11 +161,11 @@ a user:
161
161
 
162
162
  it { should be_writable.by_user('user') }
163
163
 
164
- ## cmp
164
+ ### cmp
165
165
 
166
166
  <%= partial "/shared/matcher_cmp" %>
167
167
 
168
- ## content
168
+ ### content
169
169
 
170
170
  The `content` matcher tests if contents in the file match the value specified in a regular expression. The values of the `content` matcher are arbitrary and depend on the file type being tested and also the type of information that is expected to be in that file:
171
171
 
@@ -179,67 +179,67 @@ The following complete example tests the `pg_hba.conf` file in PostgreSQL for MD
179
179
  its('content') { should match(%r{host\s.*?all\s.*?all\s.*?::1\/128\s.*?md5})
180
180
  end
181
181
 
182
- ## eq
182
+ ### eq
183
183
 
184
184
  <%= partial "/shared/matcher_eq" %>
185
185
 
186
- ## exist
186
+ ### exist
187
187
 
188
188
  The `exist` matcher tests if the named file exists:
189
189
 
190
190
  it { should exist }
191
191
 
192
- ## file_version
192
+ ### file_version
193
193
 
194
194
  The `file_version` matcher tests if the file's version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates:
195
195
 
196
196
  its('file_version') { should eq '1.2.3' }
197
197
 
198
- ## group
198
+ ### group
199
199
 
200
200
  The `group` matcher tests if the group to which a file belongs matches the specified value:
201
201
 
202
202
  its('group') { should eq 'admins' }
203
203
 
204
- ## have_mode
204
+ ### have_mode
205
205
 
206
206
  The `have_mode` matcher tests if a file has a mode assigned to it:
207
207
 
208
208
  it { should have_mode }
209
209
 
210
- ## include
210
+ ### include
211
211
 
212
212
  <%= partial "/shared/matcher_include" %>
213
213
 
214
- ## link_path
214
+ ### link_path
215
215
 
216
216
  The `link_path` matcher tests if the file exists at the specified path:
217
217
 
218
218
  its('link_path') { should eq '/some/path/to/file' }
219
219
 
220
- ## link_target
220
+ ### link_target
221
221
 
222
222
  The `link_target` matcher tests if a file that is linked to this file exists at the specified path:
223
223
 
224
224
  its('link_target') { should eq '/some/path/to/file' }
225
225
 
226
- ## match
226
+ ### match
227
227
 
228
228
  <%= partial "/shared/matcher_match" %>
229
229
 
230
- ## md5sum
230
+ ### md5sum
231
231
 
232
232
  The `md5sum` matcher tests if the MD5 checksum for a file matches the specified value:
233
233
 
234
234
  its('md5sum') { should eq '3329x3hf9130gjs9jlasf2305mx91s4j' }
235
235
 
236
- ## mode
236
+ ### mode
237
237
 
238
238
  The `mode` matcher tests if the mode assigned to the file matches the specified value:
239
239
 
240
240
  its('mode') { should cmp '0644' }
241
241
 
242
- ## mtime
242
+ ### mtime
243
243
 
244
244
  The `mtime` matcher tests if the file modification time for the file matches the specified value:
245
245
 
@@ -252,31 +252,31 @@ or:
252
252
  it { should >= Time.now.to_i - 1000}
253
253
  end
254
254
 
255
- ## owner
255
+ ### owner
256
256
 
257
257
  The `owner` matcher tests if the owner of the file matches the specified value:
258
258
 
259
259
  its('owner') { should eq 'root' }
260
260
 
261
- ## product_version
261
+ ### product_version
262
262
 
263
263
  The `product_version` matcher tests if the file's product version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates:
264
264
 
265
265
  its('product_version') { should eq 2.3.4 }
266
266
 
267
- ## selinux_label
267
+ ### selinux_label
268
268
 
269
269
  The `selinux_label` matcher tests if the SELinux label for a file matches the specified value:
270
270
 
271
271
  its('selinux_label') { should eq 'system_u:system_r:httpd_t:s0' }
272
272
 
273
- ## sha256sum
273
+ ### sha256sum
274
274
 
275
275
  The `sha256sum` matcher tests if the SHA-256 checksum for a file matches the specified value:
276
276
 
277
277
  its('sha256sum') { should eq 'b837ch38lh19bb8eaopl8jvxwd2e4g58jn9lkho1w3ed9jbkeicalplaad9k0pjn' }
278
278
 
279
- ## size
279
+ ### size
280
280
 
281
281
  The `size` matcher tests if a file's size matches, is greater than, or is less than the specified value. For example, equal:
282
282
 
@@ -290,7 +290,7 @@ Less than:
290
290
 
291
291
  its('size') { should < 10240 }
292
292
 
293
- ## type
293
+ ### type
294
294
 
295
295
  The `type` matcher tests if the first letter of the file's mode string contains one of the following characters:
296
296
 
@@ -311,11 +311,11 @@ or:
311
311
 
312
312
  its('type') { should eq 'socket' }
313
313
 
314
- # Examples
314
+ ## Examples
315
315
 
316
316
  The following examples show how to use this InSpec audit resource.
317
317
 
318
- ## Test the contents of a file for MD5 requirements
318
+ ### Test the contents of a file for MD5 requirements
319
319
 
320
320
  describe file(hba_config_file) do
321
321
  its('content') { should match /local\s.*?all\s.*?all\s.*?md5/ }
@@ -323,26 +323,26 @@ The following examples show how to use this InSpec audit resource.
323
323
  its('content') { should match %r{/host\s.*?all\s.*?all\s.*?::1\/128\s.*?md5/} }
324
324
  end
325
325
 
326
- ## Test if a file exists
326
+ ### Test if a file exists
327
327
 
328
328
  describe file('/tmp') do
329
329
  it { should exist }
330
330
  end
331
331
 
332
- ## Test that a file does not exist
332
+ ### Test that a file does not exist
333
333
 
334
334
  describe file('/tmpest') do
335
335
  it { should_not exist }
336
336
  end
337
337
 
338
- ## Test if a path is a directory
338
+ ### Test if a path is a directory
339
339
 
340
340
  describe file('/tmp') do
341
341
  its('type') { should eq :directory }
342
342
  it { should be_directory }
343
343
  end
344
344
 
345
- ## Test if a path is a file and not a directory
345
+ ### Test if a path is a file and not a directory
346
346
 
347
347
  describe file('/proc/version') do
348
348
  its('type') { should eq 'file' }
@@ -350,7 +350,7 @@ The following examples show how to use this InSpec audit resource.
350
350
  it { should_not be_directory }
351
351
  end
352
352
 
353
- ## Test if a file is a symbolic link
353
+ ### Test if a file is a symbolic link
354
354
 
355
355
  describe file('/dev/stdout') do
356
356
  its('type') { should eq 'symlink' }
@@ -359,7 +359,7 @@ The following examples show how to use this InSpec audit resource.
359
359
  it { should_not be_directory }
360
360
  end
361
361
 
362
- ## Test if a file is a character device
362
+ ### Test if a file is a character device
363
363
 
364
364
  describe file('/dev/zero') do
365
365
  its('type') { should eq 'character' }
@@ -368,7 +368,7 @@ The following examples show how to use this InSpec audit resource.
368
368
  it { should_not be_directory }
369
369
  end
370
370
 
371
- ## Test if a file is a block device
371
+ ### Test if a file is a block device
372
372
 
373
373
  describe file('/dev/zero') do
374
374
  its('type') { should eq 'block' }
@@ -377,51 +377,51 @@ The following examples show how to use this InSpec audit resource.
377
377
  it { should_not be_directory }
378
378
  end
379
379
 
380
- ## Test the mode for a file
380
+ ### Test the mode for a file
381
381
 
382
382
  describe file('/dev') do
383
383
  its('mode') { should cmp '00755' }
384
384
  end
385
385
 
386
- ## Test the owner of a file
386
+ ### Test the owner of a file
387
387
 
388
388
  describe file('/root') do
389
389
  its('owner') { should eq 'root' }
390
390
  end
391
391
 
392
- ## Test if a file is owned by the root user
392
+ ### Test if a file is owned by the root user
393
393
 
394
394
  describe file('/dev') do
395
395
  it { should be_owned_by 'root' }
396
396
  end
397
397
 
398
- ## Test the mtime for a file
398
+ ### Test the mtime for a file
399
399
 
400
400
  describe file('/').mtime.to_i do
401
401
  it { should <= Time.now.to_i }
402
402
  it { should >= Time.now.to_i - 1000}
403
403
  end
404
404
 
405
- ## Test that a file's size is between 64 and 10240
405
+ ### Test that a file's size is between 64 and 10240
406
406
 
407
407
  describe file('/') do
408
408
  its('size') { should be > 64 }
409
409
  its('size') { should be < 10240 }
410
410
  end
411
411
 
412
- ## Test that a file's size is zero
412
+ ### Test that a file's size is zero
413
413
 
414
414
  describe file('/proc/cpuinfo') do
415
415
  its('size') { should be 0 }
416
416
  end
417
417
 
418
- ## Test that a file is not mounted
418
+ ### Test that a file is not mounted
419
419
 
420
420
  describe file('/proc/cpuinfo') do
421
421
  it { should_not be_mounted }
422
422
  end
423
423
 
424
- ## Test an MD5 checksum
424
+ ### Test an MD5 checksum
425
425
 
426
426
  require 'digest'
427
427
  cpuinfo = file('/proc/cpuinfo').content
@@ -432,7 +432,7 @@ The following examples show how to use this InSpec audit resource.
432
432
  its('md5sum') { should eq md5sum }
433
433
  end
434
434
 
435
- ## Test an SHA-256 checksum
435
+ ### Test an SHA-256 checksum
436
436
 
437
437
  require 'digest'
438
438
  cpuinfo = file('/proc/cpuinfo').content
@@ -443,7 +443,7 @@ The following examples show how to use this InSpec audit resource.
443
443
  its('sha256sum') { should eq sha256sum }
444
444
  end
445
445
 
446
- ## Verify NTP
446
+ ### Verify NTP
447
447
 
448
448
  The following example shows how to use the `file` audit resource to verify if the `ntp.conf` and `leap-seconds` files are present, and then the `command` resource to verify if NTP is installed and running:
449
449
 
@@ -458,3 +458,25 @@ The following example shows how to use the `file` audit resource to verify if th
458
458
  describe command('pgrep ntp') do
459
459
  its('exit_status') { should eq 0 }
460
460
  end
461
+
462
+ ### Test parameters of symlinked file
463
+
464
+ If you need to test the parameters of the target file for a symlink, you can use the `link_path` method for the `file` resource.
465
+
466
+ For example, for the following symlink:
467
+
468
+ lrwxrwxrwx. 1 root root 11 03-10 17:56 /dev/virtio-ports/com.redhat.rhevm.vdsm -> ../vport2p1
469
+
470
+ ... you can write controls for both the link and the target.
471
+
472
+ describe file('/dev/virtio-ports/com.redhat.rhevm.vdsm') do
473
+ it { should be_symlink }
474
+ end
475
+
476
+ virito_port_vdsm = file('/dev/virtio-ports/com.redhat.rhevm.vdsm').link_path
477
+ describe file(virito_port_vdsm) do
478
+ it { should exist }
479
+ it { should be_character_device }
480
+ it { should be_owned_by 'ovirtagent' }
481
+ it { should be_grouped_into 'ovirtagent' }
482
+ end
@@ -6,68 +6,87 @@ title: About the gem Resource
6
6
 
7
7
  Use the `gem` InSpec audit resource to test if a global Gem package is installed.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `gem` resource block declares a package and (optionally) a package version:
12
12
 
13
- describe gem('gem_package_name') do
13
+ describe gem('gem_package_name', 'gem_binary') do
14
14
  it { should be_installed }
15
15
  end
16
16
 
17
17
  where
18
18
 
19
19
  * `('gem_package_name')` must specify a Gem package, such as `'rubocop'`
20
+ * `('gem_binary')` can specify the path to a non-default gem binary, defaults to `'gem'`
20
21
  * `be_installed` is a valid matcher for this resource
21
22
 
22
- # Matchers
23
+ ## Matchers
23
24
 
24
25
  This InSpec audit resource has the following matchers:
25
26
 
26
- ## be
27
+ ### be
27
28
 
28
29
  <%= partial "/shared/matcher_be" %>
29
30
 
30
- ## be_installed
31
+ ### be_installed
31
32
 
32
33
  The `be_installed` matcher tests if the named Gem package is installed:
33
34
 
34
35
  it { should be_installed }
35
36
 
36
- ## cmp
37
+ ### cmp
37
38
 
38
39
  <%= partial "/shared/matcher_cmp" %>
39
40
 
40
- ## eq
41
+ ### eq
41
42
 
42
43
  <%= partial "/shared/matcher_eq" %>
43
44
 
44
- ## include
45
+ ### include
45
46
 
46
47
  <%= partial "/shared/matcher_include" %>
47
48
 
48
- ## match
49
+ ### match
49
50
 
50
51
  <%= partial "/shared/matcher_match" %>
51
52
 
52
- ## version
53
+ ### version
53
54
 
54
55
  The `version` matcher tests if the named package version is on the system:
55
56
 
56
57
  its('version') { should eq '0.33.0' }
57
58
 
58
- # Examples
59
+ ## Examples
59
60
 
60
61
  The following examples show how to use this InSpec audit resource.
61
62
 
62
- ## Verify that a gem package is installed, with a specific version
63
+ ### Verify that a gem package is installed, with a specific version
63
64
 
64
65
  describe gem('rubocop') do
65
66
  it { should be_installed }
66
67
  its('version') { should eq '0.33.0' }
67
68
  end
68
69
 
69
- ## Verify that a gem package is not installed
70
+ ### Verify that a gem package is not installed
70
71
 
71
72
  describe gem('rubocop') do
72
73
  it { should_not be_installed }
73
74
  end
75
+
76
+ ### Verify that a gem package is installed in an omnibus environment
77
+
78
+ describe gem('pry', '/opt/ruby-2.3.1/embedded/bin/gem') do
79
+ it { should be_installed }
80
+ end
81
+
82
+ ### Verify that a gem package is installed in a chef omnibus environment
83
+
84
+ describe gem('chef-sugar', :chef) do
85
+ it { should be_installed }
86
+ end
87
+
88
+ ### Verify that a gem package is installed in a chef-server omnibus environment
89
+
90
+ describe gem('knife-backup', :chef_server) do
91
+ it { should be_installed }
92
+ end
@@ -6,7 +6,7 @@ title: About the group Resource
6
6
 
7
7
  Use the `group` InSpec audit resource to test groups on the system.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `group` resource block declares a group, and then the details to be tested, such as if the group is a local group, the group identifier, or if the group exists:
12
12
 
@@ -20,53 +20,53 @@ where
20
20
  * `'group_name'` must specify the name of a group on the system
21
21
  * `exist` and `'gid'` are valid matchers for this resource
22
22
 
23
- # Matchers
23
+ ## Matchers
24
24
 
25
25
  This InSpec audit resource has the following matchers:
26
26
 
27
- ## be
27
+ ### be
28
28
 
29
29
  <%= partial "/shared/matcher_be" %>
30
30
 
31
- ## be_local
31
+ ### be_local
32
32
 
33
33
  The `be_local` matcher tests if the group is a local group:
34
34
 
35
35
  it { should be_local }
36
36
 
37
- ## cmp
37
+ ### cmp
38
38
 
39
39
  <%= partial "/shared/matcher_cmp" %>
40
40
 
41
- ## eq
41
+ ### eq
42
42
 
43
43
  <%= partial "/shared/matcher_eq" %>
44
44
 
45
- ## exist
45
+ ### exist
46
46
 
47
47
  The `exist` matcher tests if the named user exists:
48
48
 
49
49
  it { should exist }
50
50
 
51
- ## gid
51
+ ### gid
52
52
 
53
53
  The `gid` matcher tests the named group identifier:
54
54
 
55
55
  its('gid') { should eq 1234 }
56
56
 
57
- ## include
57
+ ### include
58
58
 
59
59
  <%= partial "/shared/matcher_include" %>
60
60
 
61
- ## match
61
+ ### match
62
62
 
63
63
  <%= partial "/shared/matcher_match" %>
64
64
 
65
- # Examples
65
+ ## Examples
66
66
 
67
67
  The following examples show how to use this InSpec audit resource.
68
68
 
69
- ## Test the group identifier for the root group
69
+ ### Test the group identifier for the root group
70
70
 
71
71
  describe group('root') do
72
72
  it { should exist }
@@ -6,7 +6,7 @@ title: About the grub_conf Resource
6
6
 
7
7
  Grub is a boot loader on the Linux platform used to load and then transfer control to an operating system kernel, after which that kernel initializes the rest of the operating system. Use the `grub_conf` InSpec audit resource to test boot loader configuration settings that are defined in the `grub.conf` configuration file.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `grub_conf` resource block declares a list of settings in a `grub.conf` file:
12
12
 
@@ -29,35 +29,35 @@ where
29
29
  * `'value'` is the value that is expected
30
30
 
31
31
 
32
- # Matchers
32
+ ## Matchers
33
33
 
34
34
  This InSpec audit resource has the following matchers:
35
35
 
36
- ## be
36
+ ### be
37
37
 
38
38
  <%= partial "/shared/matcher_be" %>
39
39
 
40
- ## cmp
40
+ ### cmp
41
41
 
42
42
  <%= partial "/shared/matcher_cmp" %>
43
43
 
44
- ## eq
44
+ ### eq
45
45
 
46
46
  <%= partial "/shared/matcher_eq" %>
47
47
 
48
- ## include
48
+ ### include
49
49
 
50
50
  <%= partial "/shared/matcher_include" %>
51
51
 
52
- ## match
52
+ ### match
53
53
 
54
54
  <%= partial "/shared/matcher_match" %>
55
55
 
56
- # Examples
56
+ ## Examples
57
57
 
58
58
  The following examples show how to use this InSpec audit resource.
59
59
 
60
- ## Test a grub.conf file
60
+ ### Test a grub.conf file
61
61
 
62
62
  A Grub configuration file located at `/etc/grub.conf` is similar to the following:
63
63
 
@@ -99,7 +99,7 @@ The following test verifies the `ramdisk_size` for the non-deault kernel:
99
99
  its('kernel') { should include 'ramdisk_size=400000' }
100
100
  end
101
101
 
102
- ## Test a configuration file and boot configuration
102
+ ### Test a configuration file and boot configuration
103
103
 
104
104
  describe grub_conf('/etc/grub.conf', 'default') do
105
105
  its('kernel') { should include '/vmlinuz-2.6.32-573.7.1.el6.x86_64' }
@@ -108,7 +108,7 @@ The following test verifies the `ramdisk_size` for the non-deault kernel:
108
108
  its('timeout') { should eq '5' }
109
109
  end
110
110
 
111
- ## Test a specific kernel
111
+ ### Test a specific kernel
112
112
 
113
113
  grub_conf('/etc/grub.conf', 'CentOS (2.6.32-573.12.1.el6.x86_64)') do
114
114
  its('kernel') { should include 'audit=1' }