inspec-core 4.7.3 → 4.7.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bundles/inspec-supermarket/api.rb +2 -1
  3. data/lib/bundles/inspec-supermarket/cli.rb +6 -6
  4. data/lib/bundles/inspec-supermarket/target.rb +1 -0
  5. data/lib/fetchers/git.rb +3 -1
  6. data/lib/fetchers/mock.rb +1 -0
  7. data/lib/fetchers/url.rb +6 -3
  8. data/lib/inspec/backend.rb +1 -0
  9. data/lib/inspec/base_cli.rb +4 -1
  10. data/lib/inspec/cli.rb +5 -4
  11. data/lib/inspec/config.rb +9 -1
  12. data/lib/inspec/control_eval_context.rb +1 -0
  13. data/lib/inspec/dependencies/cache.rb +1 -0
  14. data/lib/inspec/dependencies/dependency_set.rb +2 -0
  15. data/lib/inspec/dependencies/lockfile.rb +1 -0
  16. data/lib/inspec/dependencies/requirement.rb +8 -7
  17. data/lib/inspec/dependencies/resolver.rb +3 -3
  18. data/lib/inspec/describe.rb +1 -0
  19. data/lib/inspec/dsl.rb +1 -1
  20. data/lib/inspec/dsl_shared.rb +1 -1
  21. data/lib/inspec/env_printer.rb +4 -4
  22. data/lib/inspec/fetcher.rb +4 -2
  23. data/lib/inspec/file_provider.rb +18 -8
  24. data/lib/inspec/formatters/base.rb +5 -0
  25. data/lib/inspec/impact.rb +2 -0
  26. data/lib/inspec/input_registry.rb +14 -13
  27. data/lib/inspec/metadata.rb +6 -2
  28. data/lib/inspec/method_source.rb +1 -1
  29. data/lib/inspec/objects/control.rb +4 -1
  30. data/lib/inspec/objects/describe.rb +3 -1
  31. data/lib/inspec/objects/input.rb +6 -5
  32. data/lib/inspec/objects/list.rb +2 -0
  33. data/lib/inspec/objects/test.rb +3 -2
  34. data/lib/inspec/plugin/v1/plugin_types/resource.rb +7 -0
  35. data/lib/inspec/plugin/v1/plugins.rb +4 -3
  36. data/lib/inspec/plugin/v1/registry.rb +3 -2
  37. data/lib/inspec/plugin/v2.rb +1 -0
  38. data/lib/inspec/plugin/v2/activator.rb +2 -0
  39. data/lib/inspec/plugin/v2/config_file.rb +4 -1
  40. data/lib/inspec/plugin/v2/filter.rb +1 -0
  41. data/lib/inspec/plugin/v2/installer.rb +9 -7
  42. data/lib/inspec/plugin/v2/loader.rb +2 -0
  43. data/lib/inspec/plugin/v2/plugin_base.rb +1 -0
  44. data/lib/inspec/plugin/v2/plugin_types/cli.rb +2 -2
  45. data/lib/inspec/plugin/v2/registry.rb +3 -1
  46. data/lib/inspec/profile.rb +13 -6
  47. data/lib/inspec/profile_context.rb +4 -2
  48. data/lib/inspec/reporters/cli.rb +14 -10
  49. data/lib/inspec/reporters/json.rb +1 -0
  50. data/lib/inspec/reporters/json_automate.rb +3 -0
  51. data/lib/inspec/reporters/json_min.rb +2 -0
  52. data/lib/inspec/resource.rb +2 -0
  53. data/lib/inspec/resources/aide_conf.rb +4 -3
  54. data/lib/inspec/resources/apache_conf.rb +1 -1
  55. data/lib/inspec/resources/apt.rb +2 -0
  56. data/lib/inspec/resources/auditd.rb +19 -18
  57. data/lib/inspec/resources/bridge.rb +5 -2
  58. data/lib/inspec/resources/chocolatey_package.rb +2 -0
  59. data/lib/inspec/resources/command.rb +1 -1
  60. data/lib/inspec/resources/crontab.rb +9 -8
  61. data/lib/inspec/resources/csv.rb +1 -1
  62. data/lib/inspec/resources/dh_params.rb +6 -0
  63. data/lib/inspec/resources/docker.rb +37 -34
  64. data/lib/inspec/resources/docker_container.rb +1 -0
  65. data/lib/inspec/resources/docker_image.rb +1 -0
  66. data/lib/inspec/resources/docker_plugin.rb +1 -0
  67. data/lib/inspec/resources/docker_service.rb +1 -0
  68. data/lib/inspec/resources/elasticsearch.rb +24 -24
  69. data/lib/inspec/resources/etc_fstab.rb +8 -7
  70. data/lib/inspec/resources/etc_group.rb +4 -0
  71. data/lib/inspec/resources/etc_hosts.rb +4 -4
  72. data/lib/inspec/resources/etc_hosts_allow_deny.rb +5 -3
  73. data/lib/inspec/resources/file.rb +4 -1
  74. data/lib/inspec/resources/filesystem.rb +5 -3
  75. data/lib/inspec/resources/firewalld.rb +7 -4
  76. data/lib/inspec/resources/groups.rb +6 -4
  77. data/lib/inspec/resources/grub_conf.rb +3 -0
  78. data/lib/inspec/resources/host.rb +5 -3
  79. data/lib/inspec/resources/http.rb +6 -4
  80. data/lib/inspec/resources/iis_app.rb +1 -0
  81. data/lib/inspec/resources/iis_app_pool.rb +1 -1
  82. data/lib/inspec/resources/iis_site.rb +4 -3
  83. data/lib/inspec/resources/interface.rb +10 -7
  84. data/lib/inspec/resources/json.rb +1 -1
  85. data/lib/inspec/resources/kernel_module.rb +1 -1
  86. data/lib/inspec/resources/kernel_parameter.rb +2 -1
  87. data/lib/inspec/resources/key_rsa.rb +5 -0
  88. data/lib/inspec/resources/mount.rb +3 -1
  89. data/lib/inspec/resources/mysql_conf.rb +3 -1
  90. data/lib/inspec/resources/mysql_session.rb +2 -0
  91. data/lib/inspec/resources/nginx.rb +1 -0
  92. data/lib/inspec/resources/nginx_conf.rb +10 -6
  93. data/lib/inspec/resources/ntp_conf.rb +1 -0
  94. data/lib/inspec/resources/oneget.rb +1 -1
  95. data/lib/inspec/resources/oracledb_session.rb +4 -2
  96. data/lib/inspec/resources/os_env.rb +1 -0
  97. data/lib/inspec/resources/package.rb +10 -6
  98. data/lib/inspec/resources/packages.rb +7 -5
  99. data/lib/inspec/resources/passwd.rb +7 -7
  100. data/lib/inspec/resources/pip.rb +2 -0
  101. data/lib/inspec/resources/port.rb +22 -8
  102. data/lib/inspec/resources/postgres.rb +2 -1
  103. data/lib/inspec/resources/postgres_conf.rb +2 -0
  104. data/lib/inspec/resources/postgres_hba_conf.rb +6 -6
  105. data/lib/inspec/resources/postgres_ident_conf.rb +3 -3
  106. data/lib/inspec/resources/processes.rb +16 -15
  107. data/lib/inspec/resources/rabbitmq_config.rb +2 -0
  108. data/lib/inspec/resources/registry_key.rb +8 -3
  109. data/lib/inspec/resources/security_identifier.rb +3 -1
  110. data/lib/inspec/resources/security_policy.rb +2 -1
  111. data/lib/inspec/resources/service.rb +13 -1
  112. data/lib/inspec/resources/shadow.rb +1 -0
  113. data/lib/inspec/resources/ssh_config.rb +2 -0
  114. data/lib/inspec/resources/ssl.rb +12 -11
  115. data/lib/inspec/resources/users.rb +29 -19
  116. data/lib/inspec/resources/virtualization.rb +10 -0
  117. data/lib/inspec/resources/windows_feature.rb +1 -1
  118. data/lib/inspec/resources/windows_hotfix.rb +2 -0
  119. data/lib/inspec/resources/windows_task.rb +4 -0
  120. data/lib/inspec/resources/wmi.rb +2 -1
  121. data/lib/inspec/resources/x509_certificate.rb +8 -0
  122. data/lib/inspec/resources/xinetd_conf.rb +10 -9
  123. data/lib/inspec/resources/yum.rb +15 -11
  124. data/lib/inspec/resources/zfs_dataset.rb +4 -2
  125. data/lib/inspec/resources/zfs_pool.rb +2 -1
  126. data/lib/inspec/rule.rb +11 -1
  127. data/lib/inspec/runner.rb +9 -6
  128. data/lib/inspec/runner_rspec.rb +10 -8
  129. data/lib/inspec/schema.rb +1 -0
  130. data/lib/inspec/secrets.rb +1 -0
  131. data/lib/inspec/secrets/yaml.rb +1 -0
  132. data/lib/inspec/shell.rb +20 -19
  133. data/lib/inspec/shell_detector.rb +1 -1
  134. data/lib/inspec/source_reader.rb +2 -0
  135. data/lib/inspec/ui.rb +1 -0
  136. data/lib/inspec/utils/deprecation/config_file.rb +8 -4
  137. data/lib/inspec/utils/erlang_parser.rb +2 -0
  138. data/lib/inspec/utils/file_reader.rb +1 -1
  139. data/lib/inspec/utils/filter.rb +16 -3
  140. data/lib/inspec/utils/find_files.rb +2 -2
  141. data/lib/inspec/utils/object_traversal.rb +1 -0
  142. data/lib/inspec/utils/parser.rb +2 -0
  143. data/lib/inspec/utils/simpleconfig.rb +4 -1
  144. data/lib/inspec/utils/telemetry/global_methods.rb +1 -0
  145. data/lib/inspec/version.rb +1 -1
  146. data/lib/matchers/matchers.rb +4 -1
  147. data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +12 -11
  148. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +15 -11
  149. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +4 -2
  150. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +13 -12
  151. data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +3 -0
  152. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +1 -1
  153. data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +2 -2
  154. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +1 -0
  155. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +6 -5
  156. data/lib/plugins/shared/core_plugin_test_helper.rb +1 -0
  157. data/lib/source_readers/flat.rb +1 -0
  158. data/lib/source_readers/inspec.rb +1 -0
  159. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3f9a9b00cc2ce6cc3be695589b41cdeecdc988c00d6f0636024fc35b739ffac
