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
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: The x509_certificate Resource
3
+ ---
4
+
5
+ # x509_certificate
6
+
7
+ Use the `x509_certificate` InSpec audit resource to test the fields and validity of an x.509 certificate.
8
+
9
+ X.509 certificates use public/private key pairs to sign and encrypt documents
10
+ or communications over a network. They may also be used for authentication.
11
+
12
+ Examples include SSL certificates, S/MIME certificates and VPN authentication
13
+ certificates.
14
+
15
+ ## Syntax
16
+
17
+ An `x509_certificate` resource block declares a certificate `key file` to be tested.
18
+
19
+ describe x509_certificate('mycertificate.pem') do
20
+ its('validity_in_days') { should be > 30 }
21
+ end
22
+
23
+ ## Supported Properties
24
+
25
+ ### subject.XX
26
+
27
+ `subject` property makes it easier to access individual subject elements.
28
+
29
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
30
+ its('subject.CN') { should eq "www.mywebsite.com" }
31
+ end
32
+
33
+ ### subject_dn (String)
34
+
35
+ The `subject_dn` string returns the distinguished name of the subject field. It contains several fields separated by forward slashes. The field identifiers are the same ones used by OpenSSL to generate CSR's and certs. Use `subject.XX` instead to access the parsed version.
36
+
37
+ e.g. `/C=US/L=Seattle/O=Chef Software Inc/OU=Chefs/CN=Richard Nixon`
38
+
39
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
40
+ its('subject_dn') { should match "CN=www.mywebsite.com" }
41
+ end
42
+
43
+ ### issuer.XX
44
+
45
+ `issuer` makes it easier to access individual issuer elements.
46
+
47
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
48
+ its('issuer.CN') { should eq "Acme Trust CA" }
49
+ end
50
+
51
+ ### issuer_dn (String)
52
+
53
+ The `issuer_dn` is the distinguished name from a CA (certificate authority) during the
54
+ certificate signing process. It describes which authority is guaranteeing the
55
+ identity of our certificate.
56
+
57
+ e.g. `/C=US/L=Seattle/CN=Acme Trust CA/emailAddress=support@acmetrust.org`
58
+
59
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
60
+ its('issuer_cn') { should match "CN=Acme Trust CA" }
61
+ end
62
+
63
+ ### public_key (String)
64
+
65
+ The `public_key` property returns a base64 encoded public key in PEM format.
66
+
67
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
68
+ its('public_key') { should match "-----BEGIN PUBLIC KEY-----\nblah blah blah..." }
69
+ end
70
+
71
+ ### key_length (Integer)
72
+
73
+ The `key_length` property calculates the number of bits in the public key.
74
+ More bits increase security, but at the cost of speed and in extreme cases, compatibility.
75
+
76
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
77
+ its('key_length') { should be 2048 }
78
+ end
79
+
80
+ ### signature_algorithm (String)
81
+
82
+ The `signature_algorithm` property describes which hash function was used by the CA to
83
+ sign the certificate.
84
+
85
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
86
+ its('signature_algorithm') { should be 'sha256WithRSAEncryption' }
87
+ end
88
+
89
+
90
+ ### validity_in_days (Float)
91
+
92
+ The `validity_in_days` property can be used to check that certificates are not in
93
+ danger of expiring soon.
94
+
95
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
96
+ its('validity_in_days') { should be > 30 }
97
+ end
98
+
99
+ ### not_before and not_after (Time)
100
+
101
+ The `not_before` and `not_after` properties expose the start and end dates of certificate
102
+ validity. They are exposed as ruby Time class so that date arithmetic can be easily performed.
103
+
104
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
105
+ its('not_before') { should be <= Time.utc.now }
106
+ its('not_after') { should be >= Time.utc.now }
107
+ end
108
+
109
+ ### serial (Integer)
110
+
111
+ The `serial` property exposes the serial number of the certificate. The serial number is set by the CA during the signing process and should be unique within that CA.
112
+
113
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
114
+ its('serial') { should eq 9623283588743302433 }
115
+ end
116
+
117
+ ### version (Integer)
118
+
119
+ The `version` property exposes the certificate version.
120
+
121
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
122
+ its('version') { should eq 2 }
123
+ end
124
+
125
+ ### extensions (Hash)
126
+
127
+ The `extensions` hash property is mainly used to determine what the certificate can be used for.
128
+
129
+ describe x509_certificate('/etc/pki/www.mywebsite.com.pem') do
130
+ # Check what extension categories we have
131
+ its('extensions') { should include 'keyUsage' }
132
+ its('extensions') { should include 'extendedKeyUsage' }
133
+ its('extensions') { should include 'subjectAltName' }
134
+
135
+ # Check examples of basic 'keyUsage'
136
+ its('extensions.keyUsage') { should include 'Digital Signature' }
137
+ its('extensions.keyUsage') { should include 'Non Repudiation' }
138
+ its('extensions.keyUsage') { should include 'Data Encipherment' }
139
+
140
+ # Check examples of newer 'extendedKeyUsage'
141
+ its('extensions.extendedKeyUsage') { should include 'TLS Web Server Authentication' }
142
+ its('extensions.extendedKeyUsage') { should include 'Code Signing' }
143
+
144
+ # Check examples of 'subjectAltName'
145
+ its('extensions.subjectAltName') { should include 'email:support@chef.io' }
146
+ end
@@ -6,7 +6,7 @@ title: About the xinetd_conf Resource
6
6
 
