inspec-core 4.3.2 → 4.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -21
  3. data/etc/deprecations.json +10 -0
  4. data/etc/plugin_filters.json +8 -0
  5. data/lib/bundles/inspec-compliance/api.rb +1 -1
  6. data/lib/bundles/inspec-compliance/configuration.rb +1 -1
  7. data/lib/bundles/inspec-compliance/http.rb +1 -1
  8. data/lib/bundles/inspec-compliance/support.rb +1 -1
  9. data/lib/bundles/inspec-compliance/target.rb +1 -1
  10. data/lib/bundles/inspec-supermarket.rb +3 -7
  11. data/lib/bundles/inspec-supermarket/api.rb +10 -13
  12. data/lib/bundles/inspec-supermarket/cli.rb +12 -15
  13. data/lib/bundles/inspec-supermarket/target.rb +7 -11
  14. data/lib/fetchers/git.rb +14 -15
  15. data/lib/fetchers/local.rb +6 -10
  16. data/lib/fetchers/mock.rb +3 -5
  17. data/lib/fetchers/url.rb +42 -44
  18. data/lib/inspec.rb +23 -24
  19. data/lib/inspec/archive/tar.rb +2 -6
  20. data/lib/inspec/archive/zip.rb +3 -7
  21. data/lib/inspec/backend.rb +8 -9
  22. data/lib/inspec/base_cli.rb +64 -65
  23. data/lib/inspec/cached_fetcher.rb +2 -3
  24. data/lib/inspec/cli.rb +136 -97
  25. data/lib/inspec/config.rb +71 -61
  26. data/lib/inspec/control_eval_context.rb +22 -18
  27. data/lib/inspec/dependencies/cache.rb +2 -3
  28. data/lib/inspec/dependencies/dependency_set.rb +2 -3
  29. data/lib/inspec/dependencies/lockfile.rb +8 -9
  30. data/lib/inspec/dependencies/requirement.rb +7 -8
  31. data/lib/inspec/dependencies/resolver.rb +5 -7
  32. data/lib/inspec/describe.rb +2 -6
  33. data/lib/inspec/dist.rb +20 -0
  34. data/lib/inspec/dsl.rb +4 -7
  35. data/lib/inspec/dsl_shared.rb +1 -2
  36. data/lib/inspec/env_printer.rb +11 -12
  37. data/lib/inspec/errors.rb +0 -4
  38. data/lib/inspec/exceptions.rb +0 -1
  39. data/lib/inspec/expect.rb +5 -8
  40. data/lib/inspec/fetcher.rb +7 -10
  41. data/lib/inspec/file_provider.rb +24 -24
  42. data/lib/inspec/formatters.rb +3 -3
  43. data/lib/inspec/formatters/base.rb +8 -8
  44. data/lib/inspec/globals.rb +2 -2
  45. data/lib/inspec/impact.rb +5 -7
  46. data/lib/inspec/input_registry.rb +84 -33
  47. data/lib/inspec/library_eval_context.rb +3 -6
  48. data/lib/inspec/log.rb +1 -5
  49. data/lib/inspec/metadata.rb +17 -16
  50. data/lib/inspec/method_source.rb +5 -9
  51. data/lib/inspec/objects.rb +10 -12
  52. data/lib/inspec/objects/control.rb +7 -9
  53. data/lib/inspec/objects/describe.rb +9 -11
  54. data/lib/inspec/objects/each_loop.rb +1 -3
  55. data/lib/inspec/objects/input.rb +24 -26
  56. data/lib/inspec/objects/list.rb +4 -6
  57. data/lib/inspec/objects/or_test.rb +2 -4
  58. data/lib/inspec/objects/ruby_helper.rb +3 -5
  59. data/lib/inspec/objects/tag.rb +0 -2
  60. data/lib/inspec/objects/test.rb +9 -11
  61. data/lib/inspec/objects/value.rb +3 -5
  62. data/lib/inspec/plugin/v1.rb +2 -2
  63. data/lib/inspec/plugin/v1/plugin_types/cli.rb +1 -5
  64. data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +2 -5
  65. data/lib/inspec/plugin/v1/plugin_types/resource.rb +4 -6
  66. data/lib/inspec/plugin/v1/plugin_types/secret.rb +1 -5
  67. data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +1 -5
  68. data/lib/inspec/plugin/v1/plugins.rb +15 -19
  69. data/lib/inspec/plugin/v1/registry.rb +0 -4
  70. data/lib/inspec/plugin/v2.rb +8 -8
  71. data/lib/inspec/plugin/v2/activator.rb +1 -1
  72. data/lib/inspec/plugin/v2/config_file.rb +6 -6
  73. data/lib/inspec/plugin/v2/filter.rb +13 -13
  74. data/lib/inspec/plugin/v2/installer.rb +36 -24
  75. data/lib/inspec/plugin/v2/loader.rb +28 -28
  76. data/lib/inspec/plugin/v2/plugin_base.rb +15 -2
  77. data/lib/inspec/plugin/v2/plugin_types/cli.rb +5 -5
  78. data/lib/inspec/plugin/v2/plugin_types/input.rb +34 -0
  79. data/lib/inspec/plugin/v2/plugin_types/mock.rb +1 -1
  80. data/lib/inspec/plugin/v2/registry.rb +7 -7
  81. data/lib/inspec/polyfill.rb +0 -3
  82. data/lib/inspec/profile.rb +55 -63
  83. data/lib/inspec/profile_context.rb +27 -30
  84. data/lib/inspec/profile_vendor.rb +6 -9
  85. data/lib/inspec/reporters.rb +24 -24
  86. data/lib/inspec/reporters/automate.rb +17 -19
  87. data/lib/inspec/reporters/base.rb +1 -1
  88. data/lib/inspec/reporters/cli.rb +88 -91
  89. data/lib/inspec/reporters/json.rb +2 -4
  90. data/lib/inspec/reporters/json_automate.rb +1 -3
  91. data/lib/inspec/reporters/json_min.rb +1 -3
  92. data/lib/inspec/reporters/junit.rb +26 -28
  93. data/lib/inspec/reporters/yaml.rb +1 -3
  94. data/lib/inspec/require_loader.rb +0 -4
  95. data/lib/inspec/resource.rb +4 -125
  96. data/lib/inspec/resources.rb +121 -0
  97. data/lib/{resources → inspec/resources}/aide_conf.rb +24 -25
  98. data/lib/{resources → inspec/resources}/apache.rb +13 -14
  99. data/lib/{resources → inspec/resources}/apache_conf.rb +16 -17
  100. data/lib/{resources → inspec/resources}/apt.rb +17 -17
  101. data/lib/{resources → inspec/resources}/audit_policy.rb +7 -6
  102. data/lib/{resources → inspec/resources}/auditd.rb +62 -64
  103. data/lib/{resources → inspec/resources}/auditd_conf.rb +7 -8
  104. data/lib/{resources → inspec/resources}/bash.rb +6 -8
  105. data/lib/{resources → inspec/resources}/bond.rb +15 -14
  106. data/lib/{resources → inspec/resources}/bridge.rb +8 -8
  107. data/lib/{resources → inspec/resources}/chocolatey_package.rb +10 -8
  108. data/lib/{resources → inspec/resources}/command.rb +11 -10
  109. data/lib/{resources → inspec/resources}/cpan.rb +12 -12
  110. data/lib/{resources → inspec/resources}/cran.rb +9 -9
  111. data/lib/{resources → inspec/resources}/crontab.rb +47 -48
  112. data/lib/{resources → inspec/resources}/csv.rb +5 -5
  113. data/lib/{resources → inspec/resources}/dh_params.rb +5 -7
  114. data/lib/{resources → inspec/resources}/directory.rb +5 -7
  115. data/lib/{resources → inspec/resources}/docker.rb +63 -63
  116. data/lib/{resources → inspec/resources}/docker_container.rb +6 -6
  117. data/lib/{resources → inspec/resources}/docker_image.rb +9 -9
  118. data/lib/{resources → inspec/resources}/docker_object.rb +8 -13
  119. data/lib/{resources → inspec/resources}/docker_plugin.rb +6 -6
  120. data/lib/{resources → inspec/resources}/docker_service.rb +7 -7
  121. data/lib/{resources → inspec/resources}/elasticsearch.rb +40 -42
  122. data/lib/{resources → inspec/resources}/etc_fstab.rb +23 -24
  123. data/lib/{resources → inspec/resources}/etc_group.rb +26 -27
  124. data/lib/{resources → inspec/resources}/etc_hosts.rb +11 -13
  125. data/lib/{resources → inspec/resources}/etc_hosts_allow_deny.rb +25 -27
  126. data/lib/{resources → inspec/resources}/file.rb +80 -79
  127. data/lib/{resources → inspec/resources}/filesystem.rb +20 -15
  128. data/lib/{resources → inspec/resources}/firewalld.rb +26 -26
  129. data/lib/{resources → inspec/resources}/gem.rb +12 -12
  130. data/lib/{resources → inspec/resources}/groups.rb +28 -27
  131. data/lib/{resources → inspec/resources}/grub_conf.rb +46 -48
  132. data/lib/{resources → inspec/resources}/host.rb +31 -29
  133. data/lib/{resources → inspec/resources}/http.rb +24 -24
  134. data/lib/{resources → inspec/resources}/iis_app.rb +6 -7
  135. data/lib/{resources → inspec/resources}/iis_app_pool.rb +21 -19
  136. data/lib/{resources → inspec/resources}/iis_site.rb +17 -15
  137. data/lib/{resources → inspec/resources}/inetd_conf.rb +9 -10
  138. data/lib/{resources → inspec/resources}/ini.rb +7 -8
  139. data/lib/{resources → inspec/resources}/interface.rb +30 -30
  140. data/lib/{resources → inspec/resources}/iptables.rb +8 -8
  141. data/lib/{resources → inspec/resources}/json.rb +8 -10
  142. data/lib/{resources → inspec/resources}/kernel_module.rb +15 -15
  143. data/lib/{resources → inspec/resources}/kernel_parameter.rb +8 -8
  144. data/lib/{resources → inspec/resources}/key_rsa.rb +8 -10
  145. data/lib/{resources → inspec/resources}/ksh.rb +6 -8
  146. data/lib/{resources → inspec/resources}/limits_conf.rb +8 -9
  147. data/lib/{resources/login_def.rb → inspec/resources/login_defs.rb} +9 -10
  148. data/lib/{resources → inspec/resources}/mount.rb +6 -8
  149. data/lib/{resources → inspec/resources}/mssql_session.rb +16 -18
  150. data/lib/inspec/resources/mysql.rb +81 -0
  151. data/lib/{resources → inspec/resources}/mysql_conf.rb +13 -14
  152. data/lib/{resources → inspec/resources}/mysql_session.rb +16 -16
  153. data/lib/{resources → inspec/resources}/nginx.rb +16 -17
  154. data/lib/{resources → inspec/resources}/nginx_conf.rb +26 -27
  155. data/lib/{resources → inspec/resources}/npm.rb +9 -10
  156. data/lib/{resources → inspec/resources}/ntp_conf.rb +9 -10
  157. data/lib/{resources → inspec/resources}/oneget.rb +8 -8
  158. data/lib/{resources → inspec/resources}/oracledb_session.rb +33 -34
  159. data/lib/{resources → inspec/resources}/os.rb +6 -8
  160. data/lib/{resources → inspec/resources}/os_env.rb +11 -12
  161. data/lib/{resources → inspec/resources}/package.rb +66 -65
  162. data/lib/{resources → inspec/resources}/packages.rb +13 -13
  163. data/lib/{resources → inspec/resources}/parse_config.rb +8 -8
  164. data/lib/{resources → inspec/resources}/passwd.rb +18 -19
  165. data/lib/{resources → inspec/resources}/pip.rb +19 -19
  166. data/lib/{resources → inspec/resources}/platform.rb +9 -11
  167. data/lib/{resources → inspec/resources}/port.rb +134 -136
  168. data/lib/{resources → inspec/resources}/postgres.rb +40 -32
  169. data/lib/{resources → inspec/resources}/postgres_conf.rb +17 -17
  170. data/lib/{resources → inspec/resources}/postgres_hba_conf.rb +21 -23
  171. data/lib/{resources → inspec/resources}/postgres_ident_conf.rb +12 -14
  172. data/lib/{resources → inspec/resources}/postgres_session.rb +8 -9
  173. data/lib/{resources → inspec/resources}/powershell.rb +17 -13
  174. data/lib/{resources → inspec/resources}/processes.rb +29 -29
  175. data/lib/{resources/rabbitmq_conf.rb → inspec/resources/rabbitmq_config.rb} +10 -11
  176. data/lib/{resources → inspec/resources}/registry_key.rb +14 -14
  177. data/lib/inspec/resources/script.rb +1 -0
  178. data/lib/{resources → inspec/resources}/security_identifier.rb +11 -10
  179. data/lib/{resources → inspec/resources}/security_policy.rb +59 -58
  180. data/lib/{resources → inspec/resources}/service.rb +74 -75
  181. data/lib/{resources → inspec/resources}/shadow.rb +44 -45
  182. data/lib/{resources/ssh_conf.rb → inspec/resources/ssh_config.rb} +16 -17
  183. data/lib/{resources → inspec/resources}/ssl.rb +28 -29
  184. data/lib/inspec/resources/sys_info.rb +30 -0
  185. data/lib/{resources → inspec/resources}/toml.rb +5 -7
  186. data/lib/{resources → inspec/resources}/users.rb +65 -65
  187. data/lib/{resources → inspec/resources}/vbscript.rb +8 -9
  188. data/lib/{resources → inspec/resources}/virtualization.rb +60 -62
  189. data/lib/{resources → inspec/resources}/windows_feature.rb +9 -9
  190. data/lib/{resources → inspec/resources}/windows_hotfix.rb +5 -5
  191. data/lib/{resources → inspec/resources}/windows_task.rb +16 -15
  192. data/lib/{resources → inspec/resources}/wmi.rb +7 -8
  193. data/lib/{resources → inspec/resources}/x509_certificate.rb +9 -11
  194. data/lib/{resources/xinetd.rb → inspec/resources/xinetd_conf.rb} +27 -29
  195. data/lib/{resources → inspec/resources}/xml.rb +7 -7
  196. data/lib/{resources → inspec/resources}/yaml.rb +5 -6
  197. data/lib/{resources → inspec/resources}/yum.rb +10 -10
  198. data/lib/{resources → inspec/resources}/zfs_dataset.rb +6 -6
  199. data/lib/{resources → inspec/resources}/zfs_pool.rb +4 -4
  200. data/lib/inspec/rspec_extensions.rb +24 -8
  201. data/lib/inspec/rule.rb +14 -15
  202. data/lib/inspec/runner.rb +28 -28
  203. data/lib/inspec/runner_mock.rb +1 -5
  204. data/lib/inspec/runner_rspec.rb +18 -20
  205. data/lib/inspec/runtime_profile.rb +2 -5
  206. data/lib/inspec/schema.rb +142 -143
  207. data/lib/inspec/secrets.rb +3 -7
  208. data/lib/inspec/secrets/yaml.rb +3 -5
  209. data/lib/inspec/shell.rb +11 -15
  210. data/lib/inspec/shell_detector.rb +6 -7
  211. data/lib/inspec/source_reader.rb +4 -8
  212. data/lib/inspec/ui.rb +33 -39
  213. data/lib/inspec/ui_table_helper.rb +12 -0
  214. data/lib/{utils → inspec/utils}/command_wrapper.rb +4 -8
  215. data/lib/{utils → inspec/utils}/convert.rb +0 -4
  216. data/lib/{utils → inspec/utils}/database_helpers.rb +4 -8
  217. data/lib/inspec/utils/deprecation.rb +6 -0
  218. data/lib/{utils → inspec/utils}/deprecation/config_file.rb +19 -19
  219. data/lib/{utils → inspec/utils}/deprecation/deprecator.rb +12 -12
  220. data/lib/{utils → inspec/utils}/deprecation/errors.rb +1 -1
  221. data/lib/{utils → inspec/utils}/deprecation/global_method.rb +2 -2
  222. data/lib/{utils → inspec/utils}/enumerable_delegation.rb +0 -2
  223. data/lib/{utils → inspec/utils}/erlang_parser.rb +61 -65
  224. data/lib/{utils → inspec/utils}/file_reader.rb +1 -2
  225. data/lib/{utils → inspec/utils}/filter.rb +30 -33
  226. data/lib/{utils → inspec/utils}/filter_array.rb +0 -2
  227. data/lib/{utils → inspec/utils}/find_files.rb +9 -12
  228. data/lib/{utils → inspec/utils}/hash.rb +1 -5
  229. data/lib/inspec/utils/json_log.rb +15 -0
  230. data/lib/inspec/utils/latest_version.rb +13 -0
  231. data/lib/{utils → inspec/utils}/modulator.rb +0 -3
  232. data/lib/{utils → inspec/utils}/nginx_parser.rb +31 -35
  233. data/lib/{utils → inspec/utils}/object_traversal.rb +0 -3
  234. data/lib/{utils → inspec/utils}/parser.rb +45 -45
  235. data/lib/{utils → inspec/utils}/pkey_reader.rb +4 -2
  236. data/lib/{utils → inspec/utils}/simpleconfig.rb +8 -10
  237. data/lib/{utils → inspec/utils}/spdx.rb +1 -4
  238. data/lib/{utils → inspec/utils}/spdx.txt +0 -0
  239. data/lib/inspec/utils/telemetry.rb +3 -3
  240. data/lib/inspec/utils/telemetry/collector.rb +30 -9
  241. data/lib/inspec/utils/telemetry/data_series.rb +3 -1
  242. data/lib/inspec/utils/telemetry/global_methods.rb +1 -1
  243. data/lib/inspec/version.rb +1 -1
  244. data/lib/matchers/matchers.rb +22 -25
  245. data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +1 -1
  246. data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +52 -45
  247. data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +18 -16
  248. data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +1 -1
  249. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +73 -73
  250. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +66 -62
  251. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +59 -57
  252. data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +11 -11
  253. data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +20 -22
  254. data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +2 -4
  255. data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +30 -27
  256. data/lib/plugins/inspec-habitat/Berksfile +2 -2
  257. data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +1 -1
  258. data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +15 -13
  259. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +64 -63
  260. data/lib/plugins/inspec-habitat/templates/habitat/hooks/run.erb +3 -3
  261. data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +11 -11
  262. data/lib/plugins/inspec-init/lib/inspec-init.rb +1 -1
  263. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +6 -8
  264. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +72 -74
  265. data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +9 -11
  266. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +4 -4
  267. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -1
  268. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/inspec-plugin-template.gemspec +0 -2
  269. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -2
  270. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -2
  271. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -2
  272. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -2
  273. data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +6 -7
  274. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +1 -2
  275. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +72 -70
  276. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +1 -1
  277. data/lib/plugins/shared/core_plugin_test_helper.rb +43 -38
  278. data/lib/source_readers/flat.rb +6 -10
  279. data/lib/source_readers/inspec.rb +8 -12
  280. metadata +139 -140
  281. data/lib/resources/mysql.rb +0 -82
  282. data/lib/resources/sys_info.rb +0 -28
  283. data/lib/utils/deprecation.rb +0 -6
  284. data/lib/utils/json_log.rb +0 -18
  285. data/lib/utils/latest_version.rb +0 -22
