inspec 1.31.0 → 1.45.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +2599 -1
  4. data/Gemfile +0 -1
  5. data/README.md +24 -34
  6. data/Rakefile +0 -31
  7. data/docs/dsl_inspec.md +10 -0
  8. data/docs/matchers.md +29 -0
  9. data/docs/plugin_kitchen_inspec.md +18 -24
  10. data/docs/profiles.md +101 -81
  11. data/docs/resources/aide_conf.md.erb +71 -0
  12. data/docs/resources/apache_conf.md.erb +19 -33
  13. data/docs/resources/apt.md.erb +22 -36
  14. data/docs/resources/audit_policy.md.erb +9 -24
  15. data/docs/resources/auditd.md.erb +78 -0
  16. data/docs/resources/auditd_conf.md.erb +20 -34
  17. data/docs/resources/auditd_rules.md.erb +8 -24
  18. data/docs/resources/bash.md.erb +4 -26
  19. data/docs/resources/bond.md.erb +25 -40
  20. data/docs/resources/bridge.md.erb +5 -25
  21. data/docs/resources/bsd_service.md.erb +5 -25
  22. data/docs/resources/command.md.erb +35 -50
  23. data/docs/resources/cpan.md.erb +62 -0
  24. data/docs/resources/cran.md.erb +54 -0
  25. data/docs/resources/crontab.md.erb +9 -23
  26. data/docs/resources/csv.md.erb +12 -27
  27. data/docs/resources/dh_params.md +1 -0
  28. data/docs/resources/directory.md.erb +5 -25
  29. data/docs/resources/docker.md.erb +61 -58
  30. data/docs/resources/docker_container.md.erb +23 -19
  31. data/docs/resources/docker_image.md.erb +20 -16
  32. data/docs/resources/elasticsearch.md.erb +245 -0
  33. data/docs/resources/etc_fstab.md.erb +120 -0
  34. data/docs/resources/etc_group.md.erb +29 -45
  35. data/docs/resources/etc_hosts.md.erb +68 -0
  36. data/docs/resources/etc_hosts_allow.md.erb +68 -0
  37. data/docs/resources/etc_hosts_deny.md.erb +68 -0
  38. data/docs/resources/file.md.erb +227 -216
  39. data/docs/resources/firewalld.md.erb +104 -0
  40. data/docs/resources/gem.md.erb +21 -35
  41. data/docs/resources/group.md.erb +16 -30
  42. data/docs/resources/grub_conf.md.erb +9 -24
  43. data/docs/resources/host.md.erb +32 -49
  44. data/docs/resources/http.md.erb +38 -44
  45. data/docs/resources/iis_app.md.erb +25 -35
  46. data/docs/resources/iis_site.md.erb +26 -40
  47. data/docs/resources/inetd_conf.md.erb +27 -42
  48. data/docs/resources/ini.md.erb +9 -23
  49. data/docs/resources/interface.md.erb +5 -25
  50. data/docs/resources/iptables.md.erb +15 -29
  51. data/docs/resources/json.md.erb +12 -27
  52. data/docs/resources/kernel_module.md.erb +47 -61
  53. data/docs/resources/kernel_parameter.md.erb +15 -29
  54. data/docs/resources/key_rsa.md.erb +3 -0
  55. data/docs/resources/launchd_service.md.erb +5 -25
  56. data/docs/resources/limits_conf.md.erb +15 -29
  57. data/docs/resources/login_def.md.erb +15 -30
  58. data/docs/resources/mount.md.erb +18 -33
  59. data/docs/resources/mssql_session.md.erb +9 -12
  60. data/docs/resources/mysql_conf.md.erb +28 -32
  61. data/docs/resources/mysql_session.md.erb +15 -29
  62. data/docs/resources/nginx.md.erb +78 -0
  63. data/docs/resources/nginx_conf.md.erb +127 -0
  64. data/docs/resources/npm.md.erb +19 -35
  65. data/docs/resources/ntp_conf.md.erb +20 -37
  66. data/docs/resources/oneget.md.erb +15 -30
  67. data/docs/resources/oracledb_session.md.erb +9 -11
  68. data/docs/resources/os.md.erb +29 -43
  69. data/docs/resources/os_env.md.erb +23 -44
  70. data/docs/resources/package.md.erb +34 -36
  71. data/docs/resources/parse_config.md.erb +5 -25
  72. data/docs/resources/parse_config_file.md.erb +31 -43
  73. data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +24 -39
  74. data/docs/resources/pip.md.erb +20 -35
  75. data/docs/resources/port.md.erb +43 -57
  76. data/docs/resources/postgres_conf.md.erb +17 -31
  77. data/docs/resources/postgres_hba_conf.md.erb +26 -38
  78. data/docs/resources/postgres_ident_conf.md.erb +25 -37
  79. data/docs/resources/postgres_session.md.erb +15 -29
  80. data/docs/resources/powershell.md.erb +27 -42
  81. data/docs/resources/processes.md.erb +17 -33
  82. data/docs/resources/rabbitmq_config.md.erb +9 -24
  83. data/docs/resources/registry_key.md.erb +27 -42
  84. data/docs/resources/runit_service.md.erb +5 -25
  85. data/docs/resources/security_policy.md.erb +12 -27
  86. data/docs/resources/service.md.erb +27 -42
  87. data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +41 -47
  88. data/docs/resources/ssh_config.md.erb +19 -34
  89. data/docs/resources/sshd_config.md.erb +19 -34
  90. data/docs/resources/ssl.md.erb +39 -54
  91. data/docs/resources/sys_info.md.erb +12 -26
  92. data/docs/resources/systemd_service.md.erb +5 -25
  93. data/docs/resources/sysv_service.md.erb +5 -25
  94. data/docs/resources/upstart_service.md.erb +5 -25
  95. data/docs/resources/user.md.erb +29 -44
  96. data/docs/resources/users.md.erb +12 -26
  97. data/docs/resources/vbscript.md.erb +9 -24
  98. data/docs/resources/virtualization.md.erb +8 -23
  99. data/docs/resources/windows_feature.md.erb +15 -30
  100. data/docs/resources/windows_hotfix.md.erb +50 -0
  101. data/docs/resources/windows_task.md.erb +12 -26
  102. data/docs/resources/wmi.md.erb +9 -24
  103. data/docs/resources/x509_certificate.md.erb +4 -0
  104. data/docs/resources/xinetd_conf.md.erb +65 -80
  105. data/docs/resources/xml.md.erb +61 -0
  106. data/docs/resources/yaml.md.erb +12 -27
  107. data/docs/resources/yum.md.erb +37 -51
  108. data/docs/resources/zfs_dataset.md.erb +15 -26
  109. data/docs/resources/zfs_pool.md.erb +9 -20
  110. data/docs/ruby_usage.md +0 -1
  111. data/examples/meta-profile/README.md +1 -1
  112. data/examples/profile-sensitive/README.md +29 -0
  113. data/examples/profile-sensitive/controls/sensitive-failures.rb +9 -0
  114. data/examples/profile-sensitive/controls/sensitive.rb +9 -0
  115. data/examples/profile-sensitive/inspec.yml +8 -0
  116. data/inspec.gemspec +3 -3
  117. data/lib/bundles/inspec-artifact/cli.rb +5 -5
  118. data/lib/bundles/inspec-compliance/README.md +24 -22
  119. data/lib/bundles/inspec-compliance/api/login.rb +152 -0
  120. data/lib/bundles/inspec-compliance/api.rb +46 -16
  121. data/lib/bundles/inspec-compliance/cli.rb +58 -165
  122. data/lib/bundles/inspec-compliance/target.rb +2 -3
  123. data/lib/bundles/inspec-habitat/cli.rb +7 -2
  124. data/lib/bundles/inspec-habitat/profile.rb +44 -20
  125. data/lib/bundles/inspec-init/templates/profile/README.md +1 -1
  126. data/lib/bundles/inspec-init/templates/profile/controls/example.rb +1 -1
  127. data/lib/bundles/inspec-supermarket/api.rb +1 -1
  128. data/lib/inspec/backend.rb +8 -0
  129. data/lib/inspec/cli.rb +1 -1
  130. data/lib/inspec/control_eval_context.rb +16 -6
  131. data/lib/inspec/dependencies/requirement.rb +22 -8
  132. data/lib/inspec/dependencies/resolver.rb +1 -1
  133. data/lib/inspec/exceptions.rb +4 -0
  134. data/lib/inspec/file_provider.rb +38 -9
  135. data/lib/inspec/metadata.rb +17 -3
  136. data/lib/inspec/objects/attribute.rb +16 -7
  137. data/lib/inspec/objects/control.rb +10 -2
  138. data/lib/inspec/plugins/resource.rb +34 -5
  139. data/lib/inspec/profile.rb +10 -1
  140. data/lib/inspec/profile_context.rb +3 -1
  141. data/lib/inspec/resource.rb +17 -5
  142. data/lib/inspec/rspec_json_formatter.rb +48 -14
  143. data/lib/inspec/rule.rb +4 -0
  144. data/lib/inspec/runner.rb +72 -30
  145. data/lib/inspec/shell.rb +24 -19
  146. data/lib/inspec/version.rb +1 -1
  147. data/lib/matchers/matchers.rb +40 -0
  148. data/lib/resources/aide_conf.rb +162 -0
  149. data/lib/resources/auditd.rb +231 -0
  150. data/lib/resources/auditd_rules.rb +3 -1
  151. data/lib/resources/command.rb +1 -1
  152. data/lib/resources/cpan.rb +60 -0
  153. data/lib/resources/cran.rb +66 -0
  154. data/lib/resources/docker.rb +8 -1
  155. data/lib/resources/docker_container.rb +19 -2
  156. data/lib/resources/elasticsearch.rb +172 -0
  157. data/lib/resources/etc_fstab.rb +102 -0
  158. data/lib/resources/etc_group.rb +1 -1
  159. data/lib/resources/etc_hosts.rb +81 -0
  160. data/lib/resources/etc_hosts_allow_deny.rb +122 -0
  161. data/lib/resources/file.rb +87 -10
  162. data/lib/resources/firewalld.rb +144 -0
  163. data/lib/resources/groups.rb +0 -1
  164. data/lib/resources/host.rb +30 -15
  165. data/lib/resources/http.rb +178 -22
  166. data/lib/resources/mssql_session.rb +3 -3
  167. data/lib/resources/mysql_conf.rb +10 -0
  168. data/lib/resources/mysql_session.rb +1 -1
  169. data/lib/resources/nginx.rb +97 -0
  170. data/lib/resources/nginx_conf.rb +134 -1
  171. data/lib/resources/oracledb_session.rb +9 -8
  172. data/lib/resources/os_env.rb +7 -4
  173. data/lib/resources/package.rb +14 -2
  174. data/lib/resources/packages.rb +1 -1
  175. data/lib/resources/pip.rb +28 -20
  176. data/lib/resources/port.rb +251 -3
  177. data/lib/resources/postgres.rb +1 -1
  178. data/lib/resources/postgres_session.rb +1 -1
  179. data/lib/resources/processes.rb +106 -20
  180. data/lib/resources/registry_key.rb +11 -2
  181. data/lib/resources/service.rb +5 -24
  182. data/lib/resources/ssh_conf.rb +1 -1
  183. data/lib/resources/ssl.rb +4 -3
  184. data/lib/resources/toml.rb +2 -2
  185. data/lib/resources/windows_hotfix.rb +35 -0
  186. data/lib/resources/xinetd.rb +4 -6
  187. data/lib/resources/xml.rb +27 -0
  188. data/lib/source_readers/inspec.rb +3 -3
  189. data/lib/utils/find_files.rb +2 -1
  190. data/lib/utils/nginx_parser.rb +10 -1
  191. data/lib/utils/object_traversal.rb +35 -10
  192. data/lib/utils/parser.rb +21 -3
  193. metadata +48 -18
  194. data/docs/cli.md +0 -392