4
- data.tar.gz: 385c7be34679985f6e6541bba865277f42b64cc6d14ed6d69c9430b3472b6d60
3
+ metadata.gz: 28c863490aac987ef4d371231c350cb4a8b49a1f1ba115e31099a125b6017af9
4
+ data.tar.gz: b004afbe062795dc0e5a0169e370e3845c8d8361bf5767e3513bd7e84612adaf
5
5
  SHA512:
6
- metadata.gz: 47250251654358a3f822c058c7babce2d2d17dcd31c7ca78feef1832ce459c919f4a979550bf39af6ea419119314176ff6649b1df38bf2cdc08132707ea2305f
7
- data.tar.gz: d2d2ee9b16a474021a92f546b266e518bc37da3c98034007a7810171a6741ff3bacbb901e9857d417f173fc34a3e45371c6a0be62de0da4286aa991f727c48e1
6
+ metadata.gz: 18bafe0200e418478fe85a6880b7760e2fea9ac486cb4704af9a866822fcf2e48deb728dc636527d555b3668ca60ee7ea4a9926d05605f75388d0587cfce386f
7
+ data.tar.gz: 13cb08637d64a0d3fbbdda987abb9d06fff11307d9bff88b5405da6e273e2758be067df9db46c75e05a3f1ef1fda9f60c5902417e58af89950db2765560035e1
@@ -35,10 +35,11 @@ module Supermarket
35
35
  def self.info(profile, supermarket_url = SUPERMARKET_URL)
