inspec-core 2.3.10 → 2.3.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -13
  3. data/etc/plugin_filters.json +25 -0
  4. data/inspec-core.gemspec +1 -1
  5. data/lib/bundles/inspec-compliance/api.rb +3 -0
  6. data/lib/bundles/inspec-compliance/configuration.rb +3 -0
  7. data/lib/bundles/inspec-compliance/http.rb +3 -0
  8. data/lib/bundles/inspec-compliance/support.rb +3 -0
  9. data/lib/bundles/inspec-compliance/target.rb +3 -0
  10. data/lib/inspec/objects/attribute.rb +3 -0
  11. data/lib/inspec/plugin/v2.rb +3 -0
  12. data/lib/inspec/plugin/v2/filter.rb +62 -0
  13. data/lib/inspec/plugin/v2/installer.rb +21 -1
  14. data/lib/inspec/plugin/v2/loader.rb +4 -0
  15. data/lib/inspec/profile.rb +3 -1
  16. data/lib/inspec/version.rb +1 -1
  17. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +25 -3
  18. data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +65 -11
  19. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +5 -1
  20. data/lib/resources/package.rb +1 -1
  21. metadata +4 -197
  22. data/docs/.gitignore +0 -2
  23. data/docs/README.md +0 -41
  24. data/docs/dev/control-eval.md +0 -62
  25. data/docs/dev/filtertable-internals.md +0 -353
  26. data/docs/dev/filtertable-usage.md +0 -533
  27. data/docs/dev/integration-testing.md +0 -31
  28. data/docs/dev/plugins.md +0 -323
  29. data/docs/dsl_inspec.md +0 -354
  30. data/docs/dsl_resource.md +0 -100
  31. data/docs/glossary.md +0 -381
  32. data/docs/habitat.md +0 -193
  33. data/docs/inspec_and_friends.md +0 -114
  34. data/docs/matchers.md +0 -161
  35. data/docs/migration.md +0 -293
  36. data/docs/platforms.md +0 -119
  37. data/docs/plugin_kitchen_inspec.md +0 -60
  38. data/docs/plugins.md +0 -57
  39. data/docs/profiles.md +0 -576
  40. data/docs/reporters.md +0 -170
  41. data/docs/resources/aide_conf.md.erb +0 -86
  42. data/docs/resources/apache.md.erb +0 -77
  43. data/docs/resources/apache_conf.md.erb +0 -78
  44. data/docs/resources/apt.md.erb +0 -81
  45. data/docs/resources/audit_policy.md.erb +0 -57
  46. data/docs/resources/auditd.md.erb +0 -89
  47. data/docs/resources/auditd_conf.md.erb +0 -78
  48. data/docs/resources/bash.md.erb +0 -85
  49. data/docs/resources/bond.md.erb +0 -100
  50. data/docs/resources/bridge.md.erb +0 -67
  51. data/docs/resources/bsd_service.md.erb +0 -77
  52. data/docs/resources/chocolatey_package.md.erb +0 -68
  53. data/docs/resources/command.md.erb +0 -176
  54. data/docs/resources/cpan.md.erb +0 -89
  55. data/docs/resources/cran.md.erb +0 -74
  56. data/docs/resources/crontab.md.erb +0 -103
  57. data/docs/resources/csv.md.erb +0 -64
  58. data/docs/resources/dh_params.md.erb +0 -221
  59. data/docs/resources/directory.md.erb +0 -40
  60. data/docs/resources/docker.md.erb +0 -240
  61. data/docs/resources/docker_container.md.erb +0 -113
  62. data/docs/resources/docker_image.md.erb +0 -104
  63. data/docs/resources/docker_plugin.md.erb +0 -80
  64. data/docs/resources/docker_service.md.erb +0 -124
  65. data/docs/resources/elasticsearch.md.erb +0 -252
  66. data/docs/resources/etc_fstab.md.erb +0 -135
  67. data/docs/resources/etc_group.md.erb +0 -85
  68. data/docs/resources/etc_hosts.md.erb +0 -88
  69. data/docs/resources/etc_hosts_allow.md.erb +0 -84
  70. data/docs/resources/etc_hosts_deny.md.erb +0 -84
  71. data/docs/resources/file.md.erb +0 -543
  72. data/docs/resources/filesystem.md.erb +0 -51
  73. data/docs/resources/firewalld.md.erb +0 -117
  74. data/docs/resources/gem.md.erb +0 -108
  75. data/docs/resources/group.md.erb +0 -71
  76. data/docs/resources/grub_conf.md.erb +0 -111
  77. data/docs/resources/host.md.erb +0 -96
  78. data/docs/resources/http.md.erb +0 -207
  79. data/docs/resources/iis_app.md.erb +0 -132
  80. data/docs/resources/iis_site.md.erb +0 -145
  81. data/docs/resources/inetd_conf.md.erb +0 -104
  82. data/docs/resources/ini.md.erb +0 -86
  83. data/docs/resources/interface.md.erb +0 -68
  84. data/docs/resources/iptables.md.erb +0 -74
  85. data/docs/resources/json.md.erb +0 -73
  86. data/docs/resources/kernel_module.md.erb +0 -130
  87. data/docs/resources/kernel_parameter.md.erb +0 -63
  88. data/docs/resources/key_rsa.md.erb +0 -95
  89. data/docs/resources/launchd_service.md.erb +0 -67
  90. data/docs/resources/limits_conf.md.erb +0 -85
  91. data/docs/resources/login_defs.md.erb +0 -81
  92. data/docs/resources/mount.md.erb +0 -79
  93. data/docs/resources/mssql_session.md.erb +0 -78
  94. data/docs/resources/mysql_conf.md.erb +0 -109
  95. data/docs/resources/mysql_session.md.erb +0 -84
  96. data/docs/resources/nginx.md.erb +0 -89
  97. data/docs/resources/nginx_conf.md.erb +0 -148
  98. data/docs/resources/npm.md.erb +0 -78
  99. data/docs/resources/ntp_conf.md.erb +0 -70
  100. data/docs/resources/oneget.md.erb +0 -63
  101. data/docs/resources/oracledb_session.md.erb +0 -103
  102. data/docs/resources/os.md.erb +0 -153
  103. data/docs/resources/os_env.md.erb +0 -101
  104. data/docs/resources/package.md.erb +0 -130
  105. data/docs/resources/packages.md.erb +0 -77
  106. data/docs/resources/parse_config.md.erb +0 -113
  107. data/docs/resources/parse_config_file.md.erb +0 -148
  108. data/docs/resources/passwd.md.erb +0 -151
  109. data/docs/resources/pip.md.erb +0 -77
  110. data/docs/resources/port.md.erb +0 -147
  111. data/docs/resources/postgres_conf.md.erb +0 -89
  112. data/docs/resources/postgres_hba_conf.md.erb +0 -103
  113. data/docs/resources/postgres_ident_conf.md.erb +0 -86
  114. data/docs/resources/postgres_session.md.erb +0 -79
  115. data/docs/resources/powershell.md.erb +0 -112
  116. data/docs/resources/processes.md.erb +0 -119
  117. data/docs/resources/rabbitmq_config.md.erb +0 -51
  118. data/docs/resources/registry_key.md.erb +0 -197
  119. data/docs/resources/runit_service.md.erb +0 -67
  120. data/docs/resources/security_policy.md.erb +0 -57
  121. data/docs/resources/service.md.erb +0 -131
  122. data/docs/resources/shadow.md.erb +0 -267
  123. data/docs/resources/ssh_config.md.erb +0 -83
  124. data/docs/resources/sshd_config.md.erb +0 -93
  125. data/docs/resources/ssl.md.erb +0 -129
  126. data/docs/resources/sys_info.md.erb +0 -52
  127. data/docs/resources/systemd_service.md.erb +0 -67
  128. data/docs/resources/sysv_service.md.erb +0 -67
  129. data/docs/resources/upstart_service.md.erb +0 -67
  130. data/docs/resources/user.md.erb +0 -150
  131. data/docs/resources/users.md.erb +0 -137
  132. data/docs/resources/vbscript.md.erb +0 -65
  133. data/docs/resources/virtualization.md.erb +0 -67
  134. data/docs/resources/windows_feature.md.erb +0 -69
  135. data/docs/resources/windows_hotfix.md.erb +0 -63
  136. data/docs/resources/windows_task.md.erb +0 -95
  137. data/docs/resources/wmi.md.erb +0 -91
  138. data/docs/resources/x509_certificate.md.erb +0 -161
  139. data/docs/resources/xinetd_conf.md.erb +0 -166
  140. data/docs/resources/xml.md.erb +0 -95
  141. data/docs/resources/yaml.md.erb +0 -79
  142. data/docs/resources/yum.md.erb +0 -108
  143. data/docs/resources/zfs_dataset.md.erb +0 -63
  144. data/docs/resources/zfs_pool.md.erb +0 -57
  145. data/docs/shared/matcher_be.md.erb +0 -1
  146. data/docs/shared/matcher_cmp.md.erb +0 -43
  147. data/docs/shared/matcher_eq.md.erb +0 -3
  148. data/docs/shared/matcher_include.md.erb +0 -1
  149. data/docs/shared/matcher_match.md.erb +0 -1
  150. data/docs/shell.md +0 -217
  151. data/docs/style.md +0 -178
  152. data/examples/README.md +0 -8
  153. data/examples/custom-resource/README.md +0 -3
  154. data/examples/custom-resource/controls/example.rb +0 -7
  155. data/examples/custom-resource/inspec.yml +0 -8
  156. data/examples/custom-resource/libraries/batsignal.rb +0 -20
  157. data/examples/custom-resource/libraries/gordon.rb +0 -21
  158. data/examples/inheritance/README.md +0 -65
  159. data/examples/inheritance/controls/example.rb +0 -14
  160. data/examples/inheritance/inspec.yml +0 -16
  161. data/examples/kitchen-ansible/.kitchen.yml +0 -25
  162. data/examples/kitchen-ansible/Gemfile +0 -19
  163. data/examples/kitchen-ansible/README.md +0 -53
  164. data/examples/kitchen-ansible/files/nginx.repo +0 -6
  165. data/examples/kitchen-ansible/tasks/main.yml +0 -16
  166. data/examples/kitchen-ansible/test/integration/default/default.yml +0 -5
  167. data/examples/kitchen-ansible/test/integration/default/web_spec.rb +0 -28
  168. data/examples/kitchen-chef/.kitchen.yml +0 -20
  169. data/examples/kitchen-chef/Berksfile +0 -3
  170. data/examples/kitchen-chef/Gemfile +0 -19
  171. data/examples/kitchen-chef/README.md +0 -27
  172. data/examples/kitchen-chef/metadata.rb +0 -7
  173. data/examples/kitchen-chef/recipes/default.rb +0 -6
  174. data/examples/kitchen-chef/recipes/nginx.rb +0 -30
  175. data/examples/kitchen-chef/test/integration/default/web_spec.rb +0 -28
  176. data/examples/kitchen-puppet/.kitchen.yml +0 -23
  177. data/examples/kitchen-puppet/Gemfile +0 -20
  178. data/examples/kitchen-puppet/Puppetfile +0 -25
  179. data/examples/kitchen-puppet/README.md +0 -53
  180. data/examples/kitchen-puppet/manifests/site.pp +0 -33
  181. data/examples/kitchen-puppet/metadata.json +0 -11
  182. data/examples/kitchen-puppet/modules/.gitkeep +0 -0
  183. data/examples/kitchen-puppet/test/integration/default/web_spec.rb +0 -28
  184. data/examples/meta-profile/README.md +0 -37
  185. data/examples/meta-profile/controls/example.rb +0 -13
  186. data/examples/meta-profile/inspec.yml +0 -13
  187. data/examples/plugins/inspec-resource-lister/Gemfile +0 -12
  188. data/examples/plugins/inspec-resource-lister/LICENSE +0 -13
  189. data/examples/plugins/inspec-resource-lister/README.md +0 -62
  190. data/examples/plugins/inspec-resource-lister/Rakefile +0 -40
  191. data/examples/plugins/inspec-resource-lister/inspec-resource-lister.gemspec +0 -45
  192. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister.rb +0 -16
  193. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/cli_command.rb +0 -70
  194. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/plugin.rb +0 -55
  195. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/version.rb +0 -10
  196. data/examples/plugins/inspec-resource-lister/test/fixtures/README.md +0 -24
  197. data/examples/plugins/inspec-resource-lister/test/functional/README.md +0 -18
  198. data/examples/plugins/inspec-resource-lister/test/functional/inspec_resource_lister_test.rb +0 -110
  199. data/examples/plugins/inspec-resource-lister/test/helper.rb +0 -26
  200. data/examples/plugins/inspec-resource-lister/test/unit/README.md +0 -17
  201. data/examples/plugins/inspec-resource-lister/test/unit/cli_args_test.rb +0 -64
  202. data/examples/plugins/inspec-resource-lister/test/unit/plugin_def_test.rb +0 -51
  203. data/examples/profile-attribute.yml +0 -2
  204. data/examples/profile-attribute/README.md +0 -14
  205. data/examples/profile-attribute/controls/example.rb +0 -11
  206. data/examples/profile-attribute/inspec.yml +0 -8
  207. data/examples/profile-sensitive/README.md +0 -29
  208. data/examples/profile-sensitive/controls/sensitive-failures.rb +0 -9
  209. data/examples/profile-sensitive/controls/sensitive.rb +0 -9
  210. data/examples/profile-sensitive/inspec.yml +0 -8
  211. data/examples/profile/README.md +0 -48
  212. data/examples/profile/controls/example.rb +0 -24
  213. data/examples/profile/controls/gordon.rb +0 -36
  214. data/examples/profile/controls/meta.rb +0 -36
  215. data/examples/profile/inspec.yml +0 -11
  216. data/examples/profile/libraries/gordon_config.rb +0 -59
