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,34 +0,0 @@
1
- require "inspec/fetcher"
2
-
3
- module Inspec::Fetcher
4
- class Mock < Inspec.fetcher(1)
5
- name "mock"
6
- priority 0
7
-
8
- def self.resolve(target)
9
- return nil unless target.is_a? Hash
10
-
11
- new(target)
12
- end
13
-
14
- def initialize(data)
15
- @data = data
16
- end
17
-
18
- def fetch(_path)
19
- archive_path
20
- end
21
-
22
- def archive_path
23
- { mock: @data }
24
- end
25
-
26
- def resolved_source
27
- { mock_fetcher: true }
28
- end
29
-
30
- def cache_key
31
- ""
32
- end
33
- end
34
- end
@@ -1,281 +0,0 @@
1
- require "uri"
2
- require "openssl"
3
- require "tempfile"
4
- require "open-uri"
5
-
6
- module Inspec::Fetcher
7
- class Url < Inspec.fetcher(1)
8
- MIME_TYPES = {
9
- "application/x-zip-compressed" => ".zip",
10
- "application/zip" => ".zip",
11
- "application/x-gzip" => ".tar.gz",
12
- "application/gzip" => ".tar.gz",
13
- }.freeze
14
-
15
- name "url"
16
- priority 200
17
-
18
- def self.resolve(target, opts = {})
19
- if target.is_a?(Hash) && target.key?(:url)
20
- resolve_from_string(target[:url], opts, target[:username], target[:password])
21
- elsif target.is_a?(String)
22
- resolve_from_string(target, opts)
23
- elsif target.is_a?(URI)
24
- resolve_from_string(target.to_s, opts)
25
- end
26
- end
27
-
28
- def self.resolve_from_string(target, opts, username = nil, password = nil)
29
- uri = URI.parse(target)
30
- return nil if uri.nil? || uri.scheme.nil?
31
- return nil unless %{ http https }.include? uri.scheme
32
-
33
- target = transform(target)
34
- opts[:username] = username if username
35
- opts[:password] = password if password
36
- new(target, opts)
37
- rescue URI::Error
38
- nil
39
- end
40
-
41
- # Transforms a browser github/bitbucket url to github/bitbucket tar url
42
- # We distinguish between three different Github/Bitbucket URL types:
43
- # - Master URL
44
- # - Branch URL
45
- # - Commit URL
46
- #
47
- # master url:
48
- # https://github.com/nathenharvey/tmp_compliance_profile/ is transformed to
49
- # https://github.com/nathenharvey/tmp_compliance_profile/archive/master.tar.gz
50
- # https://bitbucket.org/username/repo is transformed to
51
- # https://bitbucket.org/username/repo/get/master.tar.gz
52
- #
53
- # branch:
54
- # https://github.com/hardening-io/tests-os-hardening/tree/2.0 is transformed to
55
- # https://github.com/hardening-io/tests-os-hardening/archive/2.0.tar.gz
56
- # https://bitbucket.org/username/repo/branch/branchname is transformed to
57
- # https://bitbucket.org/username/repo/get/newbranch.tar.gz
58
- #
59
- # commit:
60
- # https://github.com/hardening-io/tests-os-hardening/tree/48bd4388ddffde68badd83aefa654e7af3231876
61
- # is transformed to
62
- # https://github.com/hardening-io/tests-os-hardening/archive/48bd4388ddffde68badd83aefa654e7af3231876.tar.gz
63
- # https://bitbucket.org/username/repo/commits/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc is transformed to
64
- # https://bitbucket.org/username/repo/get/95ce1f83d5bbe9eec34c5973f6894617e8d6d8cc.tar.gz
65
-
66
- GITHUB_URL_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w.-]+?)(\.git)?(/)?$}.freeze
67
- GITHUB_URL_WITH_TREE_REGEX = %r{^https?://(www\.)?github\.com/(?<user>[\w-]+)/(?<repo>[\w.-]+)/tree/(?<commit>[\w\.]+)(/)?$}.freeze
68
- BITBUCKET_URL_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)(\.git)?(/)?$}.freeze
69
- BITBUCKET_URL_BRANCH_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)/branch/(?<branch>[\w\.]+)(/)?$}.freeze
70
- BITBUCKET_URL_COMMIT_REGEX = %r{^https?://(www\.)?bitbucket\.org/(?<user>[\w-]+)/(?<repo>[\w-]+)/commits/(?<commit>[\w\.]+)(/)?$}.freeze
71
-
72
- def self.transform(target)
73
- transformed_target = if m = GITHUB_URL_REGEX.match(target) # rubocop:disable Lint/AssignmentInCondition
74
- "https://github.com/#{m[:user]}/#{m[:repo]}/archive/master.tar.gz"
75
- elsif m = GITHUB_URL_WITH_TREE_REGEX.match(target) # rubocop:disable Lint/AssignmentInCondition
76
- "https://github.com/#{m[:user]}/#{m[:repo]}/archive/#{m[:commit]}.tar.gz"
77
- elsif m = BITBUCKET_URL_REGEX.match(target) # rubocop:disable Lint/AssignmentInCondition
78
- "https://bitbucket.org/#{m[:user]}/#{m[:repo]}/get/master.tar.gz"
79
- elsif m = BITBUCKET_URL_BRANCH_REGEX.match(target) # rubocop:disable Lint/AssignmentInCondition
80
- "https://bitbucket.org/#{m[:user]}/#{m[:repo]}/get/#{m[:branch]}.tar.gz"
81
- elsif m = BITBUCKET_URL_COMMIT_REGEX.match(target) # rubocop:disable Lint/AssignmentInCondition
82
- "https://bitbucket.org/#{m[:user]}/#{m[:repo]}/get/#{m[:commit]}.tar.gz"
83
- end
84
-
85
- if transformed_target
86
- Inspec::Log.warn("URL target #{target} transformed to #{transformed_target}. Consider using the git fetcher")
87
- transformed_target
88
- else
89
- target
90
- end
91
- end
92
-
93
- attr_reader :files, :archive_path
94
-
95
- def initialize(url, opts)
96
- @target = url.to_s
97
- @target_uri = url.is_a?(URI) ? url : parse_uri(url)
98
- @insecure = opts["insecure"]
99
- @token = opts["token"]
100
- @config = opts
101
- @archive_path = nil
102
- @temp_archive_path = nil
103
- end
104
-
105
- def fetch(path)
106
- @archive_path ||= download_archive(path)
107
- end
108
-
109
- def resolved_source
110
- @resolved_source ||= { url: @target, sha256: sha256 }
111
- end
112
-
113
- def cache_key
114
- @archive_shasum ||= sha256
115
- end
116
-
117
- def to_s
118
- @target
119
- end
120
-
121
- private
122
-
123
- def parse_uri(target)
124
- return URI.parse(target) if target.is_a?(String)
125
-
126
- URI.parse(target[:url])
127
- end
128
-
129
- def sha256
130
- file = @archive_path || temp_archive_path
131
- OpenSSL::Digest::SHA256.digest(File.read(file)).unpack("H*")[0]
132
- end
133
-
134
- def file_type_from_remote(remote)
135
- content_type = remote.meta["content-type"]
136
- file_type = MIME_TYPES[content_type]
137
-
138
- if file_type.nil?
139
- Inspec::Log.warn("Unrecognized content type: #{content_type}. Assuming tar.gz")
140
- file_type = ".tar.gz"
141
- end
142
-
143
- file_type
144
- end
145
-
146
- def temp_archive_path
147
- @temp_archive_path ||= if @config["server_type"] == "automate2"
148
- download_automate2_archive_to_temp
149
- else
150
- download_archive_to_temp
151
- end
152
- end
153
-
154
- def download_automate2_archive_to_temp
155
- return @temp_archive_path unless @temp_archive_path.nil?
156
-
157
- Inspec::Log.debug("Fetching URL: #{@target}")
158
- json = {
159
- owner: @config["profile"][0],
160
- name: @config["profile"][1],
161
- version: @config["profile"][2],
162
- }.to_json
163
-
164
- opts = http_opts
165
- opts[:use_ssl] = @target_uri.scheme == "https"
166
-
167
- if @insecure
168
- opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
169
- else
170
- opts[:verify_mode] = OpenSSL::SSL::VERIFY_PEER
171
- end
172
-
173
- req = Net::HTTP::Post.new(@target_uri)
174
- opts.each do |key, value|
175
- req.add_field(key, value)
176
- end
177
- req.body = json
178
- res = Net::HTTP.start(@target_uri.host, @target_uri.port, opts) do |http|
179
- http.request(req)
180
- end
181
-
182
- @archive_type = ".tar.gz"
183
- archive = Tempfile.new(["inspec-dl-", @archive_type])
184
- archive.binmode
185
- archive.write(res.body)
186
- archive.rewind
187
- archive.close
188
- Inspec::Log.debug("Archive stored at temporary location: #{archive.path}")
189
- @temp_archive_path = archive.path
190
- end
191
-
192
- # Downloads archive to temporary file with side effect :( of setting @archive_type
193
- def download_archive_to_temp
194
- return @temp_archive_path unless @temp_archive_path.nil?
195
-
196
- Inspec::Log.debug("Fetching URL: #{@target}")
197
- remote = open_via_uri(@target)
198
- @archive_type = file_type_from_remote(remote) # side effect :(
199
- archive = Tempfile.new(["inspec-dl-", @archive_type])
200
- archive.binmode
201
- archive.write(remote.read)
202
- archive.rewind
203
- archive.close
204
- Inspec::Log.debug("Archive stored at temporary location: #{archive.path}")
205
- @temp_archive_path = archive.path
206
- end
207
-
208
- def open(target, opts) # overridden so we can control who we're talking to
209
- URI.open(target, opts)
210
- rescue NoMethodError # TODO: remove when we drop ruby 2.4
211
- super(target, opts) # Kernel#open
212
- end
213
-
214
- def open_via_uri(target)
215
- opts = http_opts
216
-
217
- # OpenURI does not support userinfo so we need to remove it
218
- # https://ruby-doc.org/stdlib-2.5.0/libdoc/open-uri/rdoc/OpenURI/OpenRead.html#method-i-open
219
- target = target.sub("#{@target_uri.userinfo}@", "") if
220
- opts[:http_basic_authentication]
221
-
222
- open(target, opts)
223
-
224
- rescue SocketError, Errno::ECONNREFUSED, OpenURI::HTTPError => e
225
- raise Inspec::FetcherFailure, "Profile URL dependency #{target} could not be fetched: #{e.message}"
226
- end
227
-
228
- def download_archive(path)
229
- temp_archive_path
230
- final_path = "#{path}#{@archive_type}"
231
- FileUtils.mkdir_p(File.dirname(final_path))
232
- FileUtils.mv(temp_archive_path, final_path)
233
- Inspec::Log.debug("Fetched archive moved to: #{final_path}")
234
- @temp_archive_path = nil
235
- final_path
236
- end
237
-
238
- def http_opts
239
- opts = {}
240
- opts[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE if @insecure
241
-
242
- if @config["server_type"] =~ /automate/
243
- opts["chef-delivery-enterprise"] = @config["automate"]["ent"]
244
- if @config["automate"]["token_type"] == "dctoken"
245
- opts["x-data-collector-token"] = @config["token"]
246
- else
247
- opts["chef-delivery-user"] = @config["user"]
248
- opts["chef-delivery-token"] = @config["token"]
249
- end
250
- elsif @token
251
- opts["Authorization"] = "Bearer #{@token}"
252
- end
253
-
254
- username = @config[:username] || @target_uri.user
255
- password = @config[:password] || @target_uri.password
256
- opts[:http_basic_authentication] = [username, password] if username
257
-
258
- # Do not send any headers that have nil values.
259
- # Net::HTTP does not gracefully handle this situation.
260
- check_for_missing_values!(opts)
261
-
262
- opts
263
- end
264
-
265
- def check_for_missing_values!(opts)
266
- keys_missing_values = opts.keys.delete_if do |k|
267
- if opts[k].nil?
268
- false
269
- elsif opts[k].respond_to?(:empty?) && opts[k].empty?
270
- false
271
- else
272
- true
273
- end
274
- end
275
- unless keys_missing_values.empty?
276
- raise Inspec::FetcherFailure, "Unable to fetch profile - the following HTTP headers have no value: " \
277
- "#{keys_missing_values.join(", ")}"
278
- end
279
- end
280
- end
281
- end
@@ -1,318 +0,0 @@
1
- require "rubygems/package"
2
- require "pathname"
3
- require "zlib"
4
- require "zip"
5
-
6
- module Inspec
7
- class FileProvider
8
- def self.for_path(path)
9
- if path.is_a?(Hash)
10
- MockProvider.new(path)
11
- elsif File.directory?(path)
12
- DirProvider.new(path)
13
- elsif File.exist?(path) && path.end_with?(".tar.gz", "tgz")
14
- TarProvider.new(path)
15
- elsif File.exist?(path) && path.end_with?(".zip")
16
- ZipProvider.new(path)
17
- elsif File.exist?(path)
18
- DirProvider.new(path)
19
- else
20
- raise "No file provider for the provided path: #{path}"
21
- end
22
- end
23
-
24
- def initialize(_path); end
25
-
26
- # List all files that are offered.
27
- #
28
- # @return [Array[String]] list of file paths that are included
29
- def files
30
- raise "Fetcher #{self} does not implement `files()`. This is required."
31
- end
32
-
33
- # Read the contents of a file. This will typically refer to a text
34
- # file reading a string.
35
- #
36
- # @param _file [String] path of the file to be read
37
- # @return [String] contents of the file described
38
- def read(_file)
39
- raise "#{self} does not implement `read(...)`. This is required."
40
- end
41
-
42
- # Provide a method for reading binary contents from a file.
43
- # It will default to #read if not defined. For most streams that implement
44
- # it, it will be the same. For some special cases, it will add change the
45
- # way in which encoding of the returned data structure is handled.
46
- # Does not work with alias nor alias_method.
47
- def binread(file)
48
- read(file)
49
- end
50
-
51
- def relative_provider
52
- RelativeFileProvider.new(self)
53
- end
54
- end # class FileProvider
55
-
56
- class MockProvider < FileProvider
57
- attr_reader :files
58
- def initialize(path)
59
- @data = path[:mock]
60
- @files = @data.keys
61
- end
62
-
63
- def read(file)
64
- @data[file]
65
- end
66
- end
67
-
68
- class DirProvider < FileProvider
69
- attr_reader :files
70
- def initialize(path)
71
- @files = if File.file?(path)
72
- [path]
73
- else
74
- Dir[File.join(Shellwords.shellescape(path), "**", "*")]
75
- end
76
- @path = path
77
- end
78
-
79
- def read(file)
80
- return nil unless files.include?(file)
81
- return nil unless File.file?(file)
82
-
83
- File.read(file)
84
- end
85
-
86
- def binread(file)
87
- return nil unless files.include?(file)
88
- return nil unless File.file?(file)
89
-
90
- File.binread(file)
91
- end
92
- end # class DirProvider
93
-
94
- class ZipProvider < FileProvider
95
- attr_reader :files
96
-
97
- def initialize(path)
98
- @path = path
99
- @contents = {}
100
- @files = []
101
- walk_zip(@path) do |io|
102
- while (entry = io.get_next_entry)
103
- name = entry.name.sub(%r{/+$}, "")
104
- @files.push(name) unless name.empty? || name.squeeze("/") =~ %r{\.{2}(?:/|\z)}
105
- end
106
- end
107
- end
108
-
109
- def extract(destination_path = ".")
110
- FileUtils.mkdir_p(destination_path)
111
-
112
- Zip::File.open(@path) do |archive|
113
- archive.each do |file|
114
- final_path = File.join(destination_path, file.name)
115
-
116
- # This removes the top level directory (and any other files) to ensure
117
- # extracted files do not conflict.
118
- FileUtils.remove_entry(final_path) if File.exist?(final_path)
119
-
120
- archive.extract(file, final_path)
121
- end
122
- end
123
- end
124
-
125
- def read(file)
126
- # TODO: this is inefficient
127
- @contents[file] ||= read_from_zip(file)
128
- end
129
-
130
- private
131
-
132
- def walk_zip(path, &callback)
133
- ::Zip::InputStream.open(path, &callback)
134
- end
135
-
136
- def read_from_zip(file)
137
- return nil unless @files.include?(file)
138
-
139
- res = nil
140
- walk_zip(@path) do |io|
141
- while (entry = io.get_next_entry)
142
- next unless file == entry.name
143
-
144
- res = io.read
145
- try = res.dup
146
- try.force_encoding Encoding::UTF_8
147
- res = try.encode(try.encoding, universal_newline: true) if try.valid_encoding?
148
-
149
- break
150
- end
151
- end
152
- res
153
- end
154
- end # class ZipProvider
155
-
156
- class TarProvider < FileProvider
157
- attr_reader :files
158
-
159
- def initialize(path)
160
- @path = path
161
- @contents = {}
162
-
163
- here = Pathname.new(".")
164
-
165
- walk_tar(@path) do |entries|
166
- entries.each do |entry|
167
- name = entry.full_name
168
-
169
- # rubocop:disable Layout/MultilineOperationIndentation
170
- # rubocop:disable Style/ParenthesesAroundCondition
171
- next unless (entry.file? && # duh
172
- !name.empty? && # for empty filenames?
173
- name !~ %r{\.\.(?:/|\z)} && # .. (to avoid attacks?)
174
- !name.include?("PaxHeader/"))
175
-
176
- path = Pathname.new(name).relative_path_from(here).to_s
177
-
178
- @contents[path] = begin # not ||= in a tarball, last one wins
179
- res = entry.read || ""
180
- try = res.dup
181
- try.force_encoding Encoding::UTF_8
182
- res = try.encode(try.encoding, universal_newline: true) if
183
- try.valid_encoding?
184
- res
185
- end
186
- end
187
-
188
- @files = @contents.keys
189
- end
190
- end
191
-
192
- def extract(destination_path = ".")
193
- FileUtils.mkdir_p(destination_path)
194
-
195
- @contents.each do |path, body|
196
- full_path = File.join(destination_path, path)
197
-
198
- FileUtils.mkdir_p(File.dirname(full_path))
199
- File.open(full_path, "wb") { |f| f.write(body) }
200
- end
201
- end
202
-
203
- def read(file)
204
- @contents[file]
205
- end
206
-
207
- private
208
-
209
- def walk_tar(path, &callback)
210
- tar_file = Zlib::GzipReader.open(path)
211
- Gem::Package::TarReader.new(tar_file, &callback)
212
- ensure
213
- tar_file.close
214
- end
215
- end # class TarProvider
216
-
217
- class RelativeFileProvider
218
- BLACKLIST_FILES = [
219
- "/pax_global_header",
220
- "pax_global_header",
221
- ].freeze
222
-
223
- attr_reader :files
224
- attr_reader :prefix
225
- attr_reader :parent
226
-
227
- def initialize(parent_provider)
228
- @parent = parent_provider
229
- @prefix = get_prefix(parent.files)
230
- if @prefix.nil?
231
- raise "Could not determine path prefix for #{parent}"
232
- end
233
-
234
- # select all files that begin with the prefix, and strip off the prefix from the file.
235
- #
236
- # strip off any leading top-level relative path (./) which is common in
237
- # PAX-formatted tar files. Do not do any translation of the path if the
238
- # path is an absolute path.
239
- @files = parent.files
240
- .find_all { |x| x.start_with?(prefix) && x != prefix }
241
- .map { |x| x[prefix.length..-1] }
242
- .map do |x|
243
- path = Pathname.new(x)
244
- path.absolute? ? path.to_s : path.relative_path_from(Pathname.new(".")).to_s
245
- end
246
- end
247
-
248
- def abs_path(file)
249
- return nil if file.nil?
250
-
251
- prefix + file
252
- end
253
-
254
- def read(file)
255
- parent.read(abs_path(file))
256
- end
257
-
258
- def binread(file)
259
- parent.binread(abs_path(file))
260
- end
261
-
262
- private
263
-
264
- def get_prefix(fs)
265
- return "" if fs.empty?
266
-
267
- # filter backlisted files
268
- fs -= BLACKLIST_FILES
269
-
270
- sorted = fs.sort_by(&:length)
271
- get_folder_prefix(sorted)
272
- end
273
-
274
- def prefix_candidate_for(file)
275
- if file.end_with?(File::SEPARATOR)
276
- file
277
- else
278
- file + File::SEPARATOR
279
- end
280
- end
281
-
282
- def get_folder_prefix(fs)
283
- return get_files_prefix(fs) if fs.length == 1
284
-
285
- first, *rest = fs
286
- pre = prefix_candidate_for(first)
287
-
288
- if rest.all? { |i| i.start_with? pre }
289
- return get_folder_prefix(rest)
290
- end
291
-
292
- get_files_prefix(fs)
293
- end
294
-
295
- def get_files_prefix(fs)
296
- return "" if fs.empty?
297
-
298
- file = fs[0]
299
- bn = File.basename(file)
300
- # no more prefixes
301
- return "" if bn == file
302
-
303
- i = file.rindex(bn)
304
- pre = file[0..i - 1]
305
-
306
- rest = fs.find_all { |f| !f.start_with?(pre) }
307
- return pre if rest.empty?
308
-
309
- new_pre = get_prefix(rest)
310
- return new_pre if pre.start_with? new_pre
311
-
312
- # edge case: completely different prefixes; retry prefix detection
313
- a = File.dirname(pre + "a")
314
- b = File.dirname(new_pre + "b")
315
- get_prefix([a, b])
316
- end
317
- end # class RelativeFileProvider
318
- end