7
7
  Use the `xinetd_conf` InSpec audit resource to test services under `/etc/xinet.d` on Linux and Unix platforms. xinetd---the extended Internet service daemon---listens on all ports, and then loads the appropriate program based on a request. The `xinetd.conf` file is typically located at `/etc/xinetd.conf` and contains a list of Internet services associated to the ports on which that service will listen. Only enabled services may handle a request; only services that are required by the system should be enabled.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  An `xinetd_conf` resource block declares settings found in a `xinetd.conf` file for the named service:
12
12
 
@@ -22,29 +22,29 @@ where
22
22
  * `should eq 'value'` is the value that is expected
23
23
 
24
24
 
25
- # Matchers
25
+ ## Matchers
26
26
 
27
27
  This InSpec audit resource has the following matchers:
28
28
 
29
- ## be
29
+ ### be
30
30
 
31
31
  <%= partial "/shared/matcher_be" %>
32
32
 
33
- ## be_enabed
33
+ ### be_enabed
34
34
 
35
35
  The `be_enabled` matcher tests if a service listed under `/etc/xinet.d` is enabled:
36
36
 
37
37
  it { should be_enabled }
38
38
 
39
- ## cmp
39
+ ### cmp
40
40
 
41
41
  <%= partial "/shared/matcher_cmp" %>
42
42
 
43
- ## eq
43
+ ### eq
44
44
 
45
45
  <%= partial "/shared/matcher_eq" %>
46
46
 
47
- ## ids
47
+ ### ids
48
48
 
49
49
  The `ids` matcher tests if the named service is located under `/etc/xinet.d`:
50
50
 
@@ -54,21 +54,21 @@ For example:
54
54
 
55
55
  its('ids') { should include 'chargen-stream chargen-dgram'}
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
- ## services
65
+ ### services
66
66
 
67
67
  The `services` matcher tests if the named service is listed under `/etc/xinet.d`:
68
68
 
69
69
  its('services') { should include 'service_name' }
70
70
 
71
- ## socket_types
71
+ ### socket_types
72
72
 
73
73
  The `socket_types` matcher tests if a service listed under `/etc/xinet.d` is configured to use the named socket type:
74
74
 
@@ -86,7 +86,7 @@ For a TCP-based service:
86
86
 
87
87
  its('socket_types') { should eq 'stream' }
88
88
 
89
- ## types
89
+ ### types
90
90
 
91
91
  The `types` matcher tests the service type:
92
92
 
@@ -94,7 +94,7 @@ The `types` matcher tests the service type:
94
94
 
95
95
  where `'TYPE'` is `INTERNAL` (for a service provided by xinetd), `RPC` (for a service based on remote procedure call), or `UNLISTED` (for services not under `/etc/services` or `/etc/rpc`).
96
96
 
97
- ## wait
97
+ ### wait
98
98
 
99
99
  The `wait` matcher tests how a service handles incoming connections.
100
100
 
@@ -108,11 +108,11 @@ For TCP (`stream`) socket types the `wait` matcher should test for `no`:
108
108
  its('socket_types') { should eq 'stream' }
109
109
  its('wait') { should eq 'no' }
110
110
 
111
- # Examples
111
+ ## Examples
112
112
 
113
113
  The following examples show how to use this InSpec audit resource.
114
114
 
115
- ## Test a socket_type
115
+ ### Test a socket_type
116
116
 
117
117
  The network socket type: `dgram` (a datagram-based service), `raw` (a service that requires direct access to an IP address), `stream` (a stream-based service), or `seqpacket` (a service that requires a sequenced packet).
118
118
 
