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,26 +0,0 @@
1
-
2
- require "inspec/input_registry"
3
-
4
- module Inspec
5
- # A mixin to provide implementations for the input() DSL methods
6
- module InputDslHelpers
7
-
8
- # Find or create an input, explicitly named by a profile ID and
9
- # input name. Evaluate the input and return the value.
10
- # @param [String] Profile ID
11
- # @param [String] Input Name
12
- # @param [Hash] Input options - see input docs on website
13
- # @returns [Object] Input value
14
- def input_with_profile_id(profile_id, input_name, options)
15
- if options.empty?
16
- # Simply an access, no event here
17
- Inspec::InputRegistry.find_or_register_input(input_name, profile_id).value
18
- else
19
- options[:priority] = 20
20
- options[:provider] = :inline_control_code
21
- evt = Inspec::Input.infer_event(options)
22
- Inspec::InputRegistry.find_or_register_input(input_name, profile_id, event: evt).value
23
- end
24
- end
25
- end
26
- end
@@ -1,315 +0,0 @@
1
- require "forwardable"
2
- require "singleton"
3
- require "inspec/input"
4
- require "inspec/secrets"
5
- require "inspec/exceptions"
6
- require "inspec/plugin/v2"
7
-
8
- module Inspec
9
- # The InputRegistry's responsibilities include:
10
- # - maintaining a list of Input objects that are bound to profiles
11
- # - assisting in the lookup and creation of Inputs
12
- class InputRegistry
13
- include Singleton
14
- extend Forwardable
15
-
16
- class Error < Inspec::Error; end
17
- class ProfileLookupError < Error
18
- attr_accessor :profile_name
19
- end
20
- class InputLookupError < Error
21
- attr_accessor :profile_name
22
- attr_accessor :input_name
23
- end
24
-
25
- attr_reader :inputs_by_profile, :profile_aliases, :plugins
26
- def_delegator :inputs_by_profile, :each
27
- def_delegator :inputs_by_profile, :[]
28
- def_delegator :inputs_by_profile, :key?, :profile_known?
29
- def_delegator :inputs_by_profile, :select
30
- def_delegator :profile_aliases, :key?, :profile_alias?
31
-
32
- def initialize
33
- # Keyed on String profile_name => Hash of String input_name => Input object
34
- @inputs_by_profile = {}
35
-
36
- # this is a list of optional profile name overrides set in the inspec.yml
37
- @profile_aliases = {}
38
-
39
- # Upon creation, activate all input plugins
40
- activators = Inspec::Plugin::V2::Registry.instance.find_activators(plugin_type: :input)
41
-
42
- @plugins = activators.map do |activator|
43
- activator.activate!
44
- activator.implementation_class.new
45
- end
46
- end
47
-
48
- #-------------------------------------------------------------#
49
- # Support for Profiles
50
- #-------------------------------------------------------------#
51
-
52
- def register_profile_alias(name, alias_name)
53
- @profile_aliases[name] = alias_name
54
- end
55
-
56
- # Returns an Hash, name => Input that have actually been mentioned
57
- def list_inputs_for_profile(profile)
58
- inputs_by_profile[profile] = {} unless profile_known?(profile)
59
- inputs_by_profile[profile]
60
- end
61
-
62
- # Returns an Array of input names. This includes input names
63
- # that plugins may be able to fetch, but have not actually been
64
- # mentioned in the control code.
65
- def list_potential_input_names_for_profile(profile_name)
66
- input_names_from_dsl = inputs_by_profile[profile_name].keys
67
- input_names_from_plugins = plugins.map { |plugin| plugin.list_inputs(profile_name) }
68
- (input_names_from_dsl + input_names_from_plugins).flatten.uniq
69
- end
70
-
71
- #-------------------------------------------------------------#
72
- # Support for Individual Inputs
73
- #-------------------------------------------------------------#
74
-
75
- def find_or_register_input(input_name, profile_name, options = {})
76
- input_name = input_name.to_s
77
- profile_name = profile_name.to_s
78
-
79
- if profile_alias?(profile_name) && !profile_aliases[profile_name].nil?
80
- alias_name = profile_name
81
- profile_name = profile_aliases[profile_name]
82
- handle_late_arriving_alias(alias_name, profile_name) if profile_known?(alias_name)
83
- end
84
-
85
- # Find or create the input
86
- inputs_by_profile[profile_name] ||= {}
87
- if inputs_by_profile[profile_name].key?(input_name)
88
- inputs_by_profile[profile_name][input_name].update(options)
89
- else
90
- inputs_by_profile[profile_name][input_name] = Inspec::Input.new(input_name, options)
91
- poll_plugins_for_update(profile_name, input_name)
92
- end
93
-
94
- inputs_by_profile[profile_name][input_name]
95
- end
96
-
97
- def poll_plugins_for_update(profile_name, input_name)
98
- plugins.each do |plugin|
99
- response = plugin.fetch(profile_name, input_name)
100
- evt = Inspec::Input::Event.new(
101
- action: :fetch,
102
- provider: plugin.class.plugin_name,
103
- priority: plugin.default_priority,
104
- hit: !response.nil?
105
- )
106
- evt.value = response unless response.nil?
107
- inputs_by_profile[profile_name][input_name].events << evt
108
- end
109
- end
110
-
111
- # It is possible for a wrapper profile to create an input in metadata,
112
- # referring to the child profile by an alias that has not yet been registered.
113
- # The registry will then store the inputs under the alias, as if the alias
114
- # were a true profile.
115
- # If that happens and the child profile also mentions the input, we will
116
- # need to move some things - all inputs should be stored under the true
117
- # profile name, and no inputs should be stored under the alias.
118
- def handle_late_arriving_alias(alias_name, profile_name)
119
- inputs_by_profile[profile_name] ||= {}
120
- inputs_by_profile[alias_name].each do |input_name, input_from_alias|
121
- # Move the inpuut, or if it exists, merge events
122
- existing = inputs_by_profile[profile_name][input_name]
123
- if existing
124
- existing.events.concat(input_from_alias.events)
125
- else
126
- inputs_by_profile[profile_name][input_name] = input_from_alias
127
- end
128
- end
129
- # Finally, delete the (now copied-out) entry for the alias
130
- inputs_by_profile.delete(alias_name)
131
- end
132
- #-------------------------------------------------------------#
133
- # Support for Binding Inputs
134
- #-------------------------------------------------------------#
135
-
136
- # This method is called by the Profile as soon as it has
137
- # enough context to allow binding inputs to it.
138
- def bind_profile_inputs(profile_name, sources = {})
139
- inputs_by_profile[profile_name] ||= {}
140
-
141
- # In a more perfect world, we could let the core plugins choose
142
- # self-determine what to do; but as-is, the APIs that call this
143
- # are a bit over-constrained.
144
- bind_inputs_from_metadata(profile_name, sources[:profile_metadata])
145
- bind_inputs_from_input_files(profile_name, sources[:cli_input_files])
146
- bind_inputs_from_runner_api(profile_name, sources[:runner_api])
147
- bind_inputs_from_cli_args(profile_name, sources[:cli_input_arg])
148
- end
149
-
150
- private
151
-
152
- def bind_inputs_from_cli_args(profile_name, input_list)
153
- # TODO: move this into a core plugin
154
-
155
- return if input_list.nil?
156
- return if input_list.empty?
157
-
158
- # These arrive as an array of "name=value" strings
159
- # If the user used a comma, we'll see unfortunately see it as "name=value," pairs
160
- input_list.each do |pair|
161
- unless pair.include?("=")
162
- if pair.end_with?(".yaml")
163
- raise ArgumentError, "ERROR: --input is used for individual input values, as --input name=value. Use --input-file to load a YAML file."
164
- else
165
- raise ArgumentError, "ERROR: An '=' is required when using --input. Usage: --input input_name1=input_value1 input2=value2"
166
- end
167
- end
168
- input_name, input_value = pair.split("=")
169
- evt = Inspec::Input::Event.new(
170
- value: input_value.chomp(","), # Trim trailing comma if any
171
- provider: :cli,
172
- priority: 50
173
- )
174
- find_or_register_input(input_name, profile_name, event: evt)
175
- end
176
- end
177
-
178
- def bind_inputs_from_runner_api(profile_name, input_hash)
179
- # TODO: move this into a core plugin
180
-
181
- return if input_hash.nil?
182
- return if input_hash.empty?
183
-
184
- # These arrive as a bare hash - values are raw values, not options
185
- input_hash.each do |input_name, input_value|
186
- loc = Inspec::Input::Event.probe_stack # TODO: likely modify this to look for a kitchen.yml, if that is realistic
187
- evt = Inspec::Input::Event.new(
188
- value: input_value,
189
- provider: :runner_api, # TODO: suss out if audit cookbook or kitchen-inspec or something unknown
190
- priority: 40,
191
- file: loc.path,
192
- line: loc.lineno
193
- )
194
- find_or_register_input(input_name, profile_name, event: evt)
195
- end
196
- end
197
-
198
- def bind_inputs_from_input_files(profile_name, file_list)
199
- # TODO: move this into a core plugin
200
-
201
- return if file_list.nil?
202
- return if file_list.empty?
203
-
204
- file_list.each do |path|
205
- validate_inputs_file_readability!(path)
206
-
207
- # TODO: drop this SecretsBackend stuff, will be handled by plugin system
208
- data = Inspec::SecretsBackend.resolve(path)
209
- if data.nil?
210
- raise Inspec::Exceptions::SecretsBackendNotFound,
211
- "Cannot find parser for inputs file '#{path}'. " \
212
- "Check to make sure file has the appropriate extension."
213
- end
214
-
215
- next if data.inputs.nil?
216
-
217
- data.inputs.each do |input_name, input_value|
218
- evt = Inspec::Input::Event.new(
219
- value: input_value,
220
- provider: :cli_files,
221
- priority: 40,
222
- file: path
223
- # TODO: any way we could get a line number?
224
- )
225
- find_or_register_input(input_name, profile_name, event: evt)
226
- end
227
- end
228
- end
229
-
230
- def validate_inputs_file_readability!(path)
231
- unless File.exist?(path)
232
- raise Inspec::Exceptions::InputsFileDoesNotExist,
233
- "Cannot find input file '#{path}'. " \
234
- "Check to make sure file exists."
235
- end
236
-
237
- unless File.readable?(path)
238
- raise Inspec::Exceptions::InputsFileNotReadable,
239
- "Cannot read input file '#{path}'. " \
240
- "Check to make sure file is readable."
241
- end
242
-
243
- true
244
- end
245
-
246
- def bind_inputs_from_metadata(profile_name, profile_metadata_obj)
247
- # TODO: move this into a core plugin
248
- return if profile_metadata_obj.nil? # Metadata files are technically optional
249
-
250
- if profile_metadata_obj.params.key?(:inputs)
251
- raw_inputs = profile_metadata_obj.params[:inputs]
252
- elsif profile_metadata_obj.params.key?(:attributes)
253
- Inspec.deprecate(:attrs_rename_in_metadata, "Profile: '#{profile_name}'.")
254
- raw_inputs = profile_metadata_obj.params[:attributes]
255
- else
256
- return
257
- end
258
-
259
- unless raw_inputs.is_a?(Array)
260
- Inspec::Log.warn "Inputs must be defined as an Array in metadata files. Skipping definition from #{profile_name}."
261
- return
262
- end
263
-
264
- raw_inputs.each { |i| handle_raw_input_from_metadata(i, profile_name) }
265
- end
266
-
267
- def handle_raw_input_from_metadata(input_orig, profile_name)
268
- input_options = input_orig.dup
269
- input_name = input_options.delete(:name)
270
- input_options[:provider] = :profile_metadata
271
- input_options[:file] = File.join(profile_name, "inspec.yml")
272
- input_options[:priority] ||= 30
273
- evt = Inspec::Input.infer_event(input_options)
274
-
275
- # Profile metadata may set inputs in other profiles by naming them.
276
- if input_options[:profile]
277
- profile_name = input_options[:profile] || profile_name
278
- # Override priority to force this to win. Allow user to set their own priority.
279
- evt.priority = input_orig[:priority] || 35
280
- end
281
- find_or_register_input(
282
- input_name,
283
- profile_name,
284
- type: input_options[:type],
285
- required: input_options[:required],
286
- event: evt
287
- )
288
- end
289
-
290
- #-------------------------------------------------------------#
291
- # Other Support
292
- #-------------------------------------------------------------#
293
- public
294
-
295
- # Used in testing
296
- def __reset
297
- @inputs_by_profile = {}
298
- @profile_aliases = {}
299
- end
300
-
301
- # These class methods are convenience methods so you don't always
302
- # have to call #instance when calling the registry
303
- %i{
304
- find_or_register_input
305
- register_profile_alias
306
- list_inputs_for_profile
307
- list_potential_input_names_for_profile
308
- bind_profile_inputs
309
- }.each do |meth|
310
- define_singleton_method(meth) do |*args|
311
- instance.send(meth, *args)
312
- end
313
- end
314
- end
315
- end
@@ -1,55 +0,0 @@
1
- require "inspec/plugin/v1/plugin_types/resource"
2
- require "inspec/dsl_shared"
3
-
4
- module Inspec
5
- #
6
- # LibaryEvalContext constructs an instance of an anonymous class
7
- # that library files will be instance_exec'd against.
8
- #
9
- # The anonymous class ensures that `Inspec.resource(1)` will return
10
- # an anonymouse class that is suitable as the parent class of an
11
- # inspec resource. The class returned will have the resource
12
- # registry used by all dsl methods bound to the resource registry
13
- # passed into the #create constructor.
14
- #
15
- #
16
- class LibraryEvalContext
17
- def self.create(registry, require_loader)
18
- c = Class.new do
19
- extend Inspec::ResourceDSL
20
- include Inspec::ResourceBehaviors
21
- define_singleton_method :__resource_registry do
22
- registry
23
- end
24
- end
25
-
26
- c2 = Class.new do
27
- define_singleton_method :resource do |version|
28
- Inspec.validate_resource_dsl_version!(version)
29
- c
30
- end
31
- end
32
-
33
- c3 = Class.new do
34
- include Inspec::DSL::RequireOverride
35
- def initialize(require_loader)
36
- @require_loader = require_loader
37
- @inspec_binding = nil
38
- end
39
-
40
- def __inspec_binding
41
- @inspec_binding
42
- end
43
- end
44
-
45
- c3.const_set(:Inspec, c2)
46
- res = c3.new(require_loader)
47
-
48
- # Provide the local binding for this context which is necessary for
49
- # calls to `require` to create all dependent objects in the correct
50
- # context.
51
- res.instance_variable_set("@inspec_binding", res.instance_eval("binding"))
52
- res
53
- end
54
- end
55
- end
@@ -1,7 +0,0 @@
1
- require "mixlib/log"
2
-
3
- module Inspec
4
- class Log
5
- extend Mixlib::Log
6
- end
7
- end
@@ -1,253 +0,0 @@
1
- # Copyright 2015 Dominik Richter
2
-
3
- require "logger"
4
- require "rubygems/version"
5
- require "rubygems/requirement"
6
- require "semverse"
7
-
8
- require "inspec/version"
9
- require "inspec/utils/spdx"
10
-
11
- module Inspec
12
- # Extract metadata.rb information
13
- # A Metadata object may be created and finalized with invalid data.
14
- # This allows the check CLI command to analyse the issues.
15
- # Use valid? to determine if the metadata is coherent.
16
- class Metadata
17
- attr_reader :ref
18
- attr_accessor :params, :content
19
- def initialize(ref, logger = nil)
20
- @ref = ref
21
- @logger = logger || Logger.new(nil)
22
- @content = ""
23
- @params = {}
24
- @missing_methods = []
25
- end
26
-
27
- %w{
28
- name
29
- title
30
- maintainer
31
- maintainer_email
32
- copyright
33
- copyright_email
34
- license
35
- summary
36
- description
37
- version
38
- inspec_version
39
- }.each do |name|
40
- define_method name.to_sym do |arg|
41
- params[name.to_sym] = arg
42
- end
43
- end
44
-
45
- def dependencies
46
- params[:depends] || []
47
- end
48
-
49
- def supports(sth, version = nil)
50
- # Ignore supports with metadata.rb. This file is legacy and the way it
51
- # it handles `supports` deprecated. A deprecation warning will be printed
52
- # already.
53
- end
54
-
55
- def inspec_requirement
56
- # using Gem::Requirement here to allow nil values which
57
- # translate to [">= 0"]
58
- Gem::Requirement.create(params[:inspec_version])
59
- end
60
-
61
- def supports_runtime?
62
- running = Gem::Version.new(Inspec::VERSION)
63
- inspec_requirement.satisfied_by?(running)
64
- end
65
-
66
- def supports_platform?(backend)
67
- require "inspec/resources/platform" # break circularity in load
68
- backend.platform.supported?(params[:supports])
69
- end
70
-
71
- # return all warn and errors
72
- def valid # rubocop:disable Metrics/AbcSize
73
- errors = []
74
- warnings = []
75
-
76
- %w{name version}.each do |field|
77
- next unless params[field.to_sym].nil?
78
-
79
- errors.push("Missing profile #{field} in #{ref}")
80
- end
81
-
82
- if %r{[\/\\]} =~ params[:name]
83
- errors.push("The profile name (#{params[:name]}) contains a slash" \
84
- " which is not permitted. Please remove all slashes from `inspec.yml`.")
85
- end
86
-
87
- # if version is set, ensure it is correct
88
- if !params[:version].nil? && !valid_version?(params[:version])
89
- errors.push("Version needs to be in SemVer format")
90
- end
91
-
92
- unless supports_runtime?
93
- warnings.push("The current inspec version #{Inspec::VERSION} cannot satisfy profile inspec_version constraint #{params[:inspec_version]}")
94
- end
95
-
96
- %w{title summary maintainer copyright license}.each do |field|
97
- next unless params[field.to_sym].nil?
98
-
99
- warnings.push("Missing profile #{field} in #{ref}")
100
- end
101
-
102
- # if license is set, ensure it is in SPDX format or marked as proprietary
103
- if !params[:license].nil? && !valid_license?(params[:license])
104
- warnings.push("License '#{params[:license]}' needs to be in SPDX format or marked as 'Proprietary'. See https://spdx.org/licenses/.")
105
- end
106
-
107
- [errors, warnings]
108
- end
109
-
110
- # returns true or false
111
- def valid?
112
- errors, _warnings = valid
113
- errors.empty? && unsupported.empty?
114
- end
115
-
116
- def valid_version?(value)
117
- Semverse::Version.new(value)
118
- true
119
- rescue Semverse::InvalidVersionFormat
120
- false
121
- end
122
-
123
- def valid_license?(value)
124
- value =~ /^Proprietary[,;]?\b/ || Spdx.valid_license?(value)
125
- end
126
-
127
- def method_missing(sth, *args)
128
- @logger.warn "#{ref} doesn't support: #{sth} #{args}"
129
- @missing_methods.push(sth)
130
- end
131
-
132
- def unsupported
133
- @missing_methods
134
- end
135
-
136
- def self.symbolize_keys(obj)
137
- return obj.map { |i| symbolize_keys(i) } if obj.is_a?(Array)
138
- return obj unless obj.is_a?(Hash)
139
-
140
- obj.each_with_object({}) do |(k, v), h|
141
- v = symbolize_keys(v) if v.is_a?(Hash)
142
- v = symbolize_keys(v) if v.is_a?(Array)
143
- h[k.to_sym] = v
144
- end
145
- end
146
-
147
- def self.finalize_supports_elem(elem, logger)
148
- case x = elem
149
- when Hash
150
- x[:release] = x[:release].to_s if x[:release]
151
- x
152
- when Array
153
- logger.warn(
154
- "Failed to read supports entry that is an array. Please use "\
155
- "the `supports: {os-family: xyz}` syntax."
156
- )
157
- nil
158
- when nil then nil
159
- else
160
- Inspec.deprecate(
161
- :supports_syntax,
162
- "Do not use deprecated `supports: #{x}` syntax. Instead use:\n"\
163
- "supports:\n - os-family: #{x}\n\n"
164
- )
165
-
166
- { :'os-family' => x } # rubocop:disable Style/HashSyntax
167
- end
168
- end
169
-
170
- def self.finalize_supports(supports, logger)
171
- case x = supports
172
- when Hash then [finalize_supports_elem(x, logger)]
173
- when Array then x.map { |e| finalize_supports_elem(e, logger) }.compact
174
- when nil then []
175
- end
176
- end
177
-
178
- def self.finalize_name(metadata, profile_id, original_target)
179
- # profile_id always overwrites whatever already exists as the name
180
- unless profile_id.to_s.empty?
181
- metadata.params[:name] = profile_id.to_s
182
- return
183
- end
184
-
185
- # don't overwrite an existing name
186
- return unless metadata.params[:name].nil?
187
-
188
- # if there's a title, there is no need to set a name too
189
- return unless metadata.params[:title].nil?
190
-
191
- # create a new name based on the original target if it exists
192
- # Crudely slug the target to not contain slashes, to avoid breaking
193
- # unit tests that look for warning sequences
194
- return if original_target.to_s.empty?
195
-
196
- metadata.params[:title] = "tests from #{original_target}"
197
- metadata.params[:name] = metadata.params[:title].gsub(%r{[\/\\]}, ".")
198
- end
199
-
200
- def self.finalize(metadata, profile_id, options, logger = nil)
201
- return nil if metadata.nil?
202
-
203
- param = metadata.params || {}
204
- options ||= {}
205
- param["version"] = param["version"].to_s unless param["version"].nil?
206
- metadata.params = symbolize_keys(param)
207
- metadata.params[:supports] = finalize_supports(metadata.params[:supports], logger)
208
- finalize_name(metadata, profile_id, options[:target])
209
-
210
- metadata
211
- end
212
-
213
- def self.from_yaml(ref, content, profile_id, logger = nil)
214
- require "erb"
215
- res = Metadata.new(ref, logger)
216
- res.params = YAML.load(ERB.new(content).result)
217
- res.content = content
218
- finalize(res, profile_id, {}, logger)
219
- end
220
-
221
- def self.from_ruby(ref, content, profile_id, logger = nil)
222
- res = Metadata.new(ref, logger)
223
- res.instance_eval(content, ref, 1)
224
- res.content = content
225
- finalize(res, profile_id, {}, logger)
226
- end
227
-
228
- def self.from_ref(ref, content, profile_id, logger = nil)
229
- # NOTE there doesn't have to exist an actual file, it may come from an
230
- # archive (i.e., content)
231
- case File.basename(ref)
232
- when "inspec.yml"
233
- from_yaml(ref, content, profile_id, logger)
234
- when "metadata.rb"
235
- from_ruby(ref, content, profile_id, logger)
236
- else
237
- logger ||= Logger.new(nil)
238
- logger.error "Don't know how to handle metadata in #{ref}"
239
- nil
240
- end
241
- end
242
-
243
- def self.from_file(path, profile_id, logger = nil)
244
- unless File.file?(path)
245
- logger ||= Logger.new(nil)
246
- logger.error "Can't find metadata file #{path}"
247
- return nil
248
- end
249
-
250
- from_ref(File.basename(path), File.read(path), profile_id, logger)
251
- end
252
- end
253
- end