@@ -6,45 +6,53 @@ title: About the os Resource
6
6
 
7
7
  Use the `os` InSpec audit resource to test the platform on which the system is running.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `os` resource block declares the platform to be tested. The platform may specified via matcher or control block name. For example, using a matcher:
12
14
 
13
15
  describe os[:family] do
14
- it { should eq 'platform_name' }
16
+ it { should eq 'platform_family_name' }
15
17
  end
16
18
 
17
- or using the block name:
18
-
19
- describe os[:family_name] do
20
- ...
21
- end
19
+ * `'platform_family_name'` (a string) is one of `aix`, `bsd`, `darwin`, `debian`, `hpux`, `linux`, `redhat`, `solaris`, `suse`, `unix`, or `windows`
22
20
 
23
- * `'platform_name'` (a string) or `:family_name` (a symbol) is one of `aix`, `bsd`, `darwin`, `debian`, `hpux`, `linux`, `redhat`, `solaris`, `suse`, `unix`, or `windows`
21
+ The parameters available to `os` are:
24
22
 
25
- ## Matchers
23
+ * `:name` - the operating system name, such as `centos`
24
+ * `:family` - the operating system family, such as `redhat`
25
+ * `:release` - the version of the operating system, such as `7.3.1611`
26
+ * `:arch` - the architecture of the operating system, such as `x86_64`
27
+ <br>
26
28
 