@@ -120,7 +120,7 @@ The network socket type: `dgram` (a datagram-based service), `raw` (a service th
120
120
  its('socket_types') { should include 'dgram' }
121
121
  end
122
122
 
123
- ## Test a service type
123
+ ### Test a service type
124
124
 
125
125
  The type of service: `INTERNAL` (a service provided by xinetd), `RPC` (an RPC-based service), `TCPMUX` (a service that is started on a well-known TPCMUX port), or `UNLISTED` (a service that is not listed in a standard system file location).
126
126
 
@@ -128,7 +128,7 @@ The type of service: `INTERNAL` (a service provided by xinetd), `RPC` (an RPC-ba
128
128
  its('type') { should include 'RPC' }
129
129
  end
130
130
 
131
- ## Test the telnet service
131
+ ### Test the telnet service
132
132
 
133
133
  For example, a `telnet` file under `/etc/xinet.d` contains the following settings:
134
134
 
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: About the xml Resource
3
+ ---
4
+
5
+ # xml
6
+
7
+ Use the `xml` InSpec audit resource to test data in an XML file.
8
+
9
+ ## Syntax
10
+
11
+ An `xml` resource block declares the data to be tested. Assume the following XML file:
12
+
13
+ <root>
14
+ <name>hello</name>
15
+ <meta>
16
+ <creator>John Doe</creator>
17
+ </meta>
18
+ <array>
19
+ <element>one</element>
20
+ <element>two</element>
21
+ </array>
22
+ </root>
23
+
24
+ This file can be queried using:
25
+
26
+ describe xml('/path/to/name.xml') do
27
+ its('root/name') { should eq ['hello'] }
28
+ its('root/meta/creator') { should eq ['John Doe'] }
29
+ its('root/array[2]/element]) { should eq ['two'] }
30
+ end
31
+
32
+ where
33
+
34
+ * `root/name` is an XPath expression
35
+ * `should eq ['foo']` tests a value of `root/name` as read from an XML file versus the value declared in the test
36
+
37
+ ## Matchers
38
+
39
+ This InSpec audit resource has the following matchers:
40
+
41
+ ### be
42
+
43
+ <%= partial "/shared/matcher_be" %>
44
+
45
+ ### cmp
46
+
47
+ <%= partial "/shared/matcher_cmp" %>
48
+
49
+ ### eq
50
+
51
+ <%= partial "/shared/matcher_eq" %>
52
+
53
+ ### include
54
+
55
+ <%= partial "/shared/matcher_include" %>
56
+
57
+ ### match
58
+
59
+ <%= partial "/shared/matcher_match" %>
60
+
61
+ ### name
62
+
63
+ The `name` matcher tests the value of `name` as read from a JSON file versus the value declared in the test:
64
+
65
+ its('name') { should eq 'foo' }
66
+
67
+ ## Examples
68
+
69
+ The following examples show how to use this InSpec audit resource.
70
+
71
+ ### Test an AppPool's presence in an applicationHost.config file
72
+
73
+ describe xml('applicationHost.config') do
74
+ its('configuration/system.applicationHost/applicationPools/add@name') { should contain('my_pool') }
75
+ end
@@ -6,7 +6,7 @@ title: About the yaml Resource
6
6
 
7
7
  Use the `yaml` InSpec audit resource to test configuration data in a Yaml file.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `yaml` resource block declares the configuration data to be tested. Assume the following Yaml file:
12
12
 
@@ -17,7 +17,7 @@ A `yaml` resource block declares the configuration data to be tested. Assume the
17
17
 
18
18
  This file can be queried using:
19
19
 
20
- describe yaml do
20
+ describe yaml('filename.yml') do
21
21
  its('name') { should eq 'foo' }
22
22
  its(['array', 1]) { should eq 'one' }
23
23
  end
@@ -27,42 +27,56 @@ where
27
27
  * `name` is a configuration setting in a Yaml file
28
28
  * `should eq 'foo'` tests a value of `name` as read from a Yaml file versus the value declared in the test
29
29
 
30
+ Like the `json` resource, the `yaml` resource can read a file, run a command, or accept content inline:
30
31
 
31
- # Matchers
32
+ describe yaml('config.yaml') do
33
+ its(['driver', 'name']) { should eq 'vagrant' }
34
+ end
35
+
36
+ describe yaml({ command: 'retrieve_data.py --yaml' }) do
37
+ its('state') { should eq 'open' }
38
+ end
39
+
40
+ describe yaml({ content: \"key1: value1\nkey2: value2\" }) do
41
+ its('key2') { should cmp 'value2' }
42
+ end
43
+
44
+
45
+ ## Matchers
32
46
 
33
47
  This InSpec audit resource has the following matchers:
34
48
 
35
- ## be
49
+ ### be
36
50
 
37
51
  <%= partial "/shared/matcher_be" %>
38
52
 
39
- ## cmp
53
+ ### cmp
40
54
 
41
55
  <%= partial "/shared/matcher_cmp" %>
42
56
 
43
- ## eq
57
+ ### eq
44
58
 
45
59
  <%= partial "/shared/matcher_eq" %>
46
60
 
47
- ## include
61
+ ### include
48
62
 
49
63
  <%= partial "/shared/matcher_include" %>
50
64
 
51
- ## match
65
+ ### match
52
66
 
53
67
  <%= partial "/shared/matcher_match" %>
54
68
 
55
- ## name
69
+ ### name
56
70
 
57
71
  The `name` matcher tests the value of `name` as read from a Yaml file versus the value declared in the test:
58
72
 
59
73
  its('name') { should eq 'foo' }
60
74
 
61
- # Examples
75
+ ## Examples
62
76
 
63
77
  The following examples show how to use this InSpec audit resource.
64
78
 
65
- ## Test a kitchen.yml file driver
79
+ ### Test a kitchen.yml file driver
66
80
 
67
81
  describe yaml('.kitchen.yaml') do
68
82
  its('driver.name') { should eq('vagrant') }
@@ -6,7 +6,7 @@ title: About the yum Resource
6
6
 
7
7
  Use the `yum` InSpec audit resource to test packages in the Yum repository.
8
8
 
9
- # Syntax
9
+ ## Syntax
10
10
 
11
11
  A `yum` resource block declares a package repo, tests if the package repository is present, and if it that package repository is a valid package source (i.e. "is enabled"):
12
12
 
@@ -19,43 +19,43 @@ where
19
19
 
20
20
  * `repo('name')` is the (optional) name of a package repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`)
21
21
 
22
- # Matchers
22
+ ## Matchers
23
23
 
24
24
  This InSpec audit resource has the following matchers:
25
25
 
26
- ## be
26
+ ### be
27
27
 
28
28
  <%= partial "/shared/matcher_be" %>
29
29
 
30
- ## be_enabled
30
+ ### be_enabled
31
31
 
32
32
  The `be_enabled` matcher tests if the package repository is a valid package source:
33
33
 
34
34
  it { should be_enabled }
35
35
 
36
- ## cmp
36
+ ### cmp
37
37
 
38
38
  <%= partial "/shared/matcher_cmp" %>
39
39
 
40
- ## eq
40
+ ### eq
41
41
 
42
42
  <%= partial "/shared/matcher_eq" %>
43
43
 
44
- ## exist
44
+ ### exist
45
45
 
46
46
  The `exist` matcher tests if the package repository exists:
47
47
 
48
48
  it { should exist }
49
49
 
50
- ## include
50
+ ### include
51
51
 
52
52
  <%= partial "/shared/matcher_include" %>
53
53
 
54
- ## match
54
+ ### match
55
55
 
56
56
  <%= partial "/shared/matcher_match" %>
57
57
 
58
- ## repo('name')
58
+ ### repo('name')
59
59
 
60
60
  The `repo('name')` matcher names a specific package repository:
61
61
 
@@ -63,13 +63,13 @@ The `repo('name')` matcher names a specific package repository:
63
63
  ...
64
64
  end
65
65
 
66
- ## repos
66
+ ### repos
67
67
 
68
68
  The `repos` matcher tests if a named repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`), is included in the Yum repo:
69
69
 
70
70
  its('repos') { should include 'some_repo' }
71
71
 
72
- ## shortname
72
+ ### shortname
73
73
 
74
74
  The `shortname` matcher names a specific package repository's group identifier. For example, if a repository's group name is "Directory Server", the corresponding group idenfier is typically "directory-server":
75
75
 
@@ -77,17 +77,17 @@ The `shortname` matcher names a specific package repository's group identifier.
77
77
  its('shortname') { should eq 'directory-server' }
78
78
  end
79
79
 
80
- # Examples
80
+ ## Examples
81
81
 
82
82
  The following examples show how to use this InSpec audit resource.
83
83
 
84
- ## Test if the yum repo exists
84
+ ### Test if the yum repo exists
85
85
 
86
86
  describe yum do
87
87
  its('repos') { should exist }
88
88
  end
89
89
 
90
- ## Test if the 'base/7/x86_64' repo exists and is enabled
90
+ ### Test if the 'base/7/x86_64' repo exists and is enabled
91
91
 
92
92
  describe yum do
93
93
  its('repos') { should include 'base/7/x86_64' }
@@ -95,9 +95,17 @@ The following examples show how to use this InSpec audit resource.
95
95
  its('epel') { should be_enabled }
96
96
  end
97
97
 
98
- ## Test if a specific yum repo exists
98
+ ### Test if a specific yum repo exists
99
99
 
100
100
  describe yum.repo('epel') do
101
101
  it { should exist }
102
102
  it { should be_enabled }
103
103
  end
104
+
105
+ ### Test a particular repository configuration, such as its Base URL
106
+
107
+ describe yum.repo('mycompany-artifacts') do
108
+ it { should exist }
109
+ it { should be_enabled }
110
+ its('baseurl') { should include 'mycompany.biz' }
111
+ end
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: About the zfs_dataset Resource
3
+ ---
4
+
5
+ # zfs_dataset
6
+
7
+ Use the `zfs_dataset` InSpec audit resource to test the ZFS datasets on FreeBSD systems.
8
+
9
+ ## Syntax
10
+
11
+ A `zfs_dataset` resource block declares the ZFS dataset properties that should be tested:
12
+
13
+ describe zfs_dataset('dataset') do
14
+ it { should MATCHER 'value' }
15
+ end
16
+
17
+ where
18
+
19
+ * `('dataset')` is the name of the ZFS dataset (eg: `'tank/tmp'`)
20
+ * `MATCHER` is a valid matcher for this resource
21
+ * `'value'` is the value to be tested
22
+
23
+
24
+ ## Matchers
25
+
26
+ This InSpec audit resource has the matchers listed below, in addition to dynamically exposing all ZFS dataset properties available (see: `man zfs` for the list of supported properties.)
27
+
28
+ ### be
29
+
30
+ <%= partial "/shared/matcher_be" %>
31
+
32
+ ### be_mounted
33
+
34
+ The `be_mounted` matcher tests if the dataset is accessible from the file system:
35
+
36
+ it { should be_mounted }
37
+
38
+ ### cmp
39
+
40
+ <%= partial "/shared/matcher_cmp" %>
41
+
42
+ ### eq
43
+
44
+ <%= partial "/shared/matcher_eq" %>
45
+
46
+ ### match
47
+
48
+ <%= partial "/shared/matcher_match" %>
49
+
50
+ ## Examples
51
+
52
+ The following examples show how to use this InSpec audit resource.
53
+
54
+ ### Test a dataset of 'tank/tmp'
55
+
56
+ describe zfs_dataset('tank/tmp') do
57
+ it { should be_mounted }
58
+ its('atime') { should eq 'on' }
59
+ its('compression') { should eq 'lz4' }
60
+ its('exec') { should eq 'off' }
61
+ its('readonly') { should eq 'off' }
62
+ its('setuid') { should eq 'off' }
63
+ end
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: About the zfs_pool Resource
3
+ ---
4
+
5
+ # zfs_pool
6
+
7
+ Use the `zfs_pool` InSpec audit resource to test the ZFS pools on FreeBSD systems.
8
+
9
+ ## Syntax
10
+
11
+ A `zfs_pool` resource block declares the ZFS pool properties that should be tested:
12
+
13
+ describe zfs_pool('pool') do
14
+ it { should MATCHER 'value' }
15
+ end
16
+
17
+ where
18
+
19
+ * `('pool')` is the name of the ZFS pool (eg: `'tank'`)
20
+ * `MATCHER` is a valid matcher for this resource
21
+ * `'value'` is the value to be tested
22
+
23
+
24
+ ## Matchers
25
+
26
+ This InSpec audit resource has the matchers listed below, in addition to dynamically exposing all ZFS pool properties available (see: `man zpool` for the list of supported properties.)
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
+ ### match
41
+
42
+ <%= partial "/shared/matcher_match" %>
43
+
44
+ ## Examples
45
+
46
+ The following examples show how to use this InSpec audit resource.
47
+
48
+ ### Test a pool of 'tank'
49
+
50
+ describe zfs_pool('tank') do
51
+ its('autoexpand') { should eq 'off' }
52
+ its('failmode') { should eq 'continue' }
53
+ its('feature@lz4_compress') { should eq 'active' }
54
+ its('health') { should eq 'ONLINE' }
55
+ its('listsnapshots') { should eq 'off' }
56
+ its('readonly') { should eq 'off' }
57
+ end