@@ -1,7 +1,3 @@
1
- # encoding: utf-8
2
- # author: Dominik Richter
3
- # author: Christoph Hartmann
4
-
5
1
  module Inspec
6
2
  class RunnerMock
7
3
  attr_reader :tests, :profiles
@@ -35,7 +31,7 @@ module Inspec
35
31
  end
36
32
 
37
33
  def run(_with = nil)
38
- puts 'uhm.... nothing or something... dunno, ask your admin'
34
+ puts "uhm.... nothing or something... dunno, ask your admin"
39
35
  end
40
36
  end
41
37
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- # author: Dominik Richter
3
- # author: Christoph Hartmann
4
-
5
- require 'rspec/core'
6
- require 'rspec/its'
7
- require 'inspec/formatters'
1
+ require "rspec/core"
2
+ require "rspec/its"
3
+ require "inspec/formatters"
4
+ require "matchers/matchers"
5
+ require "inspec/rspec_extensions"
8
6
 
9
7
  # There be dragons!! Or borgs, or something...
10
8
  # This file and all its contents cannot be unit-tested. both test-suits
@@ -84,13 +82,13 @@ module Inspec
84
82
  def exit_code
85
83
  return @rspec_exit_code if @formatter.results.empty?
86
84
  stats = @formatter.results[:statistics][:controls]