27
- This InSpec audit resource has the following matchers:
29
+ ## Examples
28
30
 
29
- ### be
31
+ The following examples show how to use this InSpec audit resource.
30
32
 
31
- <%= partial "/shared/matcher_be" %>
33
+ ### Test for RedHat
32
34
 
33
- ### cmp
35
+ describe os[:family] do
36
+ it { should eq 'redhat' }
37
+ end
34
38
 
35
- <%= partial "/shared/matcher_cmp" %>
39
+ ### Test for Ubuntu
36
40
 
37
- ### eq
41
+ describe os[:family] do
42
+ it { should eq 'debian' }
43
+ end
38
44
 
39
- <%= partial "/shared/matcher_eq" %>
45
+ ### Test for Microsoft Windows
40
46
 
41
- ### include
47
+ describe os[:family] do
48
+ it { should eq 'windows' }
49
+ end
42
50
 
43
- <%= partial "/shared/matcher_include" %>
51
+ <br>
44
52
 
45
- ### match
53
+ ## Matchers
46
54
 
47
- <%= partial "/shared/matcher_match" %>
55
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
48
56
 
49
57
  ## os.family? Helpers
50
58
 
@@ -121,34 +129,12 @@ For example, both of the following tests should have the same result:
121
129
  end
122
130
  end