36
36
  _tool_owner, tool_name = profile_name("supermarket://#{profile}")
37
37
  return if tool_name.nil? || tool_name.empty?
38
+
38
39
  # Tool name in Supermarket URL is downcased so we need to downcase
39
40
  url = "#{supermarket_url}/api/v1/tools/#{tool_name.downcase}"
40
41
  _success, data = get(url, {})
41
- JSON.parse(data) if !data.nil?
42
+ JSON.parse(data) unless data.nil?
42
43
  rescue JSON::ParserError
43
44
  nil
44
45
  end
@@ -20,7 +20,7 @@ module Supermarket
20
20
 
21
21
  headline("Available profiles:")
22
22
  supermarket_profiles.each do |p|
23
- li("#{p['tool_name']} #{mark_text(p['tool_owner'] + '/' + p['slug'])}")
23
+ li("#{p["tool_name"]} #{mark_text(p["tool_owner"] + "/" + p["slug"])}")
24
24
  end
25
25
  end
26
26
 
@@ -48,7 +48,7 @@ module Supermarket
48
48
  # check that the profile is available
49
49
  supermarket_profiles = Supermarket::API.profiles
50
50
  found = supermarket_profiles.select do |p|
51
- profile == "#{p['tool_owner']}/#{p['slug']}"
51
+ profile == "#{p["tool_owner"]}/#{p["slug"]}"
52
52
  end