87
- skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == 'skipped'
85
+ skipped = @formatter.results&.fetch(:profiles, nil)&.first&.fetch(:status, nil) == "skipped"
88
86
  if stats[:failed][:total] == 0 && stats[:skipped][:total] == 0 && !skipped
89
87
  0
90
88
  elsif stats[:failed][:total] > 0
91
- @conf['distinct_exit'] ? 100 : 1
89
+ @conf["distinct_exit"] ? 100 : 1
92
90
  elsif stats[:skipped][:total] > 0 || skipped
93
- @conf['distinct_exit'] ? 101 : 0
91
+ @conf["distinct_exit"] ? 101 : 0
94
92
  else
95
93
  @rspec_exit_code
96
94
  end
@@ -112,26 +110,26 @@ module Inspec
112
110
  #
113
111
  #
114
112
  def set_optional_formatters
115
- return if @conf['reporter'].nil?
116
- if @conf['reporter'].key?('json-rspec')
113
+ return if @conf["reporter"].nil?
114
+ if @conf["reporter"].key?("json-rspec")
117
115
  # We cannot pass in a nil output path. Rspec only accepts a valid string or a IO object.
118
- if @conf['reporter']['json-rspec']&.[]('file').nil?
116
+ if @conf["reporter"]["json-rspec"]&.[]("file").nil?
119
117
  RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson)
