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,103 +0,0 @@
1
- ---
2
- title: About the postgres_hba_conf Resource
3
- platform: linux
4
- ---
5
-
6
- # postgres\_hba\_conf
7
-
8
- Use the `postgres_hba_conf` InSpec audit resource to test the client authentication data defined in the pg_hba.conf file.
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.31.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- An `postgres_hba_conf` InSpec audit resource block declares client authentication data that should be tested:
25
-
26
- describe postgres_hba_conf.where { type == 'local' } do
27
- its('auth_method') { should eq ['peer'] }
28
- end
29
-
30
- where
31
-
32
- * `'attribute'` is a attribute in the pg hba configuration file
33
- * `'filter_value'` is the value that is to be filtered for
34
- * `'value'` is the value that is to be matched expected
35
-
36
- <br>
37
-
38
- ## Properties
39
-
40
- 'address', 'auth_method', 'auth_params', 'conf_dir' , 'conf_file' , 'database', 'params' ,'type', 'user'
41
-
42
- <br>
43
-
44
- ## Property Examples
45
-
46
- ### address([String])
47
-
48
- `address` returns a an array of strings that matches the where condition of the filter table
49
-
50
- describe postgres_hba_conf.where { type == 'local' } do
51
- its('address') { should cmp 'value' }
52
- end
53
-
54
- ### auth_method([String])
55
-
56
- `auth_method` returns a an array of strings that matches the where condition of the filter table
57
-
58
- describe postgres_hba_conf.where { type == 'local' } do
59
- its('auth_method') { should cmp 'value' }
60
- end
61
-
62
- ### database([String])
63
-
64
- `database` returns a an array of strings that matches the where condition of the filter table
65
-
66
- describe postgres_hba_conf.where { type == 'local' } do
67
- its('database') { should cmp 'value' }
68
- end
69
-
70
- ### type([String])
71
-
72
- `type` returns a an array of strings that matches the where condition of the filter table
73
-
74
- describe postgres_hba_conf.where { database == 'acme_test_db' } do
75
- its('type') { should cmp 'value' }
76
- end
77
-
78
- ### user([String])
79
-
80
- `user` returns a an array of strings that matches the where condition of the filter table
81
-
82
- describe postgres_hba_conf.where { database == 'acme_test_db' } do
83
- its('user') { should cmp 'value' }
84
- end
85
-
86
- <br>
87
-
88
- ## Matchers
89
-
90
- This InSpec audit resource matches any service that is listed in the HBA configuration file. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
91
-
92
- its('auth_method') { should_not cmp 'peer' }
93
-
94
- or:
95
-
96
- its('auth_method') { should cmp 'peer' }
97
-
98
- For example:
99
-
100
- describe postgres_hba_conf.where { type == 'type' } do
101
- its('auth_method') { should cmp 'value' }
102
- its('user') { should cmp 'value' }
103
- end
@@ -1,86 +0,0 @@
1
- ---
2
- title: About the postgres_ident_conf Resource
3
- platform: linux
4
- ---
5
-
6
- # postgres\_ident\_conf
7
-
8
- Use the `postgres_ident_conf` InSpec audit resource to test the client authentication data defined in the pg_hba.conf file.
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.31.0 of InSpec.
21
-
22
- ## Syntax
23
-
24
- An `postgres_ident_conf` InSpec audit resource block declares client authentication data that should be tested:
25
-
26
- describe postgres_ident_conf.where { pg_username == 'filter_value' } do
27
- its('attribute') { should eq ['value'] }
28
- end
29
-
30
- where
31
-
32
- * `'attribute'` is a attribute in the pg ident configuration file
33
- * `'filter_value'` is the value that is to be filtered for
34
- * `'value'` is the value that is to be matched expected
35
-
36
- <br>
37
-
38
- ## Properties
39
-
40
- 'conf_file', 'map_name', 'params', 'pg_username', 'system_username'
41
-
42
- <br>
43
-
44
- ## Property Examples
45
-
46
- ### map_name([String])
47
-
48
- `address` returns a an array of strings that matches the where condition of the filter table
49
-
50
- describe pg_hba_conf.where { pg_username == 'name' } do
51
- its('map_name') { should eq ['value'] }
52
- end
53
- ### pg_username([String])
54
-
55
- `pg_username` returns a an array of strings that matches the where condition of the filter table
56
-
57
- describe pg_hba_conf.where { pg_username == 'name' } do
58
- its('pg_username') { should eq ['value'] }
59
- end
60
-
61
- ### system_username([String])
62
-
63
- `system_username` returns a an array of strings that matches the where condition of the filter table
64
-
65
- describe pg_hba_conf.where { pg_username == 'name' } do
66
- its('system_username') { should eq ['value'] }
67
- end
68
-
69
- <br>
70
-
71
- ## Matchers
72
-
73
- This InSpec audit resource matches any service that is listed in the pg ident configuration file. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
74
-
75
- its('pg_username') { should_not eq ['peer'] }
76
-
77
- or:
78
-
79
- its('map_name') { should eq ['value'] }
80
-
81
- For example:
82
-
83
- describe postgres_ident_conf.where { pg_username == 'name' } do
84
- its('system_username') { should eq ['value'] }
85
- its('map_name') { should eq ['value'] }
86
- end
@@ -1,79 +0,0 @@
1
- ---
2
- title: About the postgres_session Resource
3
- platform: os
4
- ---
5
-
6
- # postgres_session
7
-
8
- Use the `postgres_session` InSpec audit resource to test SQL commands run against a PostgreSQL database.
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 `postgres_session` resource block declares the username and password to use for the session, and then the command to be run:
25
-
26
- # Create a PostgreSQL session:
27
- sql = postgres_session('username', 'password', 'host')
28
-
29
- # default values:
30
- # username: 'postgres'
31
- # host: 'localhost'
32
-
33
- # Run an SQL query with an optional database to execute
34
- sql.query('sql_query', ['database_name'])`
35
-
36
- A full example is:
37
-
38
- sql = postgres_session('username', 'password', 'host')
39
- describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;') do
40
- its('output') { should eq '' }
41
- end
42
-
43
- where `its('output') { should eq '' }` compares the results of the query against the expected result in the test
44
-
45
- <br>
46
-
47
- ## Examples
48
-
49
- The following examples show how to use this InSpec audit resource.
50
-
51
- ### Test the PostgreSQL shadow password
52
-
53
- sql = postgres_session('my_user', 'password', '192.168.1.2')
54
-
55
- describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;', ['testdb']) do
56
- its('output') { should eq('') }
57
- end
58
-
59
- ### Test for risky database entries
60
-
61
- describe postgres_session('my_user', 'password').query('SELECT count (*)
62
- FROM pg_language
63
- WHERE lanpltrusted = \'f\'
64
- AND lanname!=\'internal\'
65
- AND lanname!=\'c\';', ['postgres']) do
66
- its('output') { should eq '0' }
67
- end
68
-
69
- <br>
70
-
71
- ## Matchers
72
-
73
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
74
-
75
- ### output
76
-
77
- The `output` matcher tests the results of the query:
78
-
79
- its('output') { should eq(/^0/) }
@@ -1,112 +0,0 @@
1
- ---
2
- title: About the powershell Resource
3
- platform: windows
4
- ---
5
-
6
- # powershell
7
-
8
- Use the `powershell` InSpec audit resource to test a Powershell script on the Windows platform.
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 `powershell` resource block declares a Powershell script to be tested, and then compares the output of that command to the matcher in the test:
25
-
26
- script = <<-EOH
27
- # a PowerShell script
28
- EOH
29
-
30
- describe powershell(script) do
31
- its('property') { should eq 'output' }
32
- end
33
-
34
- where
35
-
36
- * `'script'` must specify a Powershell script to be run
37
- * `'matcher'` is one of `exit_status`, `stderr`, or `stdout`
38
- * `'output'` tests the output of the command run on the system versus the output value stated in the test
39
-
40
- <br>
41
-
42
- ## Examples
43
-
44
- The following examples show how to use this InSpec audit resource.
45
-
46
- ### Get all groups of Administrator user
47
-
48
- script = <<-EOH
49
- # find user
50
- $user = Get-WmiObject Win32_UserAccount -filter "Name = 'Administrator'"
51
- # get related groups
52
- $groups = $user.GetRelated('Win32_Group') | Select-Object -Property Caption, Domain, Name, LocalAccount, SID, SIDType, Status
53
- $groups | ConvertTo-Json
54
- EOH
55
-
56
- describe powershell(script) do
57
- its('stdout') { should_not eq '' }
58
- end
59
-
60
- ### Write-Output 'hello'
61
-
62
- The following Powershell script:
63
-
64
- script = <<-EOH
65
- Write-Output 'hello'
66
- EOH
67
-
68
- can be tested in the following ways.
69
-
70
- For a newline:
71
-
72
- describe powershell(script) do
73
- its('stdout') { should eq "hello\r\n" }
74
- its('stderr') { should eq '' }
75
- end
76
-
77
- Removing whitespace `\r\n` from `stdout`:
78
-
79
- describe powershell(script) do
80
- its('strip') { should eq "hello" }
81
- end
82
-
83
- No newline:
84
-
85
- describe powershell("'hello' | Write-Host -NoNewLine") do
86
- its('stdout') { should eq 'hello' }
87
- its('stderr') { should eq '' }
88
- end
89
-
90
- <br>
91
-
92
- ## Matchers
93
-
94
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
95
-
96
- ### exit_status
97
-
98
- The `exit_status` matcher tests the exit status for the command:
99
-
100
- its('exit_status') { should eq 123 }
101
-
102
- ### stderr
103
-
104
- The `stderr` matcher tests results of the command as returned in standard error (stderr):
105
-
106
- its('stderr') { should eq 'error' }
107
-
108
- ### stdout
109
-
110
- The `stdout` matcher tests results of the command as returned in standard output (stdout):
111
-
112
- its('stdout') { should eq '/^1$/' }
@@ -1,119 +0,0 @@
1
- ---
2
- title: About the processes Resource
3
- platform: os
4
- ---
5
-
6
- # processes
7
-
8
- Use the `processes` InSpec audit resource to test properties for programs that are running 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 `processes` resource block declares the name of the process to be tested, and then declares one (or more) property/value pairs:
25
-
26
- describe processes('process_name') do
27
- its('property_name') { should eq ['property_value'] }
28
- end
29
-
30
- where
31
-
32
- * `processes('process_name')` specifies the name of a process to check. If this is a string, it will be converted to a Regexp. For more specificity, pass a Regexp directly. If left blank, all processes will be returned.
33
- * `property_name` may be used to test user (`its('users')`) and state properties (`its('states')`)
34
-
35
- <br>
36
-
37
- ## Examples
38
-
39
- The following examples show how to use this InSpec audit resource.
40
-
41
- ### Test if the list length for the mysqld process is 1
42
-
43
- describe processes('mysqld') do
44
- its('list.length') { should eq 1 }
45
- end
46
-
47
- ### Test if the process is owned by a specific user
48
-
49
- describe processes('init') do
50
- its('users') { should eq ['root'] }
51
- end
52
-
53
- describe processes('winlogon') do
54
- its('users') { should cmp "NT AUTHORITY\\SYSTEM" }
55
- end
56
-
57
-
58
- ### Test if a high-priority process is running
59
-
60
- describe processes('linux_process') do
61
- its('states') { should eq ['R<'] }
62
- end
63
-
64
- describe processes('windows_process') do
65
- its('labels') { should cmp "High" }
66
- end
67
-
68
- ### Test if a process exists on the system
69
-
70
- describe processes('some_process') do
71
- it { should exist }
72
- end
73
-
74
- ### Test for a process using a specific Regexp
75
-
76
- If the process name is too common for a string to uniquely find it,
77
- you may use a regexp. Inclusion of whitespace characters may be
78
- needed.
79
-
80
- describe processes(Regexp.new("/usr/local/bin/swap -d")) do
81
- its('list.length') { should eq 1 }
82
- end
83
-
84
- ### Notes for auditing Windows systems
85
-
86
- Sometimes with system properties there isn't a direct comparison between different operating systems.
87
- Most of the `property_name`'s do align between the different OS's.
88
-
89
- There are however some exception's, for example, within linux `states` offers multiple properties.
90
- Windows doesn't have direct comparison that is a single property so instead `states` is mapped to the property of `Responding`, This is a boolean true/false flag to help determine if the process is hung.
91
-
92
- Below is a mapping table to help you understand what property the unix field maps to the windows `Get-Process` Property
93
-
94
- | *unix ps field* | *windows PowerShell Property* |
95
- |:---------------:|:-----------------------------:|
96
- |labels |PriorityClass|
97
- |pids |Id|
98
- |cpus |CPU|
99
- |mem |PM|
100
- |vsz |VirtualMemorySize|
101
- |rss |NPM|
102
- |tty |SessionId|
103
- |states |Responding|
104
- |start |StartTime|
105
- |time |TotalProcessorTime|
106
- |users |UserName|
107
- |commands |Path|
108
-
109
- <br>
110
-
111
- ## Matchers
112
-
113
- For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
114
-
115
- ### property_name
116
-
117
- The `property_name` matcher tests the named property for the specified value:
118
-
119
- its('property_name') { should eq ['property_value'] }