53
53
 
54
54
  if found.empty?
@@ -58,11 +58,11 @@ module Supermarket
58
58
 
59
59
  # load details for the specific profile
60
60
  info = Supermarket::API.info(profile)
61
- puts "#{mark_text('name: ')} #{info['slug']}"
62
- puts "#{mark_text('owner:')} #{info['owner']}"
63
- puts "#{mark_text('url: ')} #{info['source_url']}"
61
+ puts "#{mark_text("name: ")} #{info["slug"]}"
62
+ puts "#{mark_text("owner:")} #{info["owner"]}"
63
+ puts "#{mark_text("url: ")} #{info["source_url"]}"
64
64
  puts
65
- puts "#{mark_text('description: ')} #{info['description']}"
65
+ puts "#{mark_text("description: ")} #{info["description"]}"
66
66
  end
67
67
  end
68
68
 
@@ -17,6 +17,7 @@ module Supermarket
17
17
  end
18
18
  return nil unless supermarket_uri
19
19
  return nil unless Supermarket::API.exist?(supermarket_uri, supermarket_server)
20
+
20
21
  tool_info = Supermarket::API.find(supermarket_uri, supermarket_server)
21
22
  resolve_next(tool_info["tool_source_url"], opts)
22
23
  rescue URI::Error
data/lib/fetchers/git.rb CHANGED
@@ -89,10 +89,12 @@ module Fetchers
89
89
  command_string = "git ls-remote \"#{@remote_url}\" \"#{ref_name}*\""
90
90
  cmd = shellout(command_string)
91
91
  raise "Error running '#{command_string}': #{cmd.stderr}" unless cmd.exitstatus == 0
92
+
92
93
  ref = parse_ls_remote(cmd.stdout, ref_name)
93
- if !ref
94
+ unless ref
94
95
  raise "Unable to resolve #{ref_name} to a specific git commit for #{@remote_url}"
95
96
  end
97
+
96
98
  ref
97
99
  end
98
100
 
data/lib/fetchers/mock.rb CHANGED
@@ -7,6 +7,7 @@ module Fetchers
7
7
 
8
8
  def self.resolve(target)
9
9
  return nil unless target.is_a? Hash
10
+
10
11
  new(target)
11
12
  end
12
13
 