120
118
  else
121
- RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson, @conf['reporter']['json-rspec']['file'])
119
+ RSpec.configuration.add_formatter(Inspec::Formatters::RspecJson, @conf["reporter"]["json-rspec"]["file"])
122
120
  end
123
- @conf['reporter'].delete('json-rspec')
121
+ @conf["reporter"].delete("json-rspec")
124
122
  end
125
123
 
126
- formats = @conf['reporter'].select { |k, _v| %w{documentation progress html}.include?(k) }
124
+ formats = @conf["reporter"].select { |k, _v| %w{documentation progress html}.include?(k) }
127
125
  formats.each do |k, v|
128
126
  # We cannot pass in a nil output path. Rspec only accepts a valid string or a IO object.
129
- if v&.[]('file').nil?
127
+ if v&.[]("file").nil?
130
128
  RSpec.configuration.add_formatter(k.to_sym)
131
129
  else
132
- RSpec.configuration.add_formatter(k.to_sym, v['file'])
130
+ RSpec.configuration.add_formatter(k.to_sym, v["file"])
133
131
  end
134
- @conf['reporter'].delete(k)
132
+ @conf["reporter"].delete(k)
135
133
  end
136
134
  end
137
135
 
@@ -143,7 +141,7 @@ module Inspec
143
141
  @formatter = RSpec.configuration.add_formatter(Inspec::Formatters::Base)
