inspec 4.18.51 → 4.18.85

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. checksums.yaml +4 -4
  2. data/inspec.gemspec +15 -37
  3. data/lib/resource_support/aws/aws_resource_mixin.rb +1 -1
  4. metadata +22 -709
  5. data/Gemfile +0 -61
  6. data/LICENSE +0 -14
  7. data/README.md +0 -474
  8. data/etc/deprecations.json +0 -125
  9. data/etc/plugin_filters.json +0 -45
  10. data/lib/bundles/README.md +0 -3
  11. data/lib/bundles/inspec-compliance/api.rb +0 -7
  12. data/lib/bundles/inspec-compliance/configuration.rb +0 -7
  13. data/lib/bundles/inspec-compliance/http.rb +0 -7
  14. data/lib/bundles/inspec-compliance/support.rb +0 -7
  15. data/lib/bundles/inspec-compliance/target.rb +0 -7
  16. data/lib/bundles/inspec-supermarket.rb +0 -9
  17. data/lib/bundles/inspec-supermarket/README.md +0 -45
  18. data/lib/bundles/inspec-supermarket/api.rb +0 -87
  19. data/lib/bundles/inspec-supermarket/cli.rb +0 -71
  20. data/lib/bundles/inspec-supermarket/target.rb +0 -31
  21. data/lib/inspec.rb +0 -30
  22. data/lib/inspec/archive/tar.rb +0 -25
  23. data/lib/inspec/archive/zip.rb +0 -15
  24. data/lib/inspec/backend.rb +0 -101
  25. data/lib/inspec/base_cli.rb +0 -318
  26. data/lib/inspec/cached_fetcher.rb +0 -65
  27. data/lib/inspec/cli.rb +0 -469
  28. data/lib/inspec/completions/bash.sh.erb +0 -45
  29. data/lib/inspec/completions/fish.sh.erb +0 -34
  30. data/lib/inspec/completions/zsh.sh.erb +0 -61
  31. data/lib/inspec/config.rb +0 -511
  32. data/lib/inspec/control_eval_context.rb +0 -248
  33. data/lib/inspec/dependencies/cache.rb +0 -74
  34. data/lib/inspec/dependencies/dependency_set.rb +0 -93
  35. data/lib/inspec/dependencies/lockfile.rb +0 -115
  36. data/lib/inspec/dependencies/requirement.rb +0 -135
  37. data/lib/inspec/dependencies/resolver.rb +0 -86
  38. data/lib/inspec/describe_base.rb +0 -53
  39. data/lib/inspec/dist.rb +0 -20
  40. data/lib/inspec/dsl.rb +0 -115
  41. data/lib/inspec/dsl_shared.rb +0 -32
  42. data/lib/inspec/env_printer.rb +0 -156
  43. data/lib/inspec/errors.rb +0 -18
  44. data/lib/inspec/exceptions.rb +0 -11
  45. data/lib/inspec/expect.rb +0 -42
  46. data/lib/inspec/fetcher.rb +0 -48
  47. data/lib/inspec/fetcher/git.rb +0 -211
  48. data/lib/inspec/fetcher/local.rb +0 -116
  49. data/lib/inspec/fetcher/mock.rb +0 -34
  50. data/lib/inspec/fetcher/url.rb +0 -281
  51. data/lib/inspec/file_provider.rb +0 -318
  52. data/lib/inspec/formatters.rb +0 -3
  53. data/lib/inspec/formatters/base.rb +0 -269
  54. data/lib/inspec/formatters/json_rspec.rb +0 -20
  55. data/lib/inspec/formatters/show_progress.rb +0 -12
  56. data/lib/inspec/globals.rb +0 -9
  57. data/lib/inspec/impact.rb +0 -36
  58. data/lib/inspec/input.rb +0 -421
  59. data/lib/inspec/input_dsl_helpers.rb +0 -26
  60. data/lib/inspec/input_registry.rb +0 -315
  61. data/lib/inspec/library_eval_context.rb +0 -55
  62. data/lib/inspec/log.rb +0 -7
  63. data/lib/inspec/metadata.rb +0 -253
  64. data/lib/inspec/method_source.rb +0 -20
  65. data/lib/inspec/objects.rb +0 -14
  66. data/lib/inspec/objects/control.rb +0 -85
  67. data/lib/inspec/objects/describe.rb +0 -106
  68. data/lib/inspec/objects/each_loop.rb +0 -41
  69. data/lib/inspec/objects/input.rb +0 -49
  70. data/lib/inspec/objects/list.rb +0 -15
  71. data/lib/inspec/objects/or_test.rb +0 -45
  72. data/lib/inspec/objects/ruby_helper.rb +0 -13
  73. data/lib/inspec/objects/tag.rb +0 -32
  74. data/lib/inspec/objects/test.rb +0 -94
  75. data/lib/inspec/objects/value.rb +0 -32
  76. data/lib/inspec/plugin/v1.rb +0 -2
  77. data/lib/inspec/plugin/v1/plugin_types/cli.rb +0 -22
  78. data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +0 -83
  79. data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
  80. data/lib/inspec/plugin/v1/plugin_types/secret.rb +0 -11
  81. data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +0 -36
  82. data/lib/inspec/plugin/v1/plugins.rb +0 -59
  83. data/lib/inspec/plugin/v1/registry.rb +0 -90
  84. data/lib/inspec/plugin/v2.rb +0 -46
  85. data/lib/inspec/plugin/v2/activator.rb +0 -40
  86. data/lib/inspec/plugin/v2/config_file.rb +0 -151
  87. data/lib/inspec/plugin/v2/filter.rb +0 -96
  88. data/lib/inspec/plugin/v2/installer.rb +0 -512
  89. data/lib/inspec/plugin/v2/loader.rb +0 -321
  90. data/lib/inspec/plugin/v2/plugin_base.rb +0 -112
  91. data/lib/inspec/plugin/v2/plugin_types/cli.rb +0 -49
  92. data/lib/inspec/plugin/v2/plugin_types/dsl.rb +0 -11
  93. data/lib/inspec/plugin/v2/plugin_types/input.rb +0 -34
  94. data/lib/inspec/plugin/v2/plugin_types/mock.rb +0 -12
  95. data/lib/inspec/plugin/v2/registry.rb +0 -98
  96. data/lib/inspec/plugin/v2/status.rb +0 -29
  97. data/lib/inspec/profile.rb +0 -658
  98. data/lib/inspec/profile_context.rb +0 -203
  99. data/lib/inspec/profile_vendor.rb +0 -84
  100. data/lib/inspec/reporters.rb +0 -73
  101. data/lib/inspec/reporters/automate.rb +0 -78
  102. data/lib/inspec/reporters/base.rb +0 -25
  103. data/lib/inspec/reporters/cli.rb +0 -370
  104. data/lib/inspec/reporters/json.rb +0 -113
  105. data/lib/inspec/reporters/json_automate.rb +0 -80
  106. data/lib/inspec/reporters/json_min.rb +0 -48
  107. data/lib/inspec/reporters/junit.rb +0 -77
  108. data/lib/inspec/reporters/yaml.rb +0 -20
  109. data/lib/inspec/require_loader.rb +0 -29
  110. data/lib/inspec/resource.rb +0 -114
  111. data/lib/inspec/resources.rb +0 -130
  112. data/lib/inspec/resources/aide_conf.rb +0 -153
  113. data/lib/inspec/resources/apache.rb +0 -47
  114. data/lib/inspec/resources/apache_conf.rb +0 -156
  115. data/lib/inspec/resources/apt.rb +0 -151
  116. data/lib/inspec/resources/audit_policy.rb +0 -64
  117. data/lib/inspec/resources/auditd.rb +0 -251
  118. data/lib/inspec/resources/auditd_conf.rb +0 -45
  119. data/lib/inspec/resources/bash.rb +0 -33
  120. data/lib/inspec/resources/bond.rb +0 -70
  121. data/lib/inspec/resources/bridge.rb +0 -125
  122. data/lib/inspec/resources/bsd_service.rb +0 -2
  123. data/lib/inspec/resources/chocolatey_package.rb +0 -82
  124. data/lib/inspec/resources/command.rb +0 -91
  125. data/lib/inspec/resources/cpan.rb +0 -58
  126. data/lib/inspec/resources/cran.rb +0 -64
  127. data/lib/inspec/resources/crontab.rb +0 -173
  128. data/lib/inspec/resources/csv.rb +0 -56
  129. data/lib/inspec/resources/dh_params.rb +0 -83
  130. data/lib/inspec/resources/directory.rb +0 -23
  131. data/lib/inspec/resources/docker.rb +0 -274
  132. data/lib/inspec/resources/docker_container.rb +0 -91
  133. data/lib/inspec/resources/docker_image.rb +0 -84
  134. data/lib/inspec/resources/docker_object.rb +0 -52
  135. data/lib/inspec/resources/docker_plugin.rb +0 -64
  136. data/lib/inspec/resources/docker_service.rb +0 -91
  137. data/lib/inspec/resources/elasticsearch.rb +0 -165
  138. data/lib/inspec/resources/etc_fstab.rb +0 -96
  139. data/lib/inspec/resources/etc_group.rb +0 -157
  140. data/lib/inspec/resources/etc_hosts.rb +0 -68
  141. data/lib/inspec/resources/etc_hosts_allow.rb +0 -2
  142. data/lib/inspec/resources/etc_hosts_allow_deny.rb +0 -114
  143. data/lib/inspec/resources/etc_hosts_deny.rb +0 -2
  144. data/lib/inspec/resources/file.rb +0 -339
  145. data/lib/inspec/resources/filesystem.rb +0 -139
  146. data/lib/inspec/resources/firewalld.rb +0 -148
  147. data/lib/inspec/resources/gem.rb +0 -80
  148. data/lib/inspec/resources/group.rb +0 -2
  149. data/lib/inspec/resources/groups.rb +0 -241
  150. data/lib/inspec/resources/grub_conf.rb +0 -230
  151. data/lib/inspec/resources/host.rb +0 -310
  152. data/lib/inspec/resources/http.rb +0 -275
  153. data/lib/inspec/resources/iis_app.rb +0 -101
  154. data/lib/inspec/resources/iis_app_pool.rb +0 -127
  155. data/lib/inspec/resources/iis_site.rb +0 -148
  156. data/lib/inspec/resources/iis_website.rb +0 -2
  157. data/lib/inspec/resources/inetd_conf.rb +0 -53
  158. data/lib/inspec/resources/ini.rb +0 -28
  159. data/lib/inspec/resources/interface.rb +0 -204
  160. data/lib/inspec/resources/ip6tables.rb +0 -79
  161. data/lib/inspec/resources/iptables.rb +0 -80
  162. data/lib/inspec/resources/json.rb +0 -116
  163. data/lib/inspec/resources/kernel_module.rb +0 -106
  164. data/lib/inspec/resources/kernel_parameter.rb +0 -54
  165. data/lib/inspec/resources/key_rsa.rb +0 -66
  166. data/lib/inspec/resources/ksh.rb +0 -33
  167. data/lib/inspec/resources/launchd_service.rb +0 -2
  168. data/lib/inspec/resources/limits_conf.rb +0 -45
  169. data/lib/inspec/resources/linux_kernel_parameter.rb +0 -2
  170. data/lib/inspec/resources/login_defs.rb +0 -56
  171. data/lib/inspec/resources/mount.rb +0 -88
  172. data/lib/inspec/resources/mssql_session.rb +0 -117
  173. data/lib/inspec/resources/mysql.rb +0 -81
  174. data/lib/inspec/resources/mysql_conf.rb +0 -128
  175. data/lib/inspec/resources/mysql_session.rb +0 -88
  176. data/lib/inspec/resources/nginx.rb +0 -96
  177. data/lib/inspec/resources/nginx_conf.rb +0 -232
  178. data/lib/inspec/resources/noop.rb +0 -9
  179. data/lib/inspec/resources/npm.rb +0 -68
  180. data/lib/inspec/resources/ntp_conf.rb +0 -51
  181. data/lib/inspec/resources/oneget.rb +0 -71
  182. data/lib/inspec/resources/oracledb_session.rb +0 -149
  183. data/lib/inspec/resources/os.rb +0 -34
  184. data/lib/inspec/resources/os_env.rb +0 -86
  185. data/lib/inspec/resources/package.rb +0 -391
  186. data/lib/inspec/resources/packages.rb +0 -111
  187. data/lib/inspec/resources/parse_config.rb +0 -112
  188. data/lib/inspec/resources/parse_config_file.rb +0 -2
  189. data/lib/inspec/resources/passwd.rb +0 -73
  190. data/lib/inspec/resources/pip.rb +0 -132
  191. data/lib/inspec/resources/platform.rb +0 -112
  192. data/lib/inspec/resources/port.rb +0 -791
  193. data/lib/inspec/resources/postfix_conf.rb +0 -35
  194. data/lib/inspec/resources/postgres.rb +0 -152
  195. data/lib/inspec/resources/postgres_conf.rb +0 -116
  196. data/lib/inspec/resources/postgres_hba_conf.rb +0 -86
  197. data/lib/inspec/resources/postgres_ident_conf.rb +0 -75
  198. data/lib/inspec/resources/postgres_session.rb +0 -70
  199. data/lib/inspec/resources/powershell.rb +0 -67
  200. data/lib/inspec/resources/ppa.rb +0 -2
  201. data/lib/inspec/resources/processes.rb +0 -219
  202. data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
  203. data/lib/inspec/resources/rabbitmq_config.rb +0 -52
  204. data/lib/inspec/resources/registry_key.rb +0 -296
  205. data/lib/inspec/resources/runit_service.rb +0 -2
  206. data/lib/inspec/resources/script.rb +0 -1
  207. data/lib/inspec/resources/security_identifier.rb +0 -91
  208. data/lib/inspec/resources/security_policy.rb +0 -182
  209. data/lib/inspec/resources/service.rb +0 -820
  210. data/lib/inspec/resources/shadow.rb +0 -150
  211. data/lib/inspec/resources/ssh_config.rb +0 -98
  212. data/lib/inspec/resources/sshd_config.rb +0 -2
  213. data/lib/inspec/resources/ssl.rb +0 -99
  214. data/lib/inspec/resources/sys_info.rb +0 -119
  215. data/lib/inspec/resources/systemd_service.rb +0 -2
  216. data/lib/inspec/resources/sysv_service.rb +0 -2
  217. data/lib/inspec/resources/toml.rb +0 -30
  218. data/lib/inspec/resources/upstart_service.rb +0 -2
  219. data/lib/inspec/resources/user.rb +0 -1
  220. data/lib/inspec/resources/users.rb +0 -742
  221. data/lib/inspec/resources/vbscript.rb +0 -67
  222. data/lib/inspec/resources/virtualization.rb +0 -255
  223. data/lib/inspec/resources/windows_feature.rb +0 -126
  224. data/lib/inspec/resources/windows_hotfix.rb +0 -37
  225. data/lib/inspec/resources/windows_registry_key.rb +0 -2
  226. data/lib/inspec/resources/windows_task.rb +0 -112
  227. data/lib/inspec/resources/wmi.rb +0 -109
  228. data/lib/inspec/resources/x509_certificate.rb +0 -143
  229. data/lib/inspec/resources/xinetd_conf.rb +0 -103
  230. data/lib/inspec/resources/xml.rb +0 -48
  231. data/lib/inspec/resources/yaml.rb +0 -42
  232. data/lib/inspec/resources/yum.rb +0 -162
  233. data/lib/inspec/resources/zfs_dataset.rb +0 -62
  234. data/lib/inspec/resources/zfs_pool.rb +0 -50
  235. data/lib/inspec/rspec_extensions.rb +0 -116
  236. data/lib/inspec/rule.rb +0 -389
  237. data/lib/inspec/runner.rb +0 -333
  238. data/lib/inspec/runner_mock.rb +0 -37
  239. data/lib/inspec/runner_rspec.rb +0 -184
  240. data/lib/inspec/runtime_profile.rb +0 -23
  241. data/lib/inspec/schema.rb +0 -245
  242. data/lib/inspec/secrets.rb +0 -15
  243. data/lib/inspec/secrets/yaml.rb +0 -29
  244. data/lib/inspec/shell.rb +0 -211
  245. data/lib/inspec/shell_detector.rb +0 -89
  246. data/lib/inspec/source_reader.rb +0 -26
  247. data/lib/inspec/ui.rb +0 -213
  248. data/lib/inspec/ui_table_helper.rb +0 -12
  249. data/lib/inspec/utils/command_wrapper.rb +0 -23
  250. data/lib/inspec/utils/convert.rb +0 -8
  251. data/lib/inspec/utils/database_helpers.rb +0 -75
  252. data/lib/inspec/utils/deprecation.rb +0 -6
  253. data/lib/inspec/utils/deprecation/config_file.rb +0 -109
  254. data/lib/inspec/utils/deprecation/deprecator.rb +0 -118
  255. data/lib/inspec/utils/deprecation/errors.rb +0 -14
  256. data/lib/inspec/utils/deprecation/global_method.rb +0 -9
  257. data/lib/inspec/utils/enumerable_delegation.rb +0 -7
  258. data/lib/inspec/utils/erlang_parser.rb +0 -190
  259. data/lib/inspec/utils/file_reader.rb +0 -24
  260. data/lib/inspec/utils/filter.rb +0 -461
  261. data/lib/inspec/utils/filter_array.rb +0 -25
  262. data/lib/inspec/utils/find_files.rb +0 -44
  263. data/lib/inspec/utils/hash.rb +0 -37
  264. data/lib/inspec/utils/json_log.rb +0 -15
  265. data/lib/inspec/utils/modulator.rb +0 -9
  266. data/lib/inspec/utils/nginx_parser.rb +0 -101
  267. data/lib/inspec/utils/object_traversal.rb +0 -47
  268. data/lib/inspec/utils/parser.rb +0 -277
  269. data/lib/inspec/utils/pkey_reader.rb +0 -17
  270. data/lib/inspec/utils/simpleconfig.rb +0 -121
  271. data/lib/inspec/utils/spdx.rb +0 -10
  272. data/lib/inspec/utils/spdx.txt +0 -383
  273. data/lib/inspec/utils/telemetry.rb +0 -3
  274. data/lib/inspec/utils/telemetry/collector.rb +0 -81
  275. data/lib/inspec/utils/telemetry/data_series.rb +0 -44
  276. data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
  277. data/lib/inspec/version.rb +0 -3
  278. data/lib/matchers/matchers.rb +0 -341
  279. data/lib/plugins/README.md +0 -16
  280. data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +0 -12
  281. data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +0 -170
  282. data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +0 -116
  283. data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -50
  284. data/lib/plugins/inspec-compliance/README.md +0 -207
  285. data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +0 -12
  286. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +0 -362
  287. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +0 -198
  288. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +0 -269
  289. data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +0 -103
  290. data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +0 -117
  291. data/lib/plugins/inspec-compliance/lib/inspec-compliance/images/cc-token.png +0 -0
  292. data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +0 -34
  293. data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +0 -146
  294. data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -53
  295. data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -91
  296. data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
  297. data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -386
  298. data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
  299. data/lib/plugins/inspec-habitat/Berksfile +0 -5
  300. data/lib/plugins/inspec-habitat/README.md +0 -150
  301. data/lib/plugins/inspec-habitat/kitchen.yml +0 -28
  302. data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +0 -11
  303. data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +0 -41
  304. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -265
  305. data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +0 -6
  306. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
  307. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
  308. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
  309. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
  310. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
  311. data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -34
  312. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
  313. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
  314. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
  315. data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
  316. data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
  317. data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
  318. data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -242
  319. data/lib/plugins/inspec-init/README.md +0 -31
  320. data/lib/plugins/inspec-init/lib/inspec-init.rb +0 -12
  321. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +0 -15
  322. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +0 -243
  323. data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +0 -47
  324. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +0 -97
  325. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -11
  326. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE +0 -2
  327. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/README.md +0 -28
  328. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Rakefile +0 -40
  329. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -14
  330. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -62
  331. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -53
  332. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -8
  333. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
  334. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
  335. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
  336. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -24
  337. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
  338. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
  339. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
  340. data/lib/plugins/inspec-init/templates/profiles/aws/libraries/.gitkeep +0 -0
  341. data/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep +0 -0
  342. data/lib/plugins/inspec-init/templates/profiles/gcp/libraries/.gitkeep +0 -0
  343. data/lib/plugins/inspec-init/templates/profiles/os/README.md +0 -3
  344. data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +0 -18
  345. data/lib/plugins/inspec-init/templates/profiles/os/inspec.yml +0 -10
  346. data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
  347. data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -184
  348. data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -121
  349. data/lib/plugins/inspec-plugin-manager-cli/README.md +0 -6
  350. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +0 -17
  351. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +0 -518
  352. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +0 -12
  353. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
  354. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
  355. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
  356. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
  357. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
  358. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
  359. data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +0 -23
  360. data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +0 -62
  361. data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +0 -368
  362. data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +0 -101
  363. data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +0 -129
  364. data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +0 -63
  365. data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +0 -84
  366. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -77
  367. data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -39
  368. data/lib/plugins/shared/core_plugin_test_helper.rb +0 -153
  369. data/lib/plugins/things-for-train-integration.rb +0 -14
  370. data/lib/source_readers/flat.rb +0 -36
  371. data/lib/source_readers/inspec.rb +0 -66
