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
- # This unit test performs some tests to verify that
2
- # the inspec-resource-lister plugin is configured correctly.
3
-
4
- # Include our test harness
5
- require_relative '../helper'
6
-
7
- # Load the class under test, the Plugin definition.
8
- require '<%= plugin_name %>/plugin'
9
-
10
- # Because InSpec is a Spec-style test suite, we're going to use Minitest::Spec
11
- # here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
12
-
13
- describe InspecPlugins::<%= module_name %>::Plugin do
14
-
15
- # When writing tests, you can use `let` to create variables that you
16
- # can reference easily.
17
-
18
- # Internally, plugins are always known by a Symbol name. Convert here.
19
- let(:plugin_name) { :'<%= plugin_name %>' }
20
-
21
- # The Registry knows about all plugins that ship with InSpec by
22
- # default, as well as any that are installed by the user. When a
23
- # plugin definition is loaded, it will also self-register.
24
- let(:registry) { Inspec::Plugin::V2::Registry.instance }
25
-
26
- # The plugin status record tells us what the Registry knows.
27
- # Note that you can use previously-defined 'let's.
28
- let(:status) { registry[plugin_name] }
29
-
30
- # OK, actual tests!
31
-
32
- # Does the Registry know about us at all?
33
- it "should be registered" do
34
- registry.known_plugin?(plugin_name)
35
- end
36
-
37
- # Some tests through here use minitest Expectations, which attach to all
38
- # Objects, and begin with 'must' (positive) or 'wont' (negative)
39
- # See http://docs.seattlerb.org/minitest/Minitest/Expectations.html
40
-
41
- # The plugin system had an undocumented v1 API; this should be a v2 example.
42
- it "should be an api-v2 plugin" do
43
- status.api_generation.must_equal(2)
44
- end
45
-
46
- # Plugins can support several different activator hooks, each of which has a type.
47
- # Since this is (primarily) a CliCommand plugin, we'd expect to see that among our types.
48
- it "should include a cli_command activator hook" do
49
- status.plugin_types.must_include(:cli_command)
50
- end
51
- end
@@ -1,3 +0,0 @@
1
- # Example InSpec Profile
2
-
3
- This example shows the implementation of an InSpec profile.
@@ -1,18 +0,0 @@
1
- # copyright: 2018, The Authors
2
-
3
- title "sample section"
4
-
5
- # you can also use plain tests
6
- describe file("/tmp") do
7
- it { should be_directory }
8
- end
9
-
10
- # you add controls here
11
- control "tmp-1.0" do # A unique ID for this control
12
- impact 0.7 # The criticality, if this control fails.
13
- title "Create /tmp directory" # A human-readable title
14
- desc "An optional description..."
15
- describe file("/tmp") do # The actual test
16
- it { should be_directory }
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- name: <%= name %>
2
- title: InSpec Profile
3
- maintainer: The Authors
4
- copyright: The Authors
5
- copyright_email: you@example.com
6
- license: Apache-2.0
7
- summary: An InSpec Compliance Profile
8
- version: 0.1.0
9
- supports:
10
- platform: os
@@ -1,184 +0,0 @@
1
- require_relative "../../../shared/core_plugin_test_helper.rb"
2
-
3
- class InitPluginCli < Minitest::Test
4
- include CorePluginFunctionalHelper
5
-
6
- def test_generating_inspec_plugin_correct_prefix_required
7
- Dir.mktmpdir do |dir|
8
- plugin = "wacky-name"
9
- run_result = run_inspec_process("init plugin --no-prompt #{plugin} ", prefix: "cd #{dir} &&")
10
-
11
- skip_windows!
12
- assert_includes run_result.stdout, "ERROR"
13
- assert_includes run_result.stdout, "Plugin names must begin with"
14
-
15
- assert_empty run_result.stderr
16
-
17
- assert_exit_code 1, run_result
18
- end
19
- end
20
-
21
- def test_generating_inspec_plugin_with_default_options
22
- Dir.mktmpdir do |dir|
23
- plugin = "inspec-test-generated-plugin"
24
- snake_case = plugin.tr("-", "_")
25
- module_name = plugin.sub(/^inspec\-/, "").split("-").map(&:capitalize).join("")
26
-
27
- run_result = run_inspec_process("init plugin --no-prompt #{plugin}", prefix: "cd #{dir} &&")
28
-
29
- skip_windows!
30
- assert_includes run_result.stdout, "Creating new inspec plugin at"
31
- assert_includes run_result.stdout, plugin
32
-
33
- assert_empty run_result.stderr
34
-
35
- assert_exit_code 0, run_result
36
-
37
- # Check generated files and contents.
38
- # Each file must exist, and its contents must match each of the regexen given.
39
- {
40
- File.join(plugin, "README.md") => [
41
- /#{plugin}/,
42
- ],
43
- File.join(plugin, "LICENSE") => [
44
- /(?!opyright)/, # No copyright by default
45
- /Apache License/,
46
- ],
47
- File.join(plugin, "Gemfile") => [], # No interpolation
48
- File.join(plugin, "Rakefile") => [], # No interpolation
49
- File.join(plugin, plugin + ".gemspec") => [
50
- %r{require '#{plugin}/version'},
51
- /spec\.name\s+=\s+'#{plugin}'/,
52
- /spec\.version\s+=\s+InspecPlugins::#{module_name}::VERSION/,
53
- /README\.md\s+#{snake_case}\.gemspec\s+Gemfile/,
54
- /spec\.authors\s+=\s+\['Your Name'\]/,
55
- /spec\.email\s+=\s+\['you@example\.com'\]/,
56
- /spec\.summary\s+=\s+'A plugin with a default summary'/,
57
- /spec\.description\s+=\s+''/,
58
- %r{spec\.homepage\s+=\s+'https://github.com/you/#{plugin}'},
59
- /spec\.license\s+=\s+'Apache-2\.0'/,
60
- ],
61
- File.join(plugin, "lib", plugin + ".rb") => [
62
- %r{require\s'#{plugin}/plugin'},
63
- ],
64
- File.join(plugin, "lib", plugin, "plugin.rb") => [
65
- %r{require\s'#{plugin}/version'},
66
- /\#\s#{plugin}\s=>\s#{module_name}/,
67
- /module\s#{module_name}/,
68
- /plugin_name\s+:'#{plugin}'/,
69
- # Default assumes one cli hook
70
- /cli_command :my_command/,
71
- %r{require\s'#{plugin}/cli_command'},
72
- /InspecPlugins::#{module_name}::CliCommand/,
73
- ],
74
- File.join(plugin, "lib", plugin, "version.rb") => [
75
- /module\s#{module_name}/,
76
- ],
77
- File.join(plugin, "lib", plugin, "cli_command.rb") => [
78
- /module\sInspecPlugins::#{module_name}/,
79
- /\#\smakes\s`inspec\smy-command\s\.\.\.`\swork\./,
80
- /subcommand_desc\s'my_command\s\[COMMAND\]'/,
81
- /\#\sas\s`inspec\smy-command\sdo-something/,
82
- /\#\sin\s`inspec\shelp\smy-command`/,
83
- /\#\sruns\s`inspec\smy-command\sdo-something`./,
84
- %r{Edit\slib/#{plugin}/cli_command\.rb\sto\smake\sit\sdo},
85
- ],
86
- File.join(plugin, "test", "helper.rb") => [], # No interpolation
87
- File.join(plugin, "test", "functional", "README.md") => [], # No interpolation
88
- File.join(plugin, "test", "functional", snake_case + "_test.rb") => [
89
- # Whatever goes here
90
- ],
91
- File.join(plugin, "test", "unit", "plugin_def_test.rb") => [
92
- %r{require\s'#{plugin}/plugin'},
93
- /describe InspecPlugins::#{module_name}::Plugin\sdo/,
94
- /let\(:plugin_name\) \{ \:'#{plugin}\' \}/,
95
- ],
96
- File.join(plugin, "test", "unit", "cli_args_test.rb") => [
97
- %r{require '#{plugin}/cli_command'},
98
- /describe InspecPlugins::#{module_name}::CliCommand do/,
99
- /let\(\:cli_class\) \{ InspecPlugins::#{module_name}::CliCommand \}/,
100
- ],
101
- File.join(plugin, "test", "unit", "README.md") => [
102
- /cli_args_test\.rb/,
103
- ],
104
- }.each do |path, regexen|
105
- full_path = File.join(dir, path)
106
- assert(File.exist?(full_path), "#{path} should have been generated")
107
- next if regexen.empty?
108
-
109
- contents = File.read(full_path)
110
- regexen.each do |re|
111
- assert_match re, contents, "#{path} should match #{re}"
112
- end
113
- end
114
- end
115
- end
116
-
117
- def test_generating_inspec_plugin_with_custom_options
118
- Dir.mktmpdir do |dir|
119
- plugin = "inspec-test-generated-plugin"
120
- snake_case = plugin.tr("-", "_")
121
-
122
- opts = ""
123
- opts += " --author-email bob@example.com "
124
- opts += " --author-name Bob "
125
- opts += ' --copyright "Copyright © 2018 Bob" '
126
- opts += ' --description "That you will really like" '
127
- opts += " --license-name BSD-3-Clause "
128
- opts += ' --summary "A fantastic plugin" '
129
-
130
- opts += " --homepage http://example.com "
131
- opts += " --module_name FunPlugin"
132
-
133
- run_result = run_inspec_process("init plugin #{plugin} --no-prompt #{opts}", prefix: "cd #{dir} &&")
134
-
135
- skip_windows!
136
- assert_includes run_result.stdout, "Creating new inspec plugin at"
137
- assert_includes run_result.stdout, plugin
138
-
139
- assert_empty run_result.stderr
140
-
141
- assert_exit_code 0, run_result
142
-
143
- # Check generated files and contents.
144
- # Each file must exist, and its contents must match each of the regexen given.
145
-
146
- {
147
- File.join(plugin, "README.md") => [],
148
- File.join(plugin, "LICENSE") => [
149
- /Copyright . 2018 Bob/,
150
- /used to endorse or promote/,
151
- ],
152
- File.join(plugin, "Gemfile") => [],
153
- File.join(plugin, "Rakefile") => [],
154
- File.join(plugin, plugin + ".gemspec") => [
155
- /spec\.version\s+=\s+InspecPlugins::FunPlugin::VERSION/,
156
- /spec\.authors\s+=\s+\['Bob'\]/,
157
- /spec\.email\s+=\s+\['bob@example\.com'\]/,
158
- /spec\.summary\s+=\s+'A fantastic plugin'/,
159
- /spec\.description\s+=\s+'That you will really like'/,
160
- %r{spec\.homepage\s+=\s+'http://example.com'},
161
- /spec\.license\s+=\s+'BSD-3-Clause'/,
162
- ],
163
- File.join(plugin, "lib", plugin + ".rb") => [],
164
- File.join(plugin, "lib", plugin, "plugin.rb") => [],
165
- File.join(plugin, "lib", plugin, "version.rb") => [],
166
- File.join(plugin, "lib", plugin, "cli_command.rb") => [],
167
- File.join(plugin, "test", "helper.rb") => [],
168
- File.join(plugin, "test", "functional", snake_case + "_test.rb") => [],
169
- File.join(plugin, "test", "unit", "plugin_def_test.rb") => [],
170
- File.join(plugin, "test", "unit", "cli_args_test.rb") => [],
171
- }.each do |path, regexen|
172
- full_path = File.join(dir, path)
173
- assert(File.exist?(full_path), "#{path} should have been generated")
174
- next if regexen.empty?
175
-
176
- contents = File.read(full_path)
177
- regexen.each do |re|
178
- assert_match re, contents, "#{path} should match #{re}"
179
- end
180
- end
181
- end
182
- end
183
-
184
- end
@@ -1,121 +0,0 @@
1
- require "yaml"
2
- require_relative "../../../shared/core_plugin_test_helper.rb"
3
-
4
- class InitCli < Minitest::Test
5
- include CorePluginFunctionalHelper
6
-
7
- def test_generating_inspec_profile
8
- Dir.mktmpdir do |dir|
9
- profile = File.join(dir, "test-profile")
10
- out = run_inspec_process("init profile test-profile", prefix: "cd #{dir} &&")
11
-
12
- skip_windows!
13
- assert_includes out.stdout, "Creating new profile at"
14
- assert_includes out.stdout, profile
15
- assert_includes Dir.entries(profile).join, "inspec.yml"
16
- assert_includes Dir.entries(profile).join, "README.md"
17
-
18
- assert_exit_code 0, out
19
- end
20
- end
21
-
22
- def test_generating_inspec_profile_with_explicit_platform
23
- Dir.mktmpdir do |dir|
24
- profile = File.join(dir, "test-profile")
25
- out = run_inspec_process("init profile --platform os test-profile", prefix: "cd #{dir} &&")
26
-
27
- skip_windows!
28
- assert_includes out.stdout, "Creating new profile at"
29
- assert_includes out.stdout, profile
30
- assert_includes Dir.entries(profile).join, "inspec.yml"
31
- assert_includes Dir.entries(profile).join, "README.md"
32
-
33
- assert_exit_code 0, out
34
- end
35
- end
36
-
37
- def test_generating_inspec_profile_with_bad_platform
38
- Dir.mktmpdir do |dir|
39
- out = run_inspec_process("init profile --platform nonesuch test-profile", prefix: "cd #{dir} &&")
40
-
41
- skip_windows!
42
- assert_includes out.stdout, "Unable to generate profile"
43
- assert_includes out.stdout, "No template available for platform 'nonesuch'"
44
-
45
- assert_exit_code 1, out
46
- end
47
- end
48
-
49
- def test_profile_with_slash_name
50
- Dir.mktmpdir do |dir|
51
- profile = dir + "/test/deeper/profile"
52
- out = run_inspec_process("init profile test/deeper/profile", prefix: "cd #{dir} &&")
53
- skip_windows!
54
- assert_equal true, File.exist?(profile)
55
- profile = YAML.load_file("#{profile}/inspec.yml")
56
- assert_equal "profile", profile["name"]
57
-
58
- assert_exit_code 0, out
59
- end
60
- end
61
-
62
- def test_generating_inspec_profile_gcp
63
- Dir.mktmpdir do |dir|
64
- profile = File.join(dir, "test-gcp-profile")
65
- out = run_inspec_process("init profile --platform gcp test-gcp-profile", prefix: "cd #{dir} &&")
66
-
67
- skip_windows!
68
- assert_includes out.stdout, "Creating new profile at"
69
- assert_includes out.stdout, profile
70
- assert_includes Dir.entries(profile).join, "inspec.yml"
71
- assert_includes Dir.entries(profile).join, "README.md"
72
-
73
- assert_exit_code 0, out
74
- end
75
- end
76
-
77
- def test_generating_inspec_profile_aws
78
- Dir.mktmpdir do |dir|
79
- profile = File.join(dir, "test-aws-profile")
80
- out = run_inspec_process("init profile --platform aws test-aws-profile", prefix: "cd #{dir} &&")
81
-
82
- skip_windows!
83
- assert_includes out.stdout, "Creating new profile at"
84
- assert_includes out.stdout, profile
85
- assert_includes Dir.entries(profile).join, "inspec.yml"
86
- assert_includes Dir.entries(profile).join, "README.md"
87
-
88
- assert_exit_code 0, out
89
- end
90
- end
91
-
92
- def test_generating_inspec_profile_azure
93
- Dir.mktmpdir do |dir|
94
- profile = File.join(dir, "test-azure-profile")
95
- out = run_inspec_process("init profile --platform azure test-azure-profile", prefix: "cd #{dir} &&")
96
-
97
- skip_windows!
98
- assert_includes out.stdout, "Creating new profile at"
99
- assert_includes out.stdout, profile
100
- assert_includes Dir.entries(profile).join, "inspec.yml"
101
- assert_includes Dir.entries(profile).join, "README.md"
102
-
103
- assert_exit_code 0, out
104
- end
105
- end
106
-
107
- def test_generating_inspec_profile_os
108
- Dir.mktmpdir do |dir|
109
- profile = File.join(dir, "test-os-profile")
110
- out = run_inspec_process("init profile --platform os test-os-profile", prefix: "cd #{dir} &&")
111
-
112
- skip_windows!
113
- assert_includes out.stdout, "Creating new profile at"
114
- assert_includes out.stdout, profile
115
- assert_includes Dir.entries(profile).join, "inspec.yml"
116
- assert_includes Dir.entries(profile).join, "README.md"
117
-
118
- assert_exit_code 0, out
119
- end
120
- end
121
- end
@@ -1,6 +0,0 @@
1
- # InSpec Plugin Manager CLI
2
-
3
- This is a CLI plugin for InSpec. It uses the Plugins API v2 to create a
4
- series of commands to manage plugins.
5
-
6
- It was the first plugin to be authored as a core plugin under Plugins v2.
@@ -1,17 +0,0 @@
1
- # Because this is a core plugin, we place the plugin definition here in the entry point.
2
- # This is needed because under core testing, the entry point may be reloaded multiple times,
3
- # and we need plugin registration to properly occur each time.
4
- # More typically, the entry point would just load a plugin definition file.
5
-
6
- module InspecPlugins
7
- module PluginManager
8
- class Plugin < Inspec.plugin(2)
9
- plugin_name :'inspec-plugin-manager-cli'
10
-
11
- cli_command :plugin do
12
- require_relative "inspec-plugin-manager-cli/cli_command"
13
- InspecPlugins::PluginManager::CliCommand
14
- end
15
- end
16
- end
17
- end
@@ -1,518 +0,0 @@
1
- require "pathname"
2
- require "inspec/plugin/v2"
3
- require "inspec/plugin/v2/installer"
4
- require "inspec/dist"
5
-
6
- module InspecPlugins
7
- module PluginManager
8
- class CliCommand < Inspec.plugin(2, :cli_command)
9
- INSTALL_TYPE_LABELS = {
10
- bundle: "core", # Calling this core, too - not much of a distinction
11
- core: "core",
12
- path: "path",
13
- user_gem: "gem (user)",
14
- system_gem: "gem (system)",
15
- }.freeze
16
-
17
- include Inspec::Dist
18
-
19
- subcommand_desc "plugin SUBCOMMAND", "Manage #{PRODUCT_NAME} and Train plugins"
20
-
21
- #==================================================================#
22
- # inspec plugin list
23
- #==================================================================#
24
-
25
- desc "list [options]", "Lists user-installed #{PRODUCT_NAME} plugins."
26
- option :all, desc: "List all types of plugins (default)", type: :boolean, default: true, aliases: [:a]
27
- option :user, desc: "List user plugins, from ~/.inspec/gems", banner: "", type: :boolean, default: false, aliases: [:u]
28
- option :system, desc: "List system plugins, those InSpec depends on", banner: "", type: :boolean, default: false, aliases: [:s]
29
- option :core, desc: "List core plugins, those InSpec ships with", banner: "", type: :boolean, default: false, aliases: [:c]
30
-
31
- def list
32
- plugin_statuses = Inspec::Plugin::V2::Registry.instance.plugin_statuses
33
- options[:all] = false if options[:core] || options[:user] || options[:system]
34
- plugin_statuses.select! do |status|
35
- type = status.installation_type
36
- options[:all] ||
37
- (options[:core] && %i{core bundle}.include?(type)) ||
38
- (options[:user] && %i{user_gem path}.include?(type)) ||
39
- (options[:system] && :system_gem == type)
40
- end
41
-
42
- unless plugin_statuses.empty?
43
- ui.table do |t|
44
- t.header = ["Plugin Name", "Version", "Via", "ApiVer"]
45
- plugin_statuses.sort_by { |s| s.name.to_s }.each do |status|
46
- t << [
47
- status.name,
48
- make_pretty_version(status),
49
- make_pretty_install_type(status),
50
- status.api_generation,
51
- ]
52
- end
53
- end
54
- end
55
- ui.plain_line(" #{plugin_statuses.count} plugin(s) total")
56
- puts
57
- end
58
-
59
- #==================================================================#
60
- # inspec plugin search
61
- #==================================================================#
62
-
63
- desc "search [options] PATTERN", "Searches rubygems.org for plugins."
64
- long_desc <<~EOLD
65
- Searches rubygems.org for #{PRODUCT_NAME} plugins. Exits 0 on a search hit, 1 on user error,
66
- 2 on a search miss. PATTERN is a simple string; a wildcard will be added as
67
- a suffix, unless -e is used.
68
- EOLD
69
- option :all, desc: "List all available versions, not just the latest one.", type: :boolean, aliases: [:a]
70
- option :exact, desc: "Assume PATTERN is exact; do not add a wildcard to the end", type: :boolean, aliases: [:e]
71
- option :'include-test-fixture', type: :boolean, desc: "Internal use", hide: true
72
- # Justification for disabling ABC: currently at 33.51/33
73
- def search(search_term) # rubocop: disable Metrics/AbcSize
74
- search_results = installer.search(search_term, exact: options[:exact])
75
- # The search results have already been filtered by the reject list. But the
76
- # RejectList doesn't filter {inspec, train}-test-fixture because we need those
77
- # for testing. We want to hide those from users, so unless we know we're in
78
- # test mode, remove them.
79
- unless options[:'include-test-fixture']
80
- search_results.delete("inspec-test-fixture")
81
- search_results.delete("train-test-fixture")
82
- end
83
-
84
- puts
85
- ui.bold(format(" %-30s%-50s\n", "Plugin Name", "Versions Available"))
86
- ui.line
87
- search_results.keys.sort.each do |plugin_name|
88
- versions = options[:all] ? search_results[plugin_name] : [search_results[plugin_name].first]
89
- versions = "(" + versions.join(", ") + ")"
90
- ui.plain_line(format(" %-30s%-50s", plugin_name, versions))
91
- end
92
- ui.line
93
- ui.plain_line(" #{search_results.count} plugin(s) found")
94
- puts
95
-
96
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR if search_results.empty?
97
- rescue Inspec::Plugin::V2::SearchError => ex
98
- Inspec::Log.error ex.message
99
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
100
- end
101
-
102
- #==================================================================#
103
- # inspec plugin install
104
- #==================================================================#
105
- desc "install [-v VERSION] PLUGIN", "Installs a plugin from rubygems.org, a gemfile, or a path to local source."
106
- long_desc <<~EOLD
107
- PLUGIN may be the name of a gem on rubygems.org that begins with inspec- or train-.
108
- PLUGIN may also be the path to a local gemfile, which will then be installed like
109
- any other gem. Finally, if PLUGIN is a path ending in .rb, it is taken to be a
110
- local file that will act as athe entry point for a plugin (this mode is provided
111
- for local plugin development). Exit codes are 0 on success, 2 if the plugin is
112
- already installed, and 1 if any other error occurs.
113
- EOLD
114
- option :version, desc: "When installing from rubygems.org, specifies a specific version to install.", aliases: [:v]
115
- def install(plugin_id_arg)
116
- if plugin_id_arg =~ /\.gem$/ # Does it end in .gem?
117
- install_from_gemfile(plugin_id_arg)
118
- elsif plugin_id_arg =~ %r{[\/\\]} || Dir.exist?(plugin_id_arg) # Does the argument have a slash, or exist as dir in the local directory?
119
- install_from_path(plugin_id_arg)
120
- else
121
- install_from_remote_gem(plugin_id_arg)
122
- end
123
- end
124
-
125
- #--------------------------
126
- # update
127
- #--------------------------
128
- desc "update PLUGIN", "Updates a plugin to the latest from from rubygems.org"
129
- long_desc <<~EOLD
130
- PLUGIN may be the name of a gem on rubygems.org that begins with inspec- or train-.
131
- Exit codes are 0 on success, 2 if the plugin is already up to date, and 1 if any
132
- other error occurs.
133
- EOLD
134
- def update(plugin_name)
135
- pre_update_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
136
- old_version = pre_update_versions.join(", ")
137
-
138
- update_preflight_check(plugin_name, pre_update_versions)
139
-
140
- begin
141
- installer.update(plugin_name)
142
- rescue Inspec::Plugin::V2::UpdateError => ex
143
- ui.plain_line("#{ui.red("Update error:", print: false)} #{ex.message} - update failed")
144
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
145
- end
146
- post_update_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
147
- new_version = (post_update_versions - pre_update_versions).first
148
-
149
- ui.bold(plugin_name + " plugin, version #{old_version} -> " \
150
- "#{new_version}, updated from rubygems.org\n")
151
- end
152
-
153
- #--------------------------
154
- # uninstall
155
- #--------------------------
156
- desc "uninstall PLUGIN_NAME", "Uninstalls a gem- or path- based plugin"
157
- long_desc <<~EOLD
158
- Removes a plugin from the users configuration.
159
- In the case of a gem plugin (by far the most common), the plugin gem is removed, along
160
- with any of its dependencies that are no longer needed by anything else. Finally, the
161
- plugin configuration file is updated to reflect that the plugin is no longer present.
162
- In the case of a path-based plugin (often used for plugin development), no changes
163
- are made to the referenced plugin source code. Rather, the plugin's entry is simply removed
164
- from the plugin config file.
165
- EOLD
166
- def uninstall(plugin_name)
167
- status = Inspec::Plugin::V2::Registry.instance[plugin_name.to_sym]
168
- unless status
169
- ui.plain_line("#{ui.red("No such plugin installed:", print: false)} #{plugin_name} is not " \
170
- "installed - uninstall failed")
171
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
172
- end
173
- installer = Inspec::Plugin::V2::Installer.instance
174
-
175
- pre_uninstall_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
176
- old_version = pre_uninstall_versions.join(", ")
177
-
178
- installer.uninstall(plugin_name)
179
-
180
- if status.installation_type == :path
181
- ui.bold(plugin_name + " path-based plugin install has been " \
182
- "uninstalled\n")
183
- else
184
- ui.bold(plugin_name + " plugin, version #{old_version}, has " \
185
- "been uninstalled\n")
186
- end
187
-
188
- ui.exit Inspec::UI::EXIT_NORMAL
189
- end
190
-
191
- private
192
-
193
- #==================================================================#
194
- # install breakdown
195
- #==================================================================#
196
- # These are broken down because rubocop complained.
197
-
198
- def install_from_gemfile(gem_file)
199
- unless File.exist? gem_file
200
- ui.red("No such plugin gem file #{gem_file} - installation failed.\n")
201
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
202
- end
203
-
204
- plugin_name_parts = File.basename(gem_file, ".gem").split("-")
205
- version = plugin_name_parts.pop
206
- plugin_name = plugin_name_parts.join("-")
207
- check_plugin_name(plugin_name, "installation")
208
-
209
- installer.install(plugin_name, gem_file: gem_file)
210
-
211
- ui.bold("#{plugin_name} plugin, version #{version}, installed from " \
212
- "local .gem file\n")
213
- ui.exit Inspec::UI::EXIT_NORMAL
214
- end
215
-
216
- def install_from_path(path)
217
- unless File.exist? path
218
- ui.red("No such source code path #{path} - installation failed.\n")
219
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
220
- end
221
-
222
- plugin_name = File.basename(path, ".rb")
223
-
224
- # While installer.install does some rudimentary checking,
225
- # this file has good UI access, so we promise to validate the
226
- # input a lot and hand the installer a sure-thing.
227
-
228
- # Name OK?
229
- check_plugin_name(plugin_name, "installation")
230
-
231
- # Already installed?
232
- if registry.known_plugin?(plugin_name.to_sym)
233
- ui.red("Plugin already installed - #{plugin_name} - Use '#{EXEC_NAME} " \
234
- "plugin list' to see previously installed plugin - " \
235
- "installation failed.\n")
236
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
237
- end
238
-
239
- # Can we figure out how to load it?
240
- entry_point = install_from_path__apply_entry_point_heuristics(path)
241
-
242
- # If you load it, does it act like a plugin?
243
- install_from_path__probe_load(entry_point, plugin_name)
244
-
245
- # OK, install it!
246
- installer.install(plugin_name, path: entry_point)
247
-
248
- ui.bold("#{plugin_name} plugin installed via source path reference, " \
249
- "resolved to entry point #{entry_point}\n")
250
- ui.exit Inspec::UI::EXIT_NORMAL
251
- end
252
-
253
- # Rationale for rubocop variances: It's a heuristics method, and will be full of
254
- # conditionals. The code is well-commented; refactoring into sub-methods would
255
- # reduce clarity.
256
- def install_from_path__apply_entry_point_heuristics(path) # rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
257
- given = Pathname.new(path)
258
- given = given.expand_path # Resolve any relative paths
259
- name_regex = /^(inspec|train)-/
260
- versioned_regex = /^(inspec|train)-[a-z0-9\-\_]+-\d+\.\d+\.\d+$/
261
- sha_ref_regex = /^(inspec|train)-[a-z0-9\-\_]+-[0-9a-f]{5,40}$/
262
-
263
- # What are the last four things like?
264
- parts = [
265
- given.parent.parent.basename,
266
- given.parent.basename,
267
- given.basename(".rb"),
268
- given.extname,
269
- ].map(&:to_s)
270
-
271
- # Case 1: Simplest case: it was a full entry point, as presented.
272
- # /home/you/projects/inspec-something/lib/inspec-something.rb
273
- # parts index: ^0^ ^1^ ^2^ ^3^
274
- if parts[0] =~ name_regex && parts[1] == "lib" && parts[2] == parts[0] && parts[3] == ".rb"
275
- return given.to_s
276
- end
277
-
278
- # Case 2: Also easy: they either referred to the internal library directory,
279
- # or left the extansion off. Those are the same to us.
280
- # /home/you/projects/inspec-something/lib/inspec-something
281
- # parts index: ^0^ ^1^ ^2^ (3 is empty)
282
- if parts[0] =~ name_regex && parts[1] == "lib" && parts[2] == parts[0] && parts[3].empty?
283
- return given.to_s + ".rb"
284
- end
285
-
286
- # Case 3: Maybe they were refering to a path that is inside a gem installation, or an exploded gem?
287
- # In that case, we'll have a version on the plugin name in part 0
288
- # /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something.rb
289
- # parts index: ^0^ ^1^ ^2^ ^3^
290
- if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3] == ".rb"
291
- return given.to_s
292
- end
293
-
294
- # Case 4: Like case 3, but missing the .rb
295
- # /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something
296
- # parts index: ^0^ ^1^ ^2^ ^3^ (empty)
297
- if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3].empty?
298
- return given.to_s + ".rb"
299
- end
300
-
301
- # Case 5: Easy to recognize, but harder to handle: they referred to the project root.
302
- # /home/you/projects/inspec-something
303
- # parts index: ^0^ ^1^ ^2^ (3 is empty)
304
- # 0 and 1 are not meaningful to us, but we hope to find a parts[2]/lib/inspec-something.rb.
305
- entry_point_guess = File.join(given.to_s, "lib", parts[2] + ".rb")
306
- if parts[2] =~ name_regex && File.exist?(entry_point_guess)
307
- return entry_point_guess
308
- end
309
-
310
- # Well, if we got here, parts[2] matches an inspec/train prefix, but we have no idea about anything.
311
- # Give up.
312
- ui.red("Unrecognizable plugin structure - #{parts[2]} - When " \
313
- "installing from a path, please provide the path of the " \
314
- "entry point file - installation failed.\n")
315
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
316
- end
317
-
318
- def install_from_path__probe_load(entry_point, plugin_name)
319
- # Brazenly attempt to load a file, and see if it registers a plugin.
320
- begin
321
- require entry_point
322
- rescue LoadError => ex
323
- ui.red("Plugin contains errors - #{plugin_name} - Encountered " \
324
- "errors while trying to test load the plugin entry point, " \
325
- "resolved to #{entry_point} - installation failed\n")
326
- ui.plain_line ex.message
327
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
328
- end
329
-
330
- # OK, the wheels didn't fall off. But is it a plugin?
331
- if plugin_name.to_s.start_with?("train")
332
- # Train internal names do not include the prix in their registry entries
333
- # And the registry is keyed on Strings
334
- registry_key = plugin_name.to_s.sub(/^train-/, "")
335
- unless Train::Plugins.registry.key?(registry_key)
336
- ui.red("Does not appear to be a plugin - #{plugin_name} - After " \
337
- "probe-loading the supposed plugin, it did not register " \
338
- "itself to Train. Ensure something inherits from " \
339
- "'Train.plugin(1)' - installation failed.\n")
340
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
341
- end
342
- else
343
- unless registry.known_plugin?(plugin_name.to_sym)
344
- ui.red("Does not appear to be a plugin - #{plugin_name} - After " \
345
- "probe-loading the supposed plugin, it did not register " \
346
- "itself to InSpec. Ensure something inherits from " \
347
- "'Inspec.plugin(2)' - installation failed.\n")
348
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
349
- end
350
- end
351
- end
352
-
353
- def install_from_remote_gem(plugin_name)
354
- requested_version = options[:version]
355
-
356
- check_plugin_name(plugin_name, "installation")
357
-
358
- # Version pre-flighting
359
- pre_installed_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
360
- install_from_remote_gem_verson_preflight_check(plugin_name, requested_version, pre_installed_versions)
361
-
362
- install_attempt_install(plugin_name)
363
-
364
- # Success messaging. What did we actually install?
365
- post_installed_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
366
- new_version = (post_installed_versions - pre_installed_versions).first
367
-
368
- ui.bold("#{plugin_name} plugin, version #{new_version}, installed " \
369
- "from rubygems.org\n")
370
- ui.exit Inspec::UI::EXIT_NORMAL
371
- end
372
-
373
- def install_from_remote_gem_verson_preflight_check(plugin_name, requested_version, pre_installed_versions)
374
- return if pre_installed_versions.empty?
375
-
376
- # Everything past here in the block is a code 2 error
377
-
378
- # If they didn't ask for a specific version, they implicitly ask for the latest.
379
- # Do an expensive search to determine the latest version.
380
- unless requested_version
381
- latest_version = installer.search(plugin_name, exact: true, scope: :latest)
382
- latest_version = latest_version[plugin_name]&.last
383
- if latest_version && !requested_version
384
- requested_version = latest_version
385
- end
386
- end
387
-
388
- # Check for already-installed at desired version conditions
389
- they_explicitly_asked_for_a_version = !options[:version].nil?
390
- what_we_would_install_is_already_installed = pre_installed_versions.include?(requested_version)
391
- if what_we_would_install_is_already_installed && they_explicitly_asked_for_a_version
392
- ui.red("Plugin already installed at requested version - plugin " \
393
- "#{plugin_name} #{requested_version} - refusing to install.\n")
394
- elsif what_we_would_install_is_already_installed && !they_explicitly_asked_for_a_version
395
- ui.red("Plugin already installed at latest version - plugin " \
396
- "#{plugin_name} #{requested_version} - refusing to install.\n")
397
- else
398
- # There are existing versions installed, but none of them are what was requested
399
- ui.red("Update required - plugin #{plugin_name}, requested " \
400
- "#{requested_version}, have " \
401
- "#{pre_installed_versions.join(", ")}; use `inspec " \
402
- "plugin update` - refusing to install.\n")
403
- end
404
-
405
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
406
- end
407
-
408
- # Rationale for RuboCop variance: This is a one-line method with heavy UX-focused error handling.
409
- def install_attempt_install(plugin_name) # rubocop: disable Metrics/AbcSize
410
- installer.install(plugin_name, version: options[:version])
411
- rescue Inspec::Plugin::V2::PluginExcludedError => ex
412
- ui.red("Plugin on Exclusion List - #{plugin_name} is listed as an " \
413
- "incompatible gem - refusing to install.\n")
414
- ui.plain_line("Rationale: #{ex.details.rationale}")
415
- ui.plain_line("Exclusion list location: " +
416
- File.join(Inspec.src_root, "etc", "plugin_filters.json"))
417
- ui.plain_line("If you disagree with this determination, please accept " \
418
- "our apologies for the misunderstanding, and open an issue " \
419
- "at https://github.com/inspec/inspec/issues/new")
420
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
421
- rescue Inspec::Plugin::V2::InstallError
422
- raise if Inspec::Log.level == :debug
423
-
424
- results = installer.search(plugin_name, exact: true)
425
- if results.empty?
426
- ui.red("No such plugin gem #{plugin_name} could be found on " \
427
- "rubygems.org - installation failed.\n")
428
- elsif options[:version] && !results[plugin_name].include?(options[:version])
429
- ui.red("No such version - #{plugin_name} exists, but no such " \
430
- "version #{options[:version]} found on rubygems.org - " \
431
- "installation failed.\n")
432
- else
433
- ui.red("Unknown error occured - installation failed.\n")
434
- end
435
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
436
- end
437
-
438
- #==================================================================#
439
- # update breakdown
440
- #==================================================================#
441
- def update_preflight_check(plugin_name, pre_update_versions)
442
- if pre_update_versions.empty?
443
- # Check for path install
444
- status = Inspec::Plugin::V2::Registry.instance[plugin_name.to_sym]
445
- if !status
446
- ui.plain_line("#{ui.red("No such plugin installed:", print: false)} #{plugin_name} - update failed")
447
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
448
- elsif status.installation_type == :path
449
- ui.plain_line("#{ui.red("Cannot update path-based install:", print: false)} " \
450
- "#{plugin_name} is installed via path reference; " \
451
- "use `inspec plugin uninstall` to remove - refusing to" \
452
- "update")
453
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
454
- end
455
- end
456
-
457
- # Check for latest version (and implicitly, existance)
458
- latest_version = installer.search(plugin_name, exact: true, scope: :latest)
459
- latest_version = latest_version[plugin_name]&.last
460
-
461
- if pre_update_versions.include?(latest_version)
462
- ui.plain_line("#{ui.red("Already installed at latest version:", print: false)} " \
463
- "#{plugin_name} is at #{latest_version}, which the " \
464
- "latest - refusing to update")
465
- ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
466
- end
467
- end
468
-
469
- #==================================================================#
470
- # utilities
471
- #==================================================================#
472
- def installer
473
- Inspec::Plugin::V2::Installer.instance
474
- end
475
-
476
- def registry
477
- Inspec::Plugin::V2::Registry.instance
478
- end
479
-
480
- def check_plugin_name(plugin_name, action)
481
- unless plugin_name =~ /^(inspec|train)-/
482
- ui.red("Invalid plugin name - #{plugin_name} - All inspec " \
483
- "plugins must begin with either 'inspec-' or 'train-' " \
484
- "- #{action} failed.\n")
485
- ui.exit Inspec::UI::EXIT_USAGE_ERROR
486
- end
487
- end
488
-
489
- def make_pretty_version(status)
490
- case status.installation_type
491
- when :core, :bundle
492
- Inspec::VERSION
493
- when :user_gem, :system_gem
494
- if status.version.nil?
495
- "(unknown)"
496
- elsif status.version =~ /^\d+\.\d+\.\d+$/
497
- status.version
498
- else
499
- # Assume it is a version constraint string and try to resolve
500
- # TODO: this is naive, and assumes the latest version is the one that will be used. Logged on #3317
501
- # In fact, the logic to determine "what version would be used" belongs in the Loader.
502
- plugin_name = status.name.to_s
503
- Inspec::Plugin::V2::Loader.list_installed_plugin_gems
504
- .select { |spec| spec.name == plugin_name }
505
- .sort_by(&:version)
506
- .last.version
507
- end
508
- when :path
509
- "src"
510
- end
511
- end
512
-
513
- def make_pretty_install_type(status)
514
- INSTALL_TYPE_LABELS[status.installation_type]
515
- end
516
- end
517
- end
518
- end