data/lib/fetchers/url.rb CHANGED
@@ -29,6 +29,7 @@ module Fetchers
29
29
  uri = URI.parse(target)
30
30
  return nil if uri.nil? || uri.scheme.nil?
31
31
  return nil unless %{ http https }.include? uri.scheme
32
+
32
33
  target = transform(target)
33
34
  opts[:username] = username if username
34
35
  opts[:password] = password if password
@@ -121,6 +122,7 @@ module Fetchers
121
122
 
122
123
  def parse_uri(target)
123
124
  return URI.parse(target) if target.is_a?(String)
125
+
124
126
  URI.parse(target[:url])
125
127
  end
126
128
 
@@ -150,7 +152,7 @@ module Fetchers
150
152
  end
151
153
 
152
154
  def download_automate2_archive_to_temp
153
- return @temp_archive_path if !@temp_archive_path.nil?
155
+ return @temp_archive_path unless @temp_archive_path.nil?
154
156
 
155
157
  Inspec::Log.debug("Fetching URL: #{@target}")
156
158
  json = {
@@ -189,7 +191,8 @@ module Fetchers
189
191
 
190
192
  # Downloads archive to temporary file with side effect :( of setting @archive_type
191
193
  def download_archive_to_temp
192
- return @temp_archive_path if !@temp_archive_path.nil?
194
+ return @temp_archive_path unless @temp_archive_path.nil?
195
+
193
196
  Inspec::Log.debug("Fetching URL: #{@target}")
194
197
  remote = open_via_uri(@target)
195
198
  @archive_type = file_type_from_remote(remote) # side effect :(
@@ -262,7 +265,7 @@ module Fetchers
262
265
  end
263
266
  unless keys_missing_values.empty?
264
267
  raise "Unable to fetch profile - the following HTTP headers have no value: " \
265
- "#{keys_missing_values.join(', ')}"
268
+ "#{keys_missing_values.join(", ")}"
266
269
  end
267
270
  end
268
271
  end
@@ -22,6 +22,7 @@ module Inspec
22
22
  # the Ruby stdlib for a better experience.
23
23
  def local_transport?
24
24
  return false unless defined?(Train::Transports::Local)
25
+
25
26
  backend.is_a?(Train::Transports::Local::Connection)
26
27
  end
27
28
 
@@ -10,9 +10,11 @@ require "inspec/utils/deprecation/global_method"
10
10
  class Thor::Arguments
11
11
  def parse_array(_name)
12
12
  return shift if peek.is_a?(Array)
13
+
13
14
  array = []
14
15
  while current_is_value?
15
16
  break unless @parsing_options
17
+
16
18
  array << shift
17
19
  end
18
20
  array
@@ -157,7 +159,7 @@ module Inspec
157
159
  next if data.nil?
158
160
 
159
161
  data = "\e[1m\e[#{color}m#{data}\e[0m"
160
- str << format("#{' ' * indent}%-10s %s\n", item.to_s.capitalize + ":", data)
162
+ str << format("#{" " * indent}%-10s %s\n", item.to_s.capitalize + ":", data)
161
163
  end
162
164
  str
163
165
  end
@@ -218,6 +220,7 @@ module Inspec
218
220
 
219
221
  def suppress_log_output?(opts)
220
222
  return false if opts["reporter"].nil?
223
+
221
224
  match = %w{json json-min json-rspec json-automate junit html yaml documentation progress} & opts["reporter"].keys
222
225
  unless match.empty?
223
226
  match.each do |m|
data/lib/inspec/cli.rb CHANGED
@@ -124,7 +124,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
124
124
  else
125
125
  %w{location profile controls timestamp valid}.each do |item|
126
126
  puts format("%-12s %s", item.to_s.capitalize + ":",
127
- mark_text(result[:summary][item.to_sym]))
127
+ mark_text(result[:summary][item.to_sym]))
128
128
  end
129
129
  puts
130
130
 
@@ -148,8 +148,8 @@ class Inspec::InspecCLI < Inspec::BaseCLI
148
148
 