144
142
  RSpec.configuration.add_formatter(Inspec::Formatters::ShowProgress, $stderr) if @conf[:show_progress]
145
143
  set_optional_formatters
146
- RSpec.configuration.color = @conf['color']
144
+ RSpec.configuration.color = @conf["color"]
147
145
  end
148
146
 
149
147
  # Make sure that all RSpec example groups use the provided ID.
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
1
  # Copyright 2017 Chef Software
3
- # author: Dominik Richter
4
- # author: Christoph Hartmann
5
2
 
6
3
  module Inspec
7
4
  class RuntimeProfile
@@ -10,7 +7,7 @@ module Inspec
10
7
  def initialize(profile)
11
8
  @src = profile.source_reader
12
9
  @files = @src.data_files.keys.map do |k|
13
- k.sub('files' + File::SEPARATOR, '')
10
+ k.sub("files" + File::SEPARATOR, "")
14
11
  end
15
12
  end
16
13
 
@@ -19,7 +16,7 @@ module Inspec
19
16
  # @param name [String] the name of the file
20
17
  # @return [String] contents of the file of RuntimeError if missing
21
18
  def file(name)
22
- @src.data_files[File.join('files', name)] ||
19
+ @src.data_files[File.join("files", name)] ||
23
20
  raise("Cannot find file #{name} in profile.")