123
131
 
124
- if os[:debian]
132
+ if os.debian?
125
133
  describe port(69) do
126
134
  its('processes') { should include 'in.tftpd' }
127
135
  end
128
- elsif os[:redhat]
136
+ elsif os.redhat?
129
137
  describe port(69) do
130
138
  its('processes') { should include 'xinetd' }
131
139
  end
132
140
  end
133
-
134
- ## Examples
135
-
136
- The following examples show how to use this InSpec audit resource.
137
-
138
- ### Test for RedHat
139
-
140
- describe os[:family] do
141
- it { should eq 'redhat' }
142
- end
143
-
144
- ### Test for Ubuntu
145
-
146
- describe os[:family] do
147
- it { should eq 'debian' }
148
- end
149
-
150
- ### Test for Microsoft Windows
151
-
152
- describe os[:family] do
153
- it { should eq 'windows' }
154
- end
@@ -6,6 +6,8 @@ title: About the os_env Resource
6
6
 
7
7
  Use the `os_env` InSpec audit resource to test the environment variables for the platform on which the system is running.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `os_env` resource block declares an environment variable, and then declares its value:
@@ -19,50 +21,7 @@ where
19
21
  * `('VARIABLE')` must specify an environment variable, such as `PATH`
20
22
  * `matcher` is a valid matcher for this resource
21
23
 