149
149
  puts
150
150
  puts format("Summary: %s%d errors%s, %s%d warnings%s",
151
- red, result[:errors].length, rst,
152
- yellow, result[:warnings].length, rst)
151
+ red, result[:errors].length, rst,
152
+ yellow, result[:warnings].length, rst)
153
153
  end
154
154
  end
155
155
  exit 1 unless result[:summary][:valid]
@@ -375,7 +375,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
375
375
  puts Inspec::Schema.json(name)
376
376
  rescue StandardError => e
377
377
  puts e
378
- puts "Valid schemas are #{Inspec::Schema.names.join(', ')}"
378
+ puts "Valid schemas are #{Inspec::Schema.names.join(", ")}"
379
379
  end
380
380
 
381
381
  desc "version", "prints the version of this tool"
@@ -410,6 +410,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
410
410
  runner.load
411
411
 
412
412
  return :ruby_eval, res if runner.all_rules.empty?
413
+
413
414
  return :rspec_run, runner.run_tests # rubocop:disable Style/RedundantReturn
414
415
  end
415
416
  end
data/lib/inspec/config.rb CHANGED
@@ -60,6 +60,7 @@ module Inspec
60
60
 
61
61
  def diagnose
62
62
  return unless self[:diagnose]
63
+
63
64
  puts "InSpec version: #{Inspec::VERSION}"
64
65
  puts "Train version: #{Train::VERSION}"
65
66
  puts "Command line configuration:"
@@ -159,6 +160,7 @@ module Inspec
159
160
  unless transport_name
160
161
  raise ArgumentError, "Could not recognize a backend from the target #{final_options[:target]} - use a URI format with the backend name as the URI schema. Example: 'ssh://somehost.com' or 'transport://credset' or 'transport://' if credentials are provided outside of InSpec."
161
162
  end
163
+
162
164
  credentials[:backend] = transport_name.to_s # these are indeed stored in Train as Strings.
163
165
  end
164
166
 
@@ -185,6 +187,7 @@ module Inspec
185
187
 
186
188
  def _utc_find_credset_name(_credentials, transport_name)
187
189
  return nil unless final_options[:target]