24
21
  end
25
22
  end
data/lib/inspec/schema.rb CHANGED
@@ -1,34 +1,33 @@
1
- # encoding: utf-8
2
- require 'json'
1
+ require "json"
3
2
 
4
3
  module Inspec
5
4
  class Schema
6
5
  STATISTICS = {
7
- 'type' => 'object',
8
- 'additionalProperties' => false,
9
- 'properties' => {
10
- 'duration' => { 'type' => 'number' },
11
- 'controls' => {
12
- 'type' => 'object',
13
- 'optional' => true,
14
- 'properties' => {
15
- 'total' => { 'type' => 'number' },
16
- 'passed' => {
17
- 'type' => 'object',
18
- 'properties' => {
19
- 'total' => { 'type' => 'number' },
6
+ "type" => "object",
7
+ "additionalProperties" => false,
8
+ "properties" => {
9
+ "duration" => { "type" => "number" },
10
+ "controls" => {
11
+ "type" => "object",
12
+ "optional" => true,
13
+ "properties" => {
14
+ "total" => { "type" => "number" },
15
+ "passed" => {
16
+ "type" => "object",
17
+ "properties" => {
18
+ "total" => { "type" => "number" },
20
19
  },
21
20
  },
22
- 'skipped' => {
23
- 'type' => 'object',
24
- 'properties' => {
25
- 'total' => { 'type' => 'number' },
21
+ "skipped" => {
22
+ "type" => "object",
23
+ "properties" => {
24
+ "total" => { "type" => "number" },
26
25
  },
27
26
  },
28
- 'failed' => {
29
- 'type' => 'object',
30
- 'properties' => {
31
- 'total' => { 'type' => 'number' },
27
+ "failed" => {
28
+ "type" => "object",
29
+ "properties" => {
30
+ "total" => { "type" => "number" },
32
31
  },
33
32
  },
34
33
  },
@@ -37,184 +36,184 @@ module Inspec
37
36
  }.freeze
38
37
 
39
38
  PLATFORM = {
40
- 'type' => 'object',
41
- 'additionalProperties' => false,
42
- 'properties' => {
43
- 'name' => { 'type' => 'string' },
44
- 'release' => { 'type' => 'string' },
45
- 'target_id' => { 'type' => 'string', 'optional' => true },
39
+ "type" => "object",
40
+ "additionalProperties" => false,
41
+ "properties" => {
42
+ "name" => { "type" => "string" },
43
+ "release" => { "type" => "string" },
44
+ "target_id" => { "type" => "string", "optional" => true },
46
45
  },
47
46
  }.freeze
48
47
 
49
48
  # Tags are open right, with simple key-value associations and not restrictions
50
- TAGS = { 'type' => 'object' }.freeze
49
+ TAGS = { "type" => "object" }.freeze
51
50
 
52
51
  RESULT = {
53
- 'type' => 'object',
54
- 'additionalProperties' => false,
55
- 'properties' => {
56
- 'status' => { 'type' => 'string' },
57
- 'code_desc' => { 'type' => 'string' },
58
- 'run_time' => { 'type' => 'number' },
59
- 'start_time' => { 'type' => 'string' },
60
- 'skip_message' => { 'type' => 'string', 'optional' => true },
61
- 'resource' => { 'type' => 'string', 'optional' => true },
62
- 'message' => { 'type' => 'string', 'optional' => true },
63
- 'exception' => { 'type' => 'string', 'optional' => true },
64
- 'backtrace' => { 'type' => 'object', 'optional' => true },
52
+ "type" => "object",
53
+ "additionalProperties" => false,
54
+ "properties" => {
55
+ "status" => { "type" => "string" },
56
+ "code_desc" => { "type" => "string" },
57
+ "run_time" => { "type" => "number" },
58
+ "start_time" => { "type" => "string" },
59
+ "skip_message" => { "type" => "string", "optional" => true },
60
+ "resource" => { "type" => "string", "optional" => true },
61
+ "message" => { "type" => "string", "optional" => true },
62
+ "exception" => { "type" => "string", "optional" => true },
63
+ "backtrace" => { "type" => "object", "optional" => true },
65
64
  },
66
65
  }.freeze
67
66
 
68
67
  REF = {
69
- 'type' => 'object',
70
- 'additionalProperties' => false,
71
- 'properties' => {
72
- 'ref' => { 'type' => 'string' },
68
+ "type" => "object",
69
+ "additionalProperties" => false,
70
+ "properties" => {
71
+ "ref" => { "type" => "string" },
73
72
  # TODO: One of these needs to be deprecated
74
- 'uri' => { 'type' => 'string', 'optional' => true },
75
- 'url' => { 'type' => 'string', 'optional' => true },
73
+ "uri" => { "type" => "string", "optional" => true },
74
+ "url" => { "type" => "string", "optional" => true },
76
75
  },
77
76
  }.freeze
78
- REFS = { 'type' => 'array', 'items' => REF }.freeze
77
+ REFS = { "type" => "array", "items" => REF }.freeze
79
78
 
80
79
  CONTROL = {
81
- 'type' => 'object',
82
- 'additionalProperties' => false,
83
- 'properties' => {
84
- 'id' => { 'type' => 'string' },
85
- 'title' => { 'type' => %w{string null} },
86
- 'desc' => { 'type' => %w{string null} },
87
- 'descriptions' => { 'type' => %w{array} },
88
- 'impact' => { 'type' => 'number' },
89
- 'refs' => REFS,
90
- 'tags' => TAGS,
91
- 'code' => { 'type' => 'string' },
92
- 'source_location' => {
93
- 'type' => 'object',
94
- 'properties' => {
95
- 'ref' => { 'type' => 'string' },
96
- 'line' => { 'type' => 'number' },
80
+ "type" => "object",
81
+ "additionalProperties" => false,
82
+ "properties" => {
83
+ "id" => { "type" => "string" },
84
+ "title" => { "type" => %w{string null} },
85
+ "desc" => { "type" => %w{string null} },
86
+ "descriptions" => { "type" => %w{array} },
87
+ "impact" => { "type" => "number" },
88
+ "refs" => REFS,
89
+ "tags" => TAGS,
90
+ "code" => { "type" => "string" },
91
+ "source_location" => {
92
+ "type" => "object",
93
+ "properties" => {
94
+ "ref" => { "type" => "string" },
95
+ "line" => { "type" => "number" },
97
96
  },
98
97
  },
99
- 'results' => { 'type' => 'array', 'items' => RESULT },
98
+ "results" => { "type" => "array", "items" => RESULT },
100
99
  },
101
100
  }.freeze
102
101
 
103
102
  SUPPORTS = {
104
- 'type' => 'object',
105
- 'additionalProperties' => false,
106
- 'properties' => {
107
- 'platform-family' => { 'type' => 'string', 'optional' => true },
108
- 'platform-name' => { 'type' => 'string', 'optional' => true },
109
- 'platform' => { 'type' => 'string', 'optional' => true },
103
+ "type" => "object",
104
+ "additionalProperties" => false,
105
+ "properties" => {
106
+ "platform-family" => { "type" => "string", "optional" => true },
107
+ "platform-name" => { "type" => "string", "optional" => true },
108
+ "platform" => { "type" => "string", "optional" => true },
110
109
  # os-* supports are being deprecated
111
- 'os-family' => { 'type' => 'string', 'optional' => true },
112
- 'os-name' => { 'type' => 'string', 'optional' => true },
110
+ "os-family" => { "type" => "string", "optional" => true },
111
+ "os-name" => { "type" => "string", "optional" => true },
113
112
  },
114
113
  }.freeze
115
114
 
116
115
  CONTROL_GROUP = {
117
- 'type' => 'object',
118
- 'additionalProperties' => false,
119
- 'properties' => {
120
- 'id' => { 'type' => 'string' },
121
- 'title' => { 'type' => 'string', 'optional' => true },
122
- 'controls' => { 'type' => 'array', 'items' => { 'type' => 'string' } },
116
+ "type" => "object",
117
+ "additionalProperties" => false,
118
+ "properties" => {
119
+ "id" => { "type" => "string" },
120
+ "title" => { "type" => "string", "optional" => true },
121
+ "controls" => { "type" => "array", "items" => { "type" => "string" } },
123
122
  },
124
123
  }.freeze
125
124
 
126
125
  PROFILE = {
127
- 'type' => 'object',
128
- 'additionalProperties' => false,
129
- 'properties' => {
130
- 'name' => { 'type' => 'string' },
131
- 'version' => { 'type' => 'string', 'optional' => true },
132
- 'sha256' => { 'type' => 'string', 'optional' => false },
133
-
134
- 'title' => { 'type' => 'string', 'optional' => true },
135
- 'maintainer' => { 'type' => 'string', 'optional' => true },
136
- 'copyright' => { 'type' => 'string', 'optional' => true },
137
- 'copyright_email' => { 'type' => 'string', 'optional' => true },
138
- 'license' => { 'type' => 'string', 'optional' => true },
139
- 'summary' => { 'type' => 'string', 'optional' => true },
140
- 'status' => { 'type' => 'string', 'optional' => false },
141
- 'skip_message' => { 'type' => 'string', 'optional' => true },
142
-
143
- 'supports' => {
144
- 'type' => 'array',
145
- 'items' => SUPPORTS,
146
- 'optional' => true,
126
+ "type" => "object",
127
+ "additionalProperties" => false,
128
+ "properties" => {
129
+ "name" => { "type" => "string" },
130
+ "version" => { "type" => "string", "optional" => true },
131
+ "sha256" => { "type" => "string", "optional" => false },
132
+
133
+ "title" => { "type" => "string", "optional" => true },
134
+ "maintainer" => { "type" => "string", "optional" => true },
135
+ "copyright" => { "type" => "string", "optional" => true },
136
+ "copyright_email" => { "type" => "string", "optional" => true },
137
+ "license" => { "type" => "string", "optional" => true },
138
+ "summary" => { "type" => "string", "optional" => true },
139
+ "status" => { "type" => "string", "optional" => false },
140
+ "skip_message" => { "type" => "string", "optional" => true },
141
+
142
+ "supports" => {
143
+ "type" => "array",
144
+ "items" => SUPPORTS,
145
+ "optional" => true,
147
146
  },
148
- 'controls' => {
149
- 'type' => 'array',
150
- 'items' => CONTROL,
147
+ "controls" => {
148
+ "type" => "array",
149
+ "items" => CONTROL,
151
150
  },
152
- 'groups' => {
153
- 'type' => 'array',
154
- 'items' => CONTROL_GROUP,
151
+ "groups" => {
152
+ "type" => "array",
153
+ "items" => CONTROL_GROUP,
155
154
  },
156
- 'attributes' => { # TODO: rename to inputs, refs #3802
157
- 'type' => 'array',
155
+ "attributes" => { # TODO: rename to inputs, refs #3802
156
+ "type" => "array",
158
157
  # TODO: more detailed specification needed
159
158
  },
160
159
  },
161
160
  }.freeze
162
161
 
163
162
  EXEC_JSON = {
164
- 'type' => 'object',
165
- 'additionalProperties' => false,
166
- 'properties' => {
167
- 'platform' => PLATFORM,
168
- 'profiles' => {
169
- 'type' => 'array',
170
- 'items' => PROFILE,
163
+ "type" => "object",
164
+ "additionalProperties" => false,
165
+ "properties" => {
166
+ "platform" => PLATFORM,
167
+ "profiles" => {
168
+ "type" => "array",
169
+ "items" => PROFILE,
171
170
  },
172
- 'statistics' => STATISTICS,
173
- 'version' => { 'type' => 'string' },
171
+ "statistics" => STATISTICS,
172
+ "version" => { "type" => "string" },
174
173
  },
175
174
  }.freeze
176
175
 
177
176
  MIN_CONTROL = {
178
- 'type' => 'object',
179
- 'additionalProperties' => false,
180
- 'properties' => {
181
- 'id' => { 'type' => 'string' },
182
- 'profile_id' => { 'type' => %w{string null} },
183
- 'profile_sha256' => { 'type' => 'string' },
184
- 'status' => { 'type' => 'string' },
185
- 'code_desc' => { 'type' => 'string' },
186
- 'skip_message' => { 'type' => 'string', 'optional' => true },
187
- 'resource' => { 'type' => 'string', 'optional' => true },
188
- 'message' => { 'type' => 'string', 'optional' => true },
189
- 'exception' => { 'type' => 'string', 'optional' => true },
190
- 'backtrace' => { 'type' => 'object', 'optional' => true },
177
+ "type" => "object",
178
+ "additionalProperties" => false,
179
+ "properties" => {
180
+ "id" => { "type" => "string" },
181
+ "profile_id" => { "type" => %w{string null} },
182
+ "profile_sha256" => { "type" => "string" },
183
+ "status" => { "type" => "string" },
184
+ "code_desc" => { "type" => "string" },
185
+ "skip_message" => { "type" => "string", "optional" => true },
186
+ "resource" => { "type" => "string", "optional" => true },
187
+ "message" => { "type" => "string", "optional" => true },
188
+ "exception" => { "type" => "string", "optional" => true },
189
+ "backtrace" => { "type" => "object", "optional" => true },
191
190
  },
192
191
  }.freeze
193
192
 
194
193
  EXEC_JSONMIN = {
195
- 'type' => 'object',
196
- 'additionalProperties' => false,
197
- 'properties' => {
198
- 'statistics' => STATISTICS,
199
- 'version' => { 'type' => 'string' },
200
- 'controls' => {
201
- 'type' => 'array',
202
- 'items' => MIN_CONTROL,
194
+ "type" => "object",
195
+ "additionalProperties" => false,
196
+ "properties" => {
197
+ "statistics" => STATISTICS,
198
+ "version" => { "type" => "string" },
199
+ "controls" => {
200
+ "type" => "array",
201
+ "items" => MIN_CONTROL,
203
202
  },
204
203
  },
205
204
  }.freeze
206
205
 
207
206
  # using a proc here so we can lazy load it when we need
208
207
  PLATFORMS = lambda do
209
- require 'train'
210
- Train.create('mock').connection
208
+ require "train"
209
+ Train.create("mock").connection
211
210
  Train::Platforms.export
212
211
  end
213
212
 
214
213
  LIST = {
215
- 'exec-json' => EXEC_JSON,
216
- 'exec-jsonmin' => EXEC_JSONMIN,
217
- 'platforms' => PLATFORMS,
214
+ "exec-json" => EXEC_JSON,
215
+ "exec-jsonmin" => EXEC_JSONMIN,
216
+ "platforms" => PLATFORMS,
218
217
  }.freeze
219
218
 
220
219
  def self.names