@@ -1,101 +0,0 @@
1
- ---
2
- title: About the os_env Resource
3
- platform: os
4
- ---
5
-
6
- # os_env
7
-
8
- Use the `os_env` InSpec audit resource to test the environment variables for the platform on which the system is running.
9
-
10
- <br>
11
-
12
- ## Availability
13
-
14
- ### Installation
15
-
16
- This resource is distributed along with InSpec itself. You can use it automatically.
17
-
18
- ### Version
19
-
20
- This resource first became available in v1.0.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- A `os_env` resource block declares an environment variable, and then declares its value:
25
-
26
- describe os_env('VARIABLE') do
27
- its('property') { should eq 1 }
28
- end
29
-
30
- where
31
-
32
- * `('VARIABLE')` must specify an environment variable, such as `PATH`
33
- * `matcher` is a valid matcher for this resource
34
-
35
- <br>
36
-
37
- ## Examples
38
-
39
- The following examples show how to use this InSpec audit resource.
40
-
41
- ### Test the PATH environment variable
42
-
43
- describe os_env('PATH') do
44
- its('split') { should_not include('') }
45
- its('split') { should_not include('.') }
46
- end
47
-
48
- ### Test the Path environment variable by specifying the target Environment (Windows)
49
-
50
- On windows a User's environment variable may obscure the local machine (system) environment variable. The correct environment variable may be tested as follows:
51
-
52
- describe os_env('PATH', 'target') do
53
- its('split') { should_not include('') }
54
- its('split') { should_not include('.') }
55
- end
56
-
57
- where
58
-
59
- * `'target'` may be either `system` or `user`
60
-
61
- ### Test Habitat environment variables
62
-
63
- Habitat uses the `os_env` resource to test environment variables. The environment variables are first defined in a whitespace array, after which each environment variable is tested:
64
-
65
- hab_env_vars = %w(HAB_AUTH_TOKEN
66
- HAB_CACHE_KEY_PATH
67
- HAB_DEPOT_URL
68
- HAB_ORG
69
- HAB_ORIGIN
70
- HAB_ORIGIN_KEYS
71
- HAB_RING
72
- HAB_RING_KEY
73
- HAB_STUDIOS_HOME
74
- HAB_STUDIO_ROOT
75
- HAB_USER)
76
-
77
- hab_env_vars.each do |e|
78
- describe os_env(e) do
79
- its('content') { should eq nil }
80
- end
81
- end
82
-
83
- <br>
84
-
85
- ## Matchers
86
-
87
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
88
-
89
- ### content
90
-
91
- The `content` matcher return the value of the environment variable:
92
-
93
- its('content') { should eq '/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin' }
94
-
95
- ### split
96
-
97
- The `split` matcher splits the value of the environment variable with the `:` deliminator (use the `;` deliminator if Windows):
98
-
99
- its('split') { should include ('/usr/bin') }
100
-
101
- Note: the `split` matcher returns an array including `""` for cases where there is a trailing colon (`:`), such as `dir1::dir2:`
@@ -1,130 +0,0 @@
1
- ---
2
- title: About the package Resource
3
- platform: os
4
- ---
5
-
6
- # package
7
-
8
- Use the `package` InSpec audit resource to test if the named package and/or package version is installed on the system.
9
-
10
- <br>
11
-
12
- ## Availability
13
-
14
- ### Installation
15
-
16
- This resource is distributed along with InSpec itself. You can use it automatically.
17
-
18
- ### Version
19
-
20
- This resource first became available in v1.0.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- A `package` resource block declares a package and (optionally) a package version:
25
-
26
- describe package('name') do
27
- it { should be_installed }
28
- end
29
-
30
- where
31
-
32
- * `('name')` must specify the name of a package, such as `'nginx'`
33
- * `be_installed` is a valid matcher for this resource
34
-
35
- <br>
36
-
37
- ## Examples
38
-
39
- The following examples show how to use this InSpec audit resource.
40
-
41
- ### Test if NGINX version 1.9.5 is installed
42
-
43
- describe package('nginx') do
44
- it { should be_installed }
45
- its('version') { should eq '1.9.5' }
46
- end
47
-
48
- ### Test that a package is not installed
49
-
50
- describe package('some_package') do
51
- it { should_not be_installed }
52
- end
53
-
54
- ### Test if telnet is installed
55
-
56
- describe package('telnetd') do
57
- it { should_not be_installed }
58
- end
59
-
60
- describe inetd_conf do
61
- its('telnet') { should eq nil }
62
- end
63
-
64
- ### Test if ClamAV (an antivirus engine) is installed and running
65
-
66
- describe package('clamav') do
67
- it { should be_installed }
68
- its('version') { should eq '0.98.7' }
69
- end
70
-
71
- describe service('clamd') do
72
- it { should_not be_enabled }
73
- it { should_not be_installed }
74
- it { should_not be_running }
75
- end
76
-
77
- ### Verify if a package is installed according to my rpm database
78
-
79
- describe package('some_package', rpm_dbpath: '/var/lib/my_rpmdb') do
80
- it { should be_installed }
81
- end
82
-
83
- ### Verify if Memcached is installed, enabled, and running
84
-
85
- Memcached is an in-memory key-value store that helps improve the performance of database-driven websites and can be installed, maintained, and tested using the `memcached` cookbook (maintained by Chef). The following example is from the `memcached` cookbook and shows how to use a combination of the `package`, `service`, and `port` InSpec audit resources to test if Memcached is installed, enabled, and running:
86
-
87
- describe package('memcached') do
88
- it { should be_installed }
89
- end
90
-
91
- describe service('memcached') do
92
- it { should be_installed }
93
- it { should be_enabled }
94
- it { should be_running }
95
- end
96
-
97
- describe port(11_211) do
98
- it { should be_listening }
99
- end
100
-
101
- <br>
102
-
103
- ## Matchers
104
-
105
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
106
-
107
- ### be_held
108
-
109
- The `be_held` matcher tests if the named package is "held". On dpkg platforms, a "held" package
110
- will not be upgraded to a later version.
111
-
112
- it { should be_held }
113
-
114
- ### be_installed
115
-
116
- The `be_installed` matcher tests if the named package is installed on the system:
117
-
118
- it { should be_installed }
119
-
120
- ### version
121
-
122
- The `version` matcher tests if the named package version is on the system:
123
-
124
- its('version') { should eq '1.2.3' }
125
-
126
- You can also use the `cmp OPERATOR` matcher to perform comparisons using the version attribute:
127
-
128
- its('version') { should cmp >= '7.35.0-1ubuntu3.10' }
129
-
130
- `cmp` understands version numbers using Gem::Version, and can use the operators `==, <, <=, >=, and >`. It will compare versions by each segment, not as a string - so '7.4' is smaller than '7.30', for example.
@@ -1,77 +0,0 @@
1
- ---
2
- title: About the packages Resource
3
- platform: linux
4
- ---
5
-
6
- # packages
7
-
8
- Use the `packages` InSpec audit resource to test the properties of multiple packages on the system.
9
-
10
- <br>
11
-
12
- ## Availability
13
-
14
- ### Installation
15
-
16
- This resource is distributed along with InSpec itself. You can use it automatically.
17
-
18
- ### Version
19
-
20
- This resource first became available in v1.51.15 of InSpec.
21
-
22
- ## Syntax
23
-
24
- A `packages` resource block declares a regular expression search to select packages
25
-
26
- describe packages(/name/) do
27
- its('statuses') { should cmp 'installed' }
28
- end
29
-
30
- <br>
31
-
32
- ## Examples
33
-
34
- The following examples show how to use this InSpec audit resource.
35
-
36
- ### Verify that no `xserver` packages are installed
37
-
38
- describe package(/xserver/) do
39
- its('statuses') { should_not cmp 'installed' }
40
- end
41
-
42
- ### Verify all `openssl` packages match a certain version
43
-
44
- describe package(/openssl/) do
45
- its('versions') { should cmp '1.0.1e-42.el7' }
46
- end
47
-
48
- ### Verify that both the `i686` and `x86_64` versions of `libgcc` are installed
49
-
50
- describe package(/libgcc/) do
51
- its('architectures') { should include 'x86_64' }
52
- its('architectures') { should include 'i686' }
53
- end
54
-
55
- <br>
56
-
57
- ## Matchers
58
-
59
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
60
-
61
- ### statuses
62
-
63
- The `statuses` matcher tests if packages are installed on the system
64
-
65
- its('statuses') { should cmp 'installed' }
66
-
67
- ### versions
68
-
69
- The `versions` matcher tests the versions of the packages installed on the system
70
-
71
- its('versions') { should cmp '3.4.0.2-4.el7' }
72
-
73
- ### architectures
74
-
75
- The `architectures` matcher tests the architecture of packages installed on the system
76
-
77
- its('architectures') { should include 'i686' }
@@ -1,113 +0,0 @@
1
- ---
2
- title: About the parse_config Resource
3
- platform: os
4
- ---
5
-
6
- # parse_config
7
-
8
- Use the `parse_config` InSpec audit resource to test arbitrary configuration files.
9
-
10
- <br>
11
-
12
- ## Availability
13
-
14
- ### Installation
15
-
16
- This resource is distributed along with InSpec itself. You can use it automatically.
17
-
18
- ### Version
19
-
20
- This resource first became available in v1.0.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- A `parse_config` resource block declares the location of the configuration setting to be tested, and then what value is to be tested. Because this resource relies on arbitrary configuration files, the test itself is often arbitrary and relies on custom Ruby code:
25
-
26
- output = command('some-command').stdout
27
-
28
- describe parse_config(output, { data_config_option: value } ) do
29
- its('setting') { should eq 1 }
30
- end
31
-
32
- or:
33
-
34
- audit = command('/sbin/auditctl -l').stdout
35
- options = {
36
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
37
- multiple_values: true
38
- }
39
-
40
- describe parse_config(audit, options) do
41
- its('setting') { should eq 1 }
42
- end
43
-
44
- where each test
45
-
46
- * Must declare the location of the configuration file to be tested
47
- * Must declare one (or more) settings to be tested
48
- * May run a command to `stdout`, and then run the test against that output
49
- * May use options to define how configuration data is to be parsed
50
-
51
- <br>
52
-
53
- ## Matchers
54
-
55
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
56
-
57
- ### assignment_regex
58
-
59
- Use `assignment_regex` to test a key value using a regular expression:
60
-
61
- 'key = value'
62
-
63
- may be tested using the following regular expression, which determines assignment from key to value:
64
-
65
- assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
66
-
67
- ### comment_char
68
-
69
- Use `comment_char` to test for comments in a configuration file:
70
-
71
- comment_char: '#'
72
-
73
- ### key_values
74
-
75
- Use `key_values` to test how many values a key contains:
76
-
77
- key = a b c
78
-
79
- contains three values. To test that value to ensure it only contains one, use:
80
-
81
- key_values: 1
82
-
83
- ### multiple_values
84
-
85
- Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
86
-
87
- # # file structure:
88
- # key = a
89
- # key = b
90
- # key2 = c
91
- params['key'] = ['a', 'b']
92
- params['key2'] = ['c']
93
-
94
- To use plain key value mapping, use `multiple_values: false`:
95
-
96
- # # file structure:
97
- # key = a
98
- # key = b
99
- # key2 = c
100
- params['key'] = 'b'
101
- params['key2'] = 'c'
102
-
103
- ### standalone_comments
104
-
105
- Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
106
-
107
- 'key = value # comment'
108
- params['key'] = 'value # comment'
109
-
110
- Use `standalone_comments: false`, to parse the following:
111
-
112
- 'key = value # comment'
113
- params['key'] = 'value'
@@ -1,148 +0,0 @@
1
- ---
2
- title: About the parse_config_file Resource
3
- platform: os
4
- ---
5
-
6
- # parse\_config\_file
7
-
8
- Use the `parse_config_file` InSpec audit resource to test arbitrary configuration files. It works in the same way as `parse_config`. Instead of using a command output, this resource works with files.
9
-
10
- <br>
11
-
12
- ## Availability
13
-
14
- ### Installation
15
-
16
- This resource is distributed along with InSpec itself. You can use it automatically.
17
-
18
- ### Version
19
-
20
- This resource first became available in v1.0.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- A `parse_config_file` InSpec audit resource block declares the location of the configuration file to be tested, and then which settings in that file are to be tested.
25
-
26
- describe parse_config_file('/path/to/file', { data_config_option: value } ) do
27
- its('setting') { should eq 1 }
28
- end
29
-
30
- or:
31
-
32
- options = {
33
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
34
- multiple_values: true
35
- }
36
-
37
- describe parse_config_file('path/to/file', options) do
38
- its('setting') { should eq 1 }
39
- end
40
-
41
- where each test
42
-
43
- * Must declare the location of the configuration file to be tested
44
- * Must declare one (or more) settings to be tested
45
- * May run a command to `stdout`, and then run the test against that output
46
- * May use options to define how configuration data is to be parsed
47
-
48
- <br>
49
-
50
- ## Options
51
-
52
- This resource supports the following options for parsing configuration data. Use them in an `options` block stated outside of (and immediately before) the actual test:
53
-
54
- options = {
55
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
56
- multiple_values: true
57
- }
58
- describe parse_config_file('path/to/file', options) do
59
- its('setting') { should eq 1 }
60
- end
61
-
62
- <br>
63
-
64
- ## Examples
65
-
66
- The following examples show how to use this InSpec audit resource.
67
-
68
- ### Test a configuration setting
69
-
70
- describe parse_config_file('/path/to/file.conf') do
71
- its('PARAM_X') { should eq 'Y' }
72
- end
73
-
74
- ### Use options, and then test a configuration setting
75
-
76
- describe parse_config_file('/path/to/file.conf', { multiple_values: true }) do
77
- its('PARAM_X') { should include 'Y' }
78
- end
79
-
80
- ### Test a file with an ini-like structure (such as a yum.conf)
81
-
82
- describe parse_config_file('/path/to/yum.conf') do
83
- its('main') { should include('gpgcheck' => '1') }
84
- end
85
-
86
- <br>
87
-
88
- ## Matchers
89
-
90
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
91
-
92
- ### assignment_regex
93
-
94
- Use `assignment_regex` to test a key value using a regular expression:
95
-
96
- 'key = value'
97
-
98
- may be tested using the following regular expression, which determines assignment from key to value:
99
-
100
- assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
101
-
102
- ### comment_char
103
-
104
- Use `comment_char` to test for comments in a configuration file:
105
-
106
- comment_char: '#'
107
-
108
- ### key_values
109
-
110
- Use `key_values` to test how many values a key contains:
111
-
112
- key = a b c
113
-
114
- contains three values. To test that value to ensure it only contains one, use:
115
-
116
- key_values: 1
117
-
118
- ### multiple_values
119
-
120
- Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
121
-
122
- # # file structure:
123
- # key = a
124
- # key = b
125
- # key2 = c
126
- params['key'] = ['a', 'b']
127
- params['key2'] = ['c']
128
-
129
- To use plain key value mapping, use `multiple_values: false`:
130
-
131
- # # file structure:
132
- # key = a
133
- # key = b
134
- # key2 = c
135
- params['key'] = 'b'
136
- params['key2'] = 'c'
137
-
138
- ### standalone_comments
139
-
140
- Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
141
-
142
- 'key = value # comment'
143
- params['key'] = 'value # comment'
144
-
145
- Use `standalone_comments: false`, to parse the following:
146
-
147
- 'key = value # comment'
148
- params['key'] = 'value'