190
+
188
191
  match = final_options[:target].match(%r{^#{transport_name}://(?<credset_name>[\w\d\-]+)$})
189
192
  match ? match[:credset_name] : nil
190
193
  end
@@ -196,6 +199,7 @@ module Inspec
196
199
  # Regardless of our situation, end up with a readable IO object
197
200
  def resolve_cfg_io(cli_opts, cfg_io)
198
201
  raise(ArgumentError, "Inspec::Config must use an IO to read from") if cfg_io && !cfg_io.respond_to?(:read)
202
+
199
203
  cfg_io ||= check_for_piped_config(cli_opts)
200
204
  return cfg_io if cfg_io
201
205
 
@@ -211,6 +215,7 @@ module Inspec
211
215
 
212
216
  return nil unless cli_opt
213
217
  return nil unless cli_opt == "-"
218
+
214
219
  # This warning is here so that if a user invokes inspec with --config=-,
215
220
  # they will have an explanation for why it appears to hang.
216
221
  Inspec::Log.warn "Reading JSON config from standard input" if STDIN.tty?
@@ -287,13 +292,14 @@ module Inspec
287
292
  valid_fields = %w{version cli_options credentials compliance reporter}.sort
288
293
  @cfg_file_contents.keys.each do |seen_field|
289
294
  unless valid_fields.include?(seen_field)
290
- raise Inspec::ConfigError::Invalid, "Unrecognized top-level configuration field #{seen_field}. Recognized fields: #{valid_fields.join(', ')}"
295
+ raise Inspec::ConfigError::Invalid, "Unrecognized top-level configuration field #{seen_field}. Recognized fields: #{valid_fields.join(", ")}"
291
296
  end
292
297
  end
293
298
  end
294
299
 
295
300
  def validate_reporters!(reporters)
296
301
  return if reporters.nil?
302
+
297
303
  # TODO: move this into a reporter plugin type system
298
304
  valid_types = %w{
299
305
  automate
@@ -313,6 +319,7 @@ module Inspec
313
319
  raise NotImplementedError, "'#{reporter_name}' is not a valid reporter type." unless valid_types.include?(reporter_name)
314
320
 
315
321
  next unless reporter_name == "automate"
322
+
316
323
  %w{token url}.each do |option|
317
324
  raise Inspec::ReporterError, "You must specify a automate #{option} via the config file." if reporter_config[option].nil?
318
325
  end
@@ -410,6 +417,7 @@ module Inspec
410
417
  %w{password sudo-password}.each do |option_name|
411
418
  snake_case_option_name = option_name.tr("-", "_").to_s
412
419
  next unless options[snake_case_option_name] == -1 # Thor sets -1 for missing value - see #1918
420
+
413
421
  raise ArgumentError, "Please provide a value for --#{option_name}. For example: --#{option_name}=hello."
414
422
  end
415
423
 
@@ -216,6 +216,7 @@ module Inspec
216
216
  return if @skip_only_if_eval == true
217
217
 
218
218
  return if block.yield == true
219
+
219
220
  # Apply `set_skip_rule` for other rules in the same file
220
221
  profile_context_owner.rules.values.each do |r|
221
222
  sources_match = r.source_file == block.source_location[0]
@@ -49,6 +49,7 @@ module Inspec
49
49
  #
50
50
  def exists?(key)
51
51
  return false if key.nil? || key.empty?
52
+
52
53
  path = base_path_for(key)
53
54
  File.directory?(path) || File.exist?("#{path}.tar.gz") || File.exist?("#{path}.zip")
54
55
  end
@@ -71,6 +71,7 @@ module Inspec
71
71
 
72
72
  def to_array
73
73
  return [] if @dep_list.nil?
74
+
74
75
  @dep_list.map do |_k, v|
75
76
  v.to_hash
76
77
  end.compact
@@ -85,6 +86,7 @@ module Inspec
85
86
  #
86
87
  def vendor(dependencies)
87
88
  return nil if dependencies.nil? || dependencies.empty?
89
+
88
90
  @dep_list = Resolver.resolve(dependencies, @cache, @cwd, @backend)
89
91
  end
90
92
  end
@@ -18,6 +18,7 @@ module Inspec
18
18
  parsed_content = YAML.load(content)
19
19
  version = parsed_content["lockfile_version"]
20
20
  raise "No lockfile_version set in #{path}!" if version.nil?
21
+
21
22
  validate_lockfile_version!(version.to_i)
22
23
  new(parsed_content)
23
24
  end
@@ -21,16 +21,16 @@ module Inspec
21
21
  }
22
22
 
23
23
  new(dep[:name],
24
- dep[:version],
25
- config,
26
- opts.merge(dep))
24
+ dep[:version],
25
+ config,
26
+ opts.merge(dep))
27
27
  end
28
28
 
29
29
  def self.from_lock_entry(entry, config, opts = {})
30
30
  req = new(entry[:name],
31
- entry[:version_constraints],
32
- config,
33
- entry[:resolved_source].merge(backend: config[:backend]).merge(opts))
31
+ entry[:version_constraints],
32
+ config,
33
+ entry[:resolved_source].merge(backend: config[:backend]).merge(opts))
34
34
 
35
35
  locked_deps = []
36
36
  Array(entry[:dependencies]).each do |dep_entry|
@@ -86,7 +86,7 @@ module Inspec
86
86
  "version_constraints" => version_constraints,
87
87
  }
88
88
 
89
- if !dependencies.empty?
89
+ unless dependencies.empty?
90
90
  h["dependencies"] = dependencies.map(&:to_hash)
91
91
  end
92
92
 
@@ -115,6 +115,7 @@ module Inspec
115
115
  # load the profile for the requirement
116
116
  def profile
117
117
  return @profile unless @profile.nil?