@@ -1,51 +0,0 @@
1
- # copyright: 2015, Vulcano Security GmbH
2
-
3
- require "inspec/utils/simpleconfig"
4
- require "inspec/utils/file_reader"
5
-
6
- module Inspec::Resources
7
- class NtpConf < Inspec.resource(1)
8
- name "ntp_conf"
9
- supports platform: "unix"
10
- desc "Use the ntp_conf InSpec audit resource to test the synchronization settings defined in the ntp.conf file. This file is typically located at /etc/ntp.conf."
11
- example <<~EXAMPLE
12
- describe ntp_conf do
13
- its('server') { should_not eq nil }
14
- its('restrict') { should include '-4 default kod notrap nomodify nopeer noquery'}
15
- end
16
- EXAMPLE
17
-
18
- include FileReader
19
-
20
- def initialize(path = nil)
21
- @conf_path = path || "/etc/ntp.conf"
22
- @content = read_file_content(@conf_path)
23
- end
24
-
25
- def method_missing(name)
26
- param = read_params[name.to_s]
27
- # extract first value if we have only one value in array
28
- return param[0] if param.is_a?(Array) && (param.length == 1)
29
-
30
- param
31
- end
32
-
33
- def to_s
34
- "ntp.conf"
35
- end
36
-
37
- private
38
-
39
- def read_params
40
- return @params if defined?(@params)
41
-
42
- # parse the file
43
- conf = SimpleConfig.new(
44
- @content,
45
- assignment_regex: /^\s*(\S+)\s+(.*)\s*$/,
46
- multiple_values: true
47
- )
48
- @params = conf.params
49
- end
50
- end
51
- end
@@ -1,71 +0,0 @@
1
- require "inspec/resources/command"
2
-
3
- # This resource talks with OneGet (https://github.com/OneGet/oneget)
4
- # Its part of Windows Management Framework 5.0 and part of Windows 10
5
- #
6
- # Usage:
7
- # describe oneget('zoomit') do
8
- # it { should be_installed }
9
- # end
10
- module Inspec::Resources
11
- class OneGetPackage < Inspec.resource(1)
12
- name "oneget"
13
- supports platform: "windows"
14
- desc "Use the oneget InSpec audit resource to test if the named package and/or package version is installed on the system. This resource uses OneGet, which is part of the Windows Management Framework 5.0 and Windows 10. This resource uses the Get-Package cmdlet to return all of the package names in the OneGet repository."
15
- example <<~EXAMPLE
16
- describe oneget('zoomit') do
17
- it { should be_installed }
18
- its('version') { should eq '1.2.3' }
19
- end
20
- EXAMPLE
21
-
22
- def initialize(package_name)
23
- @package_name = package_name
24
-
25
- # verify that this resource is only supported on Windows
26
- return skip_resource "The `oneget` resource is not supported on your OS." unless inspec.os.windows?
27
- end
28
-
29
- def info
30
- return @info if defined?(@info)
31
-
32
- @info = {}
33
- @info[:type] = "oneget"
34
- @info[:installed] = false
35
-
36
- cmd = inspec.command("Get-Package -Name '#{@package_name}' | ConvertTo-Json")
37
- # cannot rely on exit code for now, successful command returns exit code 1
38
- # return nil if cmd.exit_status != 0
39
- # try to parse json
40
-
41
- begin
42
- pkgs = JSON.parse(cmd.stdout)
43
- @info[:installed] = true
44
-
45
- # sometimes we get multiple values
46
- if pkgs.is_a?(Array)
47
- # select the first entry
48
- pkgs = pkgs.first
49
- end
50
- rescue JSON::ParserError => _e
51
- return @info
52
- end
53
-
54
- @info[:name] = pkgs["Name"] if pkgs.key?("Name")
55
- @info[:version] = pkgs["Version"] if pkgs.key?("Version")
56
- @info
57
- end
58
-
59
- def installed?
60
- info[:installed] == true
61
- end
62
-
63
- def version
64
- info[:version]
65
- end
66
-
67
- def to_s
68
- "OneGet Package #{@package_name}"
69
- end
70
- end
71
- end
@@ -1,149 +0,0 @@
1
- require "inspec/resources/command"
2
- require "inspec/utils/database_helpers"
3
- require "htmlentities"
4
- require "rexml/document"
5
- require "hashie/mash"
6
- require "csv"
7
-
8
- module Inspec::Resources
9
- # STABILITY: Experimental
10
- # This resource needs further testing and refinement
11
- #
12
- class OracledbSession < Inspec.resource(1)
13
- name "oracledb_session"
14
- supports platform: "unix"
15
- supports platform: "windows"
16
- desc "Use the oracledb_session InSpec resource to test commands against an Oracle database"
17
- example <<~EXAMPLE
18
- sql = oracledb_session(user: 'my_user', pass: 'password')
19
- describe sql.query(\"SELECT UPPER(VALUE) AS VALUE FROM V$PARAMETER WHERE UPPER(NAME)='AUDIT_SYS_OPERATIONS'\").row(0).column('value') do
20
- its('value') { should eq 'TRUE' }
21
- end
22
- EXAMPLE
23
-
24
- attr_reader :bin, :db_role, :host, :password, :port, :service,
25
- :su_user, :user
26
-
27
- def initialize(opts = {})
28
- @user = opts[:user]
29
- @password = opts[:password] || opts[:pass]
30
- if opts[:pass]
31
- Inspec.deprecate(:oracledb_session_pass_option, "The oracledb_session `pass` option is deprecated. Please use `password`.")
32
- end
33
-
34
- @bin = "sqlplus"
35
- @host = opts[:host] || "localhost"
36
- @port = opts[:port] || "1521"
37
- @service = opts[:service]
38
- @su_user = opts[:as_os_user]
39
- @db_role = opts[:as_db_role]
40
- @sqlcl_bin = opts[:sqlcl_bin] || nil
41
- @sqlplus_bin = opts[:sqlplus_bin] || "sqlplus"
42
- skip_resource "Option 'as_os_user' not available in Windows" if inspec.os.windows? && su_user
43
- fail_resource "Can't run Oracle checks without authentication" unless su_user && (user || password)
44
- fail_resource "You must provide a service name for the session" unless service
45
- end
46
-
47
- def query(sql)
48
- if @sqlcl_bin && inspec.command(@sqlcl_bin).exist?
49
- @bin = @sqlcl_bin
50
- format_options = "set sqlformat csv\nSET FEEDBACK OFF"
51
- parser = :parse_csv_result
52
- else
53
- @bin = "#{@sqlplus_bin} -S"
54
- format_options = "SET MARKUP HTML ON\nSET PAGESIZE 32000\nSET FEEDBACK OFF"
55
- parser = :parse_html_result
56
- end
57
-
58
- command = command_builder(format_options, sql)
59
- inspec_cmd = inspec.command(command)
60
-
61
- DatabaseHelper::SQLQueryResult.new(inspec_cmd,
62
- send(parser, inspec_cmd.stdout))
63
- end
64
-
65
- def to_s
66
- "Oracle Session"
67
- end
68
-
69
- private
70
-
71
- # 3 commands
72
- # regular user password
73
- # using a db_role
74
- # su, using a db_role
75
- def command_builder(format_options, query)
76
- verified_query = verify_query(query)
77
- sql_prefix, sql_postfix = "", ""
78
- if inspec.os.windows?
79
- sql_prefix = %{@'\n#{format_options}\n#{verified_query}\nEXIT\n'@ | }
80
- else
81
- sql_postfix = %{ <<'EOC'\n#{format_options}\n#{verified_query}\nEXIT\nEOC}
82
- end
83
-
84
- if @db_role.nil?
85
- %{#{sql_prefix}#{bin} "#{user}"/"#{password}"@#{host}:#{port}/#{@service}#{sql_postfix}}
86
- elsif @su_user.nil?
87
- %{#{sql_prefix}#{bin} "#{user}"/"#{password}"@#{host}:#{port}/#{@service} as #{@db_role}#{sql_postfix}}
88
- else
89
- %{su - #{@su_user} -c "env ORACLE_SID=#{@service} #{bin} / as #{@db_role}#{sql_postfix}}
90
- end
91
- end
92
-
93
- def verify_query(query)
94
- query += ";" unless query.strip.end_with?(";")
95
- query
96
- end
97
-
98
- def parse_csv_result(stdout)
99
- output = stdout.delete(/\r/)
100
- table = CSV.parse(output, { headers: true })
101
-
102
- # convert to hash
103
- headers = table.headers
104
-
105
- results = table.map do |row|
106
- res = {}
107
- headers.each do |header|
108
- res[header.downcase] = row[header]
109
- end
110
- Hashie::Mash.new(res)
111
- end
112
- results
113
- end
114
-
115
- def parse_html_result(stdout)
116
- result = stdout
117
- # make oracle html valid html by removing the p tag, it does not include a closing tag
118
- result = result.gsub("<p>", "").gsub("</p>", "").gsub("<br>", "")
119
- doc = REXML::Document.new result
120
- table = doc.elements["table"]
121
- hash = []
122
- unless table.nil?
123
- rows = table.elements.to_a
124
- headers = rows[0].elements.to_a("th").map { |entry| entry.text.strip }
125
- rows.delete_at(0)
126
-
127
- # iterate over each row, first row is header
128
- hash = []
129
- if !rows.nil? && !rows.empty?
130
- hash = rows.map do |row|
131
- res = {}
132
- entries = row.elements.to_a("td")
133
- # ignore if we have empty entries, oracle is adding th rows in between
134
- return nil if entries.empty?
135
-
136
- headers.each_with_index do |header, index|
137
- # we need htmlentities since we do not have nokogiri
138
- coder = HTMLEntities.new
139
- val = coder.decode(entries[index].text).strip
140
- res[header.downcase] = val
141
- end
142
- Hashie::Mash.new(res)
143
- end.compact
144
- end
145
- end
146
- hash
147
- end
148
- end
149
- end
@@ -1,34 +0,0 @@
1
- require "inspec/resources/platform"
2
-
3
- module Inspec::Resources
4
- class OSResource < PlatformResource
5
- name "os"
6
- supports platform: "unix"
7
- supports platform: "windows"
8
- desc "Use the os InSpec audit resource to test the platform on which the system is running."
9
- example <<~EXAMPLE
10
- describe os[:family] do
11
- it { should eq 'redhat' }
12
- end
13
-
14
- describe os.redhat? do
15
- it { should eq true }
16
- end
17
-
18
- describe os.linux? do
19
- it { should eq true }
20
- end
21
- EXAMPLE
22
-
23
- # reuse helper methods from backend
24
- %w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows? hpux? darwin?}.each do |os_family|
25
- define_method(os_family.to_sym) do
26
- @platform.send(os_family)
27
- end
28
- end
29
-
30
- def to_s
31
- "Operating System Detection"
32
- end
33
- end
34
- end
@@ -1,86 +0,0 @@
1
- # copyright: 2015, Vulcano Security GmbH
2
-
3
- # Usage:
4
- #
5
- # describe os_env('PATH') do
6
- # its('split') { should_not include('') }
7
- # its('split') { should_not include('.') }
8
- # end
9
-
10
- require "inspec/utils/simpleconfig"
11
-
12
- module Inspec::Resources
13
- class OsEnv < Inspec.resource(1)
14
- name "os_env"
15
- supports platform: "unix"
16
- supports platform: "windows"
17
- desc "Use the os_env InSpec audit resource to test the environment variables for the platform on which the system is running."
18
- example <<~EXAMPLE
19
- describe os_env('VARIABLE') do
20
- its('matcher') { should eq 1 }
21
- end
22
- EXAMPLE
23
-
24
- def initialize(env = nil, target = nil)
25
- @osenv = env
26
- @target = unless target.nil?
27
- if target.casecmp("system") == 0
28
- "Machine"
29
- else
30
- "User"
31
- end
32
- end
33
- end
34
-
35
- def split
36
- # we can't take advantage of `File::PATH_SEPARATOR` as code is
37
- # evaluated on the host machine
38
- path_separator = inspec.os.windows? ? ";" : ":"
39
- # -1 is required to catch cases like dir1::dir2:
40
- # where we have a trailing :
41
- content.nil? ? [] : content.split(path_separator, -1)
42
- end
43
-
44
- def content
45
- return @content if defined?(@content)
46
-
47
- @content = value_for(@osenv, @target) unless @osenv.nil?
48
- end
49
-
50
- def to_s
51
- if @osenv.nil?
52
- "Environment variables"
53
- else
54
- "Environment variable #{@osenv}"
55
- end
56
- end
57
-
58
- private
59
-
60
- def value_for(env, target = nil)
61
- command = if inspec.os.windows?
62
- if target.nil?
63
- "${Env:#{env}}"
64
- else
65
- "[System.Environment]::GetEnvironmentVariable('#{env}', [System.EnvironmentVariableTarget]::#{target})"
66
- end
67
- else
68
- "env"
69
- end
70
-
71
- out = inspec.command(command)
72
-
73
- unless out.exit_status == 0
74
- skip_resource "Can't read environment variables on #{inspec.os.name}. "\
75
- "Tried `#{command}` which returned #{out.exit_status}"
76
- end
77
-
78
- if inspec.os.windows?
79
- out.stdout.strip
80
- else
81
- params = SimpleConfig.new(out.stdout).params
82
- params[env]
83
- end
84
- end
85
- end
86
- end
@@ -1,391 +0,0 @@
1
- require "inspec/resources/directory"
2
- require "inspec/utils/simpleconfig"
3
-
4
- # Resource to determine package information
5
- #
6
- # Usage:
7
- # describe package('nginx') do
8
- # it { should be_installed }
9
- # end
10
- module Inspec::Resources
11
- class Package < Inspec.resource(1)
12
- name "package"
13
- supports platform: "unix"
14
- supports platform: "windows"
15
- desc "Use the package InSpec audit resource to test if the named package and/or package version is installed on the system."
16
- example <<~EXAMPLE
17
- describe package('nginx') do
18
- it { should be_installed }
19
- it { should_not be_held } # for dpkg platforms that support holding a version from being upgraded
20
- its('version') { should eq 1.9.5 }
21
- end
22
- EXAMPLE
23
- def initialize(package_name, opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
24
- @package_name = package_name
25
- @name = @package_name
26
- @cache = nil
27
- # select package manager
28
- @pkgman = nil
29
-
30
- os = inspec.os
31
- if os.debian?
32
- @pkgman = Deb.new(inspec)
33
- elsif os.redhat? || %w{suse amazon fedora}.include?(os[:family])
34
- @pkgman = Rpm.new(inspec, opts)
35
- elsif ["arch"].include?(os[:name])
36
- @pkgman = Pacman.new(inspec)
37
- elsif ["darwin"].include?(os[:family])
38
- @pkgman = Brew.new(inspec)
39
- elsif os.windows?
40
- @pkgman = WindowsPkg.new(inspec)
41
- elsif ["aix"].include?(os[:family])
42
- @pkgman = BffPkg.new(inspec)
43
- elsif os.solaris?
44
- @pkgman = SolarisPkg.new(inspec)
45
- elsif ["hpux"].include?(os[:family])
46
- @pkgman = HpuxPkg.new(inspec)
47
- elsif ["alpine"].include?(os[:name])
48
- @pkgman = AlpinePkg.new(inspec)
49
- else
50
- raise Inspec::Exceptions::ResourceSkipped, "The `package` resource is not supported on your OS yet."
51
- end
52
-
53
- evaluate_missing_requirements
54
- end
55
-
56
- # returns true if the package is installed
57
- def installed?(_provider = nil, _version = nil)
58
- info[:installed] == true
59
- end
60
-
61
- # returns true it the package is held (if the OS supports it)
62
- def held?(_provider = nil, _version = nil)
63
- info[:held] == true
64
- end
65
-
66
- # returns the package description
67
- def info
68
- return @cache unless @cache.nil?
69
- # All `@pkgman.info` methods return `{}`. This matches that
70
- # behavior if `@pkgman` can't be determined, thus avoiding the
71
- # `undefined method 'info' for nil:NilClass` error
72
- return {} if @pkgman.nil?
73
-
74
- @pkgman.info(@package_name)
75
- end
76
-
77
- # return the package version
78
- def version
79
- info = @pkgman.info(@package_name)
80
- info[:version]
81
- end
82
-
83
- def to_s
84
- "System Package #{@package_name}"
85
- end
86
-
87
- private
88
-
89
- def evaluate_missing_requirements
90
- missing_requirements_string = @pkgman.missing_requirements.uniq.join(", ")
91
- return if missing_requirements_string.empty?
92
-
93
- raise Inspec::Exceptions::ResourceSkipped, "The following requirements are not met for this resource: #{missing_requirements_string}"
94
- end
95
- end
96
-
97
- class PkgManagement
98
- attr_reader :inspec
99
- def initialize(inspec)
100
- @inspec = inspec
101
- end
102
-
103
- def missing_requirements
104
- # Each provider can provide an Array of missing requirements that will be
105
- # combined into a `ResourceSkipped` exception message.
106
- []
107
- end
108
- end
109
-
110
- # Debian / Ubuntu
111
- class Deb < PkgManagement
112
- def info(package_name)
113
- cmd = inspec.command("dpkg -s #{package_name}")
114
- return {} if cmd.exit_status.to_i != 0
115
-
116
- params = SimpleConfig.new(
117
- cmd.stdout.chomp,
118
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
119
- multiple_values: false
120
- ).params
121
- # If the package is installed, Status is "install ok installed"
122
- # If the package is installed and marked hold, Status is "hold ok installed"
123
- # If the package is removed and not purged, Status is "deinstall ok config-files" with exit_status 0
124
- # If the package is purged cmd fails with non-zero exit status
125
- {
126
- name: params["Package"],
127
- installed: params["Status"].split(" ")[2] == "installed",
128
- held: params["Status"].split(" ")[0] == "hold",
129
- version: params["Version"],
130
- type: "deb",
131
- }
132
- end
133
- end
134
-
135
- # RHEL family
136
- class Rpm < PkgManagement
137
- def initialize(inspec, opts)
138
- super(inspec)
139
-
140
- @dbpath = opts.fetch(:rpm_dbpath, nil)
141
- end
142
-
143
- def missing_requirements
144
- missing_requirements = []
145
-
146
- unless @dbpath.nil? || inspec.directory(@dbpath).directory?
147
- missing_requirements << "RPMDB #{@dbpath} does not exist"
148
- end
149
-
150
- missing_requirements
151
- end
152
-
153
- def info(package_name)
154
- rpm_cmd = rpm_command(package_name)
155
- cmd = inspec.command(rpm_cmd)
156
- # CentOS does not return an error code if the package is not installed,
157
- # therefore we need to check for emptyness
158
- return {} if cmd.exit_status.to_i != 0 || cmd.stdout.chomp.empty?
159
-
160
- params = SimpleConfig.new(
161
- cmd.stdout.chomp,
162
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
163
- multiple_values: false
164
- ).params
165
- # On some (all?) systems, the linebreak before the vendor line is missing
166
- if params["Version"] =~ /\s*Vendor:/
167
- v = params["Version"].split(" ")[0]
168
- else
169
- v = params["Version"]
170
- end
171
- # On some (all?) systems, the linebreak before the build line is missing
172
- if params["Release"] =~ /\s*Build Date:/
173
- r = params["Release"].split(" ")[0]
174
- else
175
- r = params["Release"]
176
- end
177
- {
178
- name: params["Name"],
179
- installed: true,
180
- version: "#{v}-#{r}",
181
- type: "rpm",
182
- }
183
- end
184
-
185
- private
186
-
187
- def rpm_command(package_name)
188
- cmd = ""
189
- cmd += "rpm -qi"
190
- cmd += " --dbpath #{@dbpath}" if @dbpath
191
- cmd += " " + package_name
192
-
193
- cmd
194
- end
195
- end
196
-
197
- # MacOS / Darwin implementation
198
- class Brew < PkgManagement
199
- def info(package_name)
200
- brew_path = inspec.command("brew").exist? ? "brew" : "/usr/local/bin/brew"
201
- cmd = inspec.command("#{brew_path} info --json=v1 #{package_name}")
202
-
203
- # If no available formula exists, then `brew` will exit non-zero
204
- return {} if cmd.exit_status.to_i != 0
205
-
206
- pkg = JSON.parse(cmd.stdout)[0]
207
-
208
- # If package exists but is not installed, then `brew` output will not
209
- # contain `pkg['installed'][0]['version']
210
- return {} unless pkg.dig("installed", 0, "version")
211
-
212
- {
213
- name: pkg["name"],
214
- installed: true,
215
- version: pkg["installed"][0]["version"],
216
- type: "brew",
217
- }
218
- rescue JSON::ParserError => e
219
- raise Inspec::Exceptions::ResourceFailed,
220
- "Failed to parse JSON from `brew` command. Error: #{e}"
221
- end
222
- end
223
-
224
- # Arch Linux
225
- class Pacman < PkgManagement
226
- def info(package_name)
227
- cmd = inspec.command("pacman -Qi #{package_name}")
228
- return {} if cmd.exit_status.to_i != 0
229
-
230
- params = SimpleConfig.new(
231
- cmd.stdout.chomp,
232
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
233
- multiple_values: false
234
- ).params
235
-
236
- {
237
- name: params["Name"],
238
- installed: true,
239
- version: params["Version"],
240
- type: "pacman",
241
- }
242
- end
243
- end
244
-
245
- class HpuxPkg < PkgManagement
246
- def info(package_name)
247
- cmd = inspec.command("swlist -l product | grep #{package_name}")
248
- return {} if cmd.exit_status.to_i != 0
249
-
250
- pkg = cmd.stdout.strip.split(" ")
251
- {
252
- name: pkg[0],
253
- installed: true,
254
- version: pkg[1],
255
- type: "pkg",
256
- }
257
- end
258
- end
259
-
260
- class AlpinePkg < PkgManagement
261
- def info(package_name)
262
- cmd = inspec.command("apk info -vv --no-network | grep #{package_name}")
263
- return {} if cmd.exit_status.to_i != 0
264
-
265
- pkg_info = cmd.stdout.split("\n").delete_if { |e| e =~ /^WARNING/i }
266
- pkg = pkg_info[0].split(" - ")[0]
267
-
268
- {
269
- name: pkg.partition("-")[0],
270
- installed: true,
271
- version: pkg.partition("-")[2],
272
- type: "pkg",
273
- }
274
- end
275
- end
276
-
277
- # Determines the installed packages on Windows using the Windows package registry entries.
278
- # @see: http://blogs.technet.com/b/heyscriptingguy/archive/2013/11/15/use-powershell-to-find-installed-software.aspx
279
- class WindowsPkg < PkgManagement
280
- def info(package_name)
281
- search_paths = [
282
- 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
283
- 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
284
- ]
285
-
286
- # add 64 bit search paths
287
- if inspec.os.arch == "x86_64"
288
- search_paths << 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
289
- search_paths << 'HKCU:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
290
- end
291
-
292
- # Find the package
293
- cmd = inspec.command <<-EOF.gsub(/^\s*/, "")
294
- Get-ItemProperty (@("#{search_paths.join('", "')}") | Where-Object { Test-Path $_ }) |
295
- Where-Object { $_.DisplayName -match "^\s*#{package_name.shellescape}\.*" -or $_.PSChildName -match "^\s*#{package_name.shellescape}\.*" } |
296
- Select-Object -Property DisplayName,DisplayVersion | ConvertTo-Json
297
- EOF
298
-
299
- # We cannot rely on `exit_status` since PowerShell always exits 0 from the
300
- # above command. Instead, if no package is found the output of the command
301
- # will be `''` so we can use that to return `{}` to match the behavior of
302
- # other package managers.
303
- return {} if cmd.stdout == ""
304
-
305
- begin
306
- package = JSON.parse(cmd.stdout)
307
- rescue JSON::ParserError => e
308
- raise Inspec::Exceptions::ResourceFailed,
309
- "Failed to parse JSON from PowerShell. Error: #{e}"
310
- end
311
-
312
- # What if we match multiple packages? just pick the first one for now.
313
- package = package[0] if package.is_a?(Array)
314
-
315
- {
316
- name: package["DisplayName"],
317
- installed: true,
318
- version: package["DisplayVersion"],
319
- type: "windows",
320
- }
321
- end
322
- end
323
-
324
- # AIX
325
- class BffPkg < PkgManagement
326
- def info(package_name)
327
- cmd = inspec.command("lslpp -cL #{package_name}")
328
- return {} if cmd.exit_status.to_i != 0
329
-
330
- bff_pkg = cmd.stdout.split("\n").last.split(":")
331
- {
332
- name: bff_pkg[1],
333
- installed: true,
334
- version: bff_pkg[2],
335
- type: "bff",
336
- }
337
- end
338
- end
339
-
340
- # Solaris
341
- class SolarisPkg < PkgManagement
342
- def info(package_name)
343
- if inspec.os[:release].to_i <= 10
344
- solaris10_info(package_name)
345
- else
346
- solaris11_info(package_name)
347
- end
348
- end
349
-
350
- # solaris 10
351
- def solaris10_info(package_name)
352
- cmd = inspec.command("pkginfo -l #{package_name}")
353
- return {} if cmd.exit_status.to_i != 0
354
-
355
- params = SimpleConfig.new(
356
- cmd.stdout.chomp,
357
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
358
- multiple_values: false
359
- ).params
360
-
361
- # parse 11.10.0,REV=2006.05.18.01.46
362
- v = params["VERSION"].split(",")
363
- {
364
- name: params["PKGINST"],
365
- installed: true,
366
- version: v[0] + "-" + v[1].split("=")[1],
367
- type: "pkg",
368
- }
369
- end
370
-
371
- # solaris 11
372
- def solaris11_info(package_name)
373
- cmd = inspec.command("pkg info #{package_name}")
374
- return {} if cmd.exit_status.to_i != 0
375
-
376
- params = SimpleConfig.new(
377
- cmd.stdout.chomp,
378
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
379
- multiple_values: false
380
- ).params
381
-
382
- {
383
- name: params["Name"],
384
- installed: true,
385
- # 0.5.11-0.175.3.1.0.5.0
386
- version: "#{params["Version"]}-#{params["Branch"]}",
387
- type: "pkg",
388
- }
389
- end
390
- end
391
- end