22
-
23
- ## Matchers
24
-
25
- This InSpec audit resource has the following matchers:
26
-
27
- ### be
28
-
29
- <%= partial "/shared/matcher_be" %>
30
-
31
- ### cmp
32
-
33
- <%= partial "/shared/matcher_cmp" %>
34
-
35
- ### content
36
-
37
- The `content` matcher return the value of the environment variable:
38
-
39
- its('content') { should eq '/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin' }
40
-
41
- ### eq
42
-
43
- <%= partial "/shared/matcher_eq" %>
44
-
45
- ### include
46
-
47
- <%= partial "/shared/matcher_include" %>
48
-
49
- ### match
50
-
51
- <%= partial "/shared/matcher_match" %>
52
-
53
- ### split
54
-
55
- The `split` splits the content with the `:` deliminator:
56
-
57
- its('split') { should include (':') }
58
-
59
- or:
60
-
61
- its('split') { should_not include ('.') }
62
-
63
- Use `-1` to test for cases where there is a trailing colon (`:`), such as `dir1::dir2:`:
64
-
65
- its('split') { should include ('-1') }
24
+ <br>
66
25
 
67
26
  ## Examples
68
27
 
@@ -96,3 +55,23 @@ Habitat uses the `os_env` resource to test environment variables. The environmen
96
55
  its('content') { should eq nil }
97
56
  end
98
57
  end
58
+
59
+ <br>
60
+
61
+ ## Matchers
62
+
63
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
64
+
65
+ ### content
66
+
67
+ The `content` matcher return the value of the environment variable:
68
+
69
+ its('content') { should eq '/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin' }
70
+
71
+ ### split
72
+
73
+ The `split` matcher splits the value of the environment variable with the `:` deliminator (use the `;` deliminator if Windows):
74
+
75
+ its('split') { should include ('/usr/bin') }
76
+
77
+ Note: the `split` matcher returns an array including `""` for cases where there is a trailing colon (`:`), such as `dir1::dir2:`
@@ -6,6 +6,7 @@ title: About the package Resource
6
6
 
7
7
  Use the `package` InSpec audit resource to test if the named package and/or package version is installed on the system.
8
8
 
9
+ <br>
9
10
 
10
11
  ## Syntax
11
12
 
@@ -20,47 +21,13 @@ where
20
21
  * `('name')` must specify the name of a package, such as `'nginx'`
21
22
  * `be_installed` is a valid matcher for this resource
22
23
 
23
- ## Matchers
24
-
25
- This InSpec audit resource has the following matchers:
26
-
27
- ### be
28
-
29
- <%= partial "/shared/matcher_be" %>
30
-
31
- ### be_installed
32
-
33
- The `be_installed` matcher tests if the named package is installed on the system:
34
-
35
- it { should be_installed }
36
-
37
- ### cmp
38
-
39
- <%= partial "/shared/matcher_cmp" %>
40
-
41
- ### eq
42
-
43
- <%= partial "/shared/matcher_eq" %>
44
-
45
- ### include
46
-
47
- <%= partial "/shared/matcher_include" %>
48
-
49
- ### match
50
-
51
- <%= partial "/shared/matcher_match" %>
52
-
53
- ### version
54
-
55
- The `version` matcher tests if the named package version is on the system:
56
-
57
- its('version') { should eq '1.2.3' }
24
+ <br>
58
25
 
59
26
  ## Examples
60
27
 
61
28
  The following examples show how to use this InSpec audit resource.
62
29
 
63
- ### Test if nginx version 1.9.5 is installed
30
+ ### Test if NGINX version 1.9.5 is installed
64
31
 
65
32
  describe package('nginx') do
66
33
  it { should be_installed }
@@ -119,3 +86,34 @@ Memcached is an in-memory key-value store that helps improve the performance of
119
86
  describe port(11_211) do
120
87
  it { should be_listening }
121
88
  end