118
+
118
119
  opts = @opts.dup
119
120
  opts[:backend] = @backend
120
121
  opts[:runner_conf] = Inspec::Config.cached
@@ -37,7 +37,7 @@ module Inspec
37
37
  problem_cookbook = if top_level
38
38
  "the inspec.yml for this profile."
39
39
  else
40
- "the dependency information for #{path_string.split(' ').last}"
40
+ "the dependency information for #{path_string.split(" ").last}"
41
41
  end
42
42
  raise Inspec::DuplicateDep, "The dependency #{dep.name} is listed twice in #{problem_cookbook}"
43
43
  else
@@ -68,13 +68,13 @@ module Inspec
68
68
 
69
69
  new_seen_items[dep.resolved_source] = true
70
70
 
71
- if !dep.source_satisfies_spec?
71
+ unless dep.source_satisfies_spec?
72
72
  raise Inspec::UnsatisfiedVersionSpecification, "The profile #{dep.name} from #{dep.resolved_source} has a version #{dep.source_version} which doesn't match #{dep.version_constraints}"
73
73
  end
74
74
 
75
75
  Inspec::Log.debug("Adding dependency #{dep.name} (#{dep.resolved_source})")
76
76
  graph[dep.name] = dep
77
- if !dep.dependencies.empty?
77
+ unless dep.dependencies.empty?
78
78
  resolve(dep.dependencies, false, new_seen_items.dup, new_path_string)
79
79
  end
80
80
  end
@@ -12,6 +12,7 @@ module Inspec
12
12
  # @return [nil]
13
13
  def one(&block)
14
14
  return unless block_given?
15
+
15
16
  instance_eval(&block)
16
17
  @action.call("describe.one", @checks, nil)
17
18
  end
data/lib/inspec/dsl.rb CHANGED
@@ -68,7 +68,7 @@ module Inspec::DSL
68
68
  context = dep_entry.profile.runner_context
69
69
  # if we don't want all the rules, then just make 1 pass to get all rule_IDs
70
70
  # that we want to keep from the original
71
- filter_included_controls(context, dep_entry.profile, &block) if !opts[:include_all]
71
+ filter_included_controls(context, dep_entry.profile, &block) unless opts[:include_all]
72
72
  # interpret the block and skip/modify as required
73
73
  context.load(block) if block_given?
74
74
  bind_context.add_subcontext(context)
@@ -10,7 +10,7 @@ module Inspec
10
10
 
11
11
  def require(path)
12
12
  rbpath = path + ".rb"
13
- return __ruby_require(path) if !@require_loader.exists?(rbpath)
13
+ return __ruby_require(path) unless @require_loader.exists?(rbpath)
14
14
  return false if @require_loader.loaded?(rbpath)
15
15
 
16
16
  # This is equivalent to calling `require 'lib'` with lib on disk.
@@ -23,8 +23,8 @@ module Inspec
23
23
  end
24
24
 
25
25
  def print_and_exit!
26
- exit_no_shell if !have_shell?
27
- exit_no_completion if !have_shell_completion?
26
+ exit_no_shell unless have_shell?
27
+ exit_no_completion unless have_shell_completion?
28
28
 
29
29
  print_completion_for_shell
30
30
  print_detection_warning($stdout) if @detected
@@ -77,7 +77,7 @@ module Inspec
77
77
  #
78
78
  # inspec env SHELLNAME
79
79
  #
80
- # Currently supported shells are: #{shells_with_completions.join(', ')}
80
+ # Currently supported shells are: #{shells_with_completions.join(", ")}
81
81
  #
82
82
  EOF
83
83
  end
@@ -98,7 +98,7 @@ module Inspec
98
98
  #
99
99
  # inspec env SHELLNAME
100
100
  #
101
- # Currently supported shells are: #{shells_with_completions.join(', ')}
101
+ # Currently supported shells are: #{shells_with_completions.join(", ")}
102
102
  EOF
103
103
  exit 1
104
104
  end