89
+
90
+ <br>
91
+
92
+ ## Matchers
93
+
94
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
95
+
96
+ ### be_held
97
+
98
+ The `be_held` matcher tests if the named package is "held". On dpkg platforms, a "held" package
99
+ will not be upgraded to a later version.
100
+
101
+ it { should be_held }
102
+
103
+ ### be_installed
104
+
105
+ The `be_installed` matcher tests if the named package is installed on the system:
106
+
107
+ it { should be_installed }
108
+
109
+ ### version
110
+
111
+ The `version` matcher tests if the named package version is on the system:
112
+
113
+ its('version') { should eq '1.2.3' }
114
+
115
+ You can also use the `cmp OPERATOR` matcher to perform comparisions using the version attribute:
116
+
117
+ its('version') { should cmp >= '7.35.0-1ubuntu3.10' }
118
+
119
+ `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.
@@ -6,6 +6,8 @@ title: About the parse_config Resource
6
6
 
7
7
  Use the `parse_config` InSpec audit resource to test arbitrary configuration files.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  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:
@@ -35,9 +37,11 @@ where each test
35
37
  * May run a command to `stdout`, and then run the test against that output
36
38
  * May use options to define how configuration data is to be parsed
37
39
 
40
+ <br>
41
+
38
42
  ## Matchers
39
43
 
40
- This InSpec audit resource has the following matchers:
44
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
41
45
 
42
46
  ### assignment_regex
43
47
 
@@ -49,28 +53,12 @@ may be tested using the following regular expression, which determines assignmen
49
53
 
50
54
  assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
51
55
 
52
- ### be
53
-
54
- <%= partial "/shared/matcher_be" %>
55
-
56
- ### cmp
57
-
58
- <%= partial "/shared/matcher_cmp" %>
59
-
60
56
  ### comment_char
61
57
 
62
58
  Use `comment_char` to test for comments in a configuration file:
63
59
 
64
60
  comment_char: '#'
65
61
 
66
- ### eq
67
-
68
- <%= partial "/shared/matcher_eq" %>
69
-
70
- ### include
71
-
72
- <%= partial "/shared/matcher_include" %>
73
-
74
62
  ### key_values
75
63
 
76
64
  Use `key_values` to test how many values a key contains:
@@ -81,10 +69,6 @@ contains three values. To test that value to ensure it only contains one, use:
81
69
 
82
70
  key_values: 1
83
71
 
84
- ### match
85
-
86
- <%= partial "/shared/matcher_match" %>
87
-
88
72
  ### multiple_values
89
73
 
90
74
  Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
@@ -116,7 +100,3 @@ Use `standalone_comments: false`, to parse the following:
116
100
 
117
101
  'key = value # comment'
118
102
  params['key'] = 'value'
119
-
120
- ## Examples
121
-
122
- None.
@@ -6,6 +6,8 @@ title: About the parse_config_file Resource
6
6
 
7
7
  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.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  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.
@@ -32,6 +34,8 @@ where each test
32
34
  * May run a command to `stdout`, and then run the test against that output
33
35
  * May use options to define how configuration data is to be parsed
34
36
 
37
+ <br>
38
+
35
39
  ## Options
36
40
 
37
41
  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:
@@ -44,9 +48,35 @@ This resource supports the following options for parsing configuration data. Use
44
48
  its('setting') { should eq 1 }
45
49
  end
46
50
 
51
+ <br>
52
+
53
+ ## Examples
54
+
55
+ The following examples show how to use this InSpec audit resource.
56
+
57
+ ### Test a configuration setting
58
+
59
+ describe parse_config_file('/path/to/file.conf') do
60
+ its('PARAM_X') { should eq 'Y' }
61
+ end
62
+
63
+ ### Use options, and then test a configuration setting
64
+
65
+ describe parse_config_file('/path/to/file.conf', { multiple_values: true }) do
66
+ its('PARAM_X') { should include 'Y' }
67
+ end
68
+
69
+ ## Test a file with an ini-like structure (such as a yum.conf)
70
+
71
+ describe parse_config_file('/path/to/yum.conf') do
72
+ its('main') { should include('gpgcheck' => '1') }
73
+ end
74
+
75
+ <br>
76
+
47
77
  ## Matchers
48
78
 
49
- This InSpec audit resource has the following matchers:
79
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
50
80
 
51
81
  ### assignment_regex
52
82
 
@@ -58,28 +88,12 @@ may be tested using the following regular expression, which determines assignmen
58
88
 
59
89
  assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
60
90
 
61
- ### be
62
-
63
- <%= partial "/shared/matcher_be" %>
64
-
65
- ### cmp
66
-
67
- <%= partial "/shared/matcher_cmp" %>
68
-
69
91
  ### comment_char
70
92
 
71
93
  Use `comment_char` to test for comments in a configuration file:
72
94
 
73
95
  comment_char: '#'
74
96
 
75
- ### eq
76
-
77
- <%= partial "/shared/matcher_eq" %>
78
-
79
- ### include
80
-
81
- <%= partial "/shared/matcher_include" %>
82
-
83
97
  ### key_values
84
98
 
85
99
  Use `key_values` to test how many values a key contains:
@@ -90,10 +104,6 @@ contains three values. To test that value to ensure it only contains one, use:
90
104
 
91
105
  key_values: 1
92
106
 
93
- ### match
94
-
95
- <%= partial "/shared/matcher_match" %>
96
-
97
107
  ### multiple_values
98
108
 
99
109
  Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
@@ -125,25 +135,3 @@ Use `standalone_comments: false`, to parse the following:
125
135
 
126
136
  'key = value # comment'
127
137
  params['key'] = 'value'
128
-
129
- ## Examples
130
-
131
- The following examples show how to use this InSpec audit resource.
132
-
133
- ### Test a configuration setting
134
-
135
- describe parse_config_file('/path/to/file.conf') do
136
- its('PARAM_X') { should eq 'Y' }
137
- end
138
-
139
- ### Use options, and then test a configuration setting
140
-
141
- describe parse_config_file('/path/to/file.conf', { multiple_values: true }) do
142
- its('PARAM_X') { should include 'Y' }
143
- end
144
-
145
- ## Test a file with an ini-like structure (such as a yum.conf)
146
-
147
- describe parse_config_file('/path/to/yum.conf') do
148
- its('main') { should include('gpgcheck' => '1') }
149
- end
@@ -18,6 +18,8 @@ These entries are defined as a colon-delimited row in the file, one row per user
18
18
 
19
19
  root:x:1234:5678:additional_info:/home/dir/:/bin/bash
20
20
 
21
+ <br>
22
+
21
23
  ## Syntax
22
24
 
23
25
  A `passwd` resource block declares one (or more) users and associated user information to be tested:
@@ -37,22 +39,36 @@ where
37
39
  * `filter` one (or more) arguments, for example: `passwd.users(/name/)` used to define filtering
38
40
  * `filter` may take any of the following arguments: `count` (retrieves the number of entries), `lines` (provides raw `passwd` lines), and `params` (returns an array of maps for all entries)
39
41
 
42
+ <br>
40
43
 
41
- ## Matchers
44
+ ## Examples
45
+
46
+ The following examples show how to use this InSpec audit resource.
47
+
48
+ ### Test usernames and UIDs
42
49
 
43
- This InSpec audit resource has the following matchers:
50
+ describe passwd do
51
+ its('users') { should eq ['root', 'www-data'] }
52
+ its('uids') { should eq [0, 33] }
53
+ end
44
54
 
45
- ### be
55
+ ### Select one user and test for multiple occurrences
46
56
 
47
- <%= partial "/shared/matcher_be" %>
57
+ describe passwd.uids(0) do
58
+ its('users') { should cmp 'root' }
59
+ its('count') { should eq 1 }
60
+ end
48
61
 
49
- ### cmp
62
+ describe passwd.filter(user: 'www-data') do
63
+ its('uids') { should cmp 33 }
64
+ its('count') { should eq 1 }
65
+ end
50
66
 
51
- <%= partial "/shared/matcher_cmp" %>
67
+ <br>
52
68
 
53
- ### eq
69
+ ## Matchers
54
70
 
55
- <%= partial "/shared/matcher_eq" %>
71
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
56
72
 
57
73
  ### gids
58
74
 
@@ -67,10 +83,6 @@ The `homes` matcher tests the absolute path to a user's home directory:
67
83
 
68
84
  its('home') { should eq '/' }
69
85
 
70
- ### include
71
-
72
- <%= partial "/shared/matcher_include" %>
73
-
74
86
  ### length
75
87
 
76
88
  The `length` matcher tests the length of a password that appears in `/etc/passwd`:
@@ -83,10 +95,6 @@ This matcher is best used in conjunction with filters. For example:
83
95
  its('length') { should_not be < 16 }
84
96
  end
85
97
 
86
- ### match
87
-
88
- <%= partial "/shared/matcher_match" %>
89
-
90
98
  ### passwords
91
99
 
92
100
  The `passwords` matcher tests if passwords are
@@ -130,26 +138,3 @@ or:
130
138
  The `users` matcher tests if the user names in the test match user names in `/etc/passwd`:
131
139
 
132
140
  its('users') { should eq ['root', 'www-data'] }
133
-
134
- ## Examples
135
-
136
- The following examples show how to use this InSpec audit resource.
137
-
138
- ### Test usernames and UIDs
139
-
140
- describe passwd do
141
- its('users') { should eq ['root', 'www-data'] }
142
- its('uids') { should eq [0, 33] }
143
- end
144
-
145
- ### Select one user and test for multiple occurrences
146
-
147
- describe passwd.uids(0) do
148
- its('users') { should cmp 'root' }
149
- its('count') { should eq 1 }
150
- end
151
-
152
- describe passwd.filter(user: 'www-data') do
153
- its('uids') { should cmp 33 }
154
- its('count') { should eq 1 }
155
- end
@@ -6,6 +6,8 @@ title: About the pip Resource
6
6
 
7
7
  Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `pip` resource block declares a package and (optionally) a package version:
@@ -19,56 +21,39 @@ where
19
21
  * `'package_name'` is the name of the package, such as `'Jinja2'`
20
22
  * `be_installed` tests to see if the package described above is installed
21
23
 
24
+ <br>
22
25
 
23
- ## Matchers
24
-
25
- This InSpec audit resource has the following matchers:
26
-
27
- ### be
28
-
29
- <%= partial "/shared/matcher_be" %>
26
+ ## Examples
30
27
 
31
- ### be_installed
28
+ The following examples show how to use this InSpec audit resource.
32
29
 
33
- The `be_installed` matcher tests if the named package is installed on the system:
30
+ ### Test if Jinja2 is installed on the system
34
31
 
35
- it { should be_installed }
32
+ describe pip('Jinja2') do
33
+ it { should be_installed }
34
+ end
36
35
 
37
- ### cmp
36
+ ### Test if Jinja2 2.8 is installed on the system
38
37
 
39
- <%= partial "/shared/matcher_cmp" %>
38
+ describe pip('Jinja2') do
39
+ it { should be_installed }
40
+ its('version') { should eq '2.8' }
41
+ end
40
42
 
41
- ### eq
43
+ <br>
42
44
 
43
- <%= partial "/shared/matcher_eq" %>
45
+ ## Matchers
44
46
 
45
- ### include
47
+ This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
46
48
 
47
- <%= partial "/shared/matcher_include" %>
49
+ ### be_installed
48
50
 
49
- ### match
51
+ The `be_installed` matcher tests if the named package is installed on the system:
50
52
 
51
- <%= partial "/shared/matcher_match" %>
53
+ it { should be_installed }
52
54
 
53
55
  ### version
54
56
 
55
57
  The `version` matcher tests if the named package version is on the system:
56
58
 
57
59
  its('version') { should eq '1.2.3' }
58
-
59
- ## Examples
60
-
61
- The following examples show how to use this InSpec audit resource.
62
-
63
- ### Test if Jinja2 is installed on the system
64
-
65
- describe pip('Jinja2') do
66
- it { should be_installed }
67
- end
68
-
69
- ### Test if Jinja2 2.8 is installed on the system
70
-
71
- describe pip('Jinja2') do
72
- it { should be_installed }
73
- its('version') { should eq '2.8' }
74
- end