inspec-core 5.22.36 → 5.22.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbe23835cae58303aa3ac665ecd59e269752bbe4f6448e33db3219df0f04dbc8
4
- data.tar.gz: 9a6d1e0e7758054f4d2746355a0c5538ede8af58a4220b3160d999f5e3093f34
3
+ metadata.gz: a95805ac2a4faab83d1826792a5d838caa5f1808fcc884e061cf3f7070ab6ef2
4
+ data.tar.gz: 984dfca55efec04f1e9b98ddfebf5be636b96a91c7fe7dc97f9ffb9789c60af3
5
5
  SHA512:
6
- metadata.gz: c074f69651db5a586e4fee3b1a621ef9cc43d05634136dae9e0008a22c2d74d0515fe2938f83df42aace4ad089bbab3e95cf3d70bf3825b88aaca5e8e0696518
7
- data.tar.gz: f01196343c6f7109cb44ced5f3a23a2b3f7b543f88a48d34d0b49c2b2a47dae31c599af4f51febca1afecbc1355f471c543c2ac8484c5c1a669ea4fec41cfe45
6
+ metadata.gz: fb6e20f346e0e5ab27878931b1396c10a633b99767472774299d92fce3ae2ccf01399cb100e5ae4566456039a3d814ac4148670da65b41563e72139d29551ed7
7
+ data.tar.gz: 0c9c665c3afb6d90121bf40ac00736a900955e0ea5955af58f7e56378d18eecfd7560f40e2cce049afd7156ecb495c77b1c58765c0e69f82bfd03e976c2f367f
@@ -26,7 +26,7 @@ module Inspec
26
26
  dep_list = {}
27
27
  dependencies.each do |d|
28
28
  # if depedent profile does not have a source version then only name is used in dependency hash
29
- key_name = (d.source_version.blank? ? "#{d.name}" : "#{d.name}-#{d.source_version}") rescue "#{d.name}"
29
+ key_name = ((d.source_version.nil? || d.source_version.empty?) ? "#{d.name}" : "#{d.name}-#{d.source_version}") rescue "#{d.name}"
30
30
  dep_list[key_name] = d
31
31
  end
32
32
  new(cwd, cache, dep_list, backend)
@@ -42,7 +42,7 @@ module Inspec
42
42
  dep_list = {}
43
43
  dep_tree.each do |d|
44
44
  # if depedent profile does not have a source version then only name is used in dependency hash
45
- key_name = (d.source_version.blank? ? "#{d.name}" : "#{d.name}-#{d.source_version}") rescue "#{d.name}"
45
+ key_name = ((d.source_version.nil? || d.source_version.empty?) ? "#{d.name}" : "#{d.name}-#{d.source_version}") rescue "#{d.name}"
46
46
  dep_list[key_name] = d
47
47
  dep_list.merge!(flatten_dep_tree(d.dependencies))
48
48
  end
data/lib/inspec/dsl.rb CHANGED
@@ -95,7 +95,7 @@ module Inspec::DSL
95
95
  # 1. Fetching VERSION from a profile dependency name which is in a format NAME-VERSION.
96
96
  # 2. Matching original profile dependency name with profile name used with include or require control DSL.
97
97
  source_version = value.source_version
98
- unless source_version.blank?
98
+ unless source_version.nil? || source_version.empty?
99
99
  profile_id_key = key.split("-#{source_version}")[0]
100
100
  new_profile_id = key if profile_id_key == profile_id
101
101
  end
@@ -248,7 +248,7 @@ module Inspec
248
248
  ## Find the waivers file
249
249
  # - TODO: cli_opts and instance_variable_get could be exposed
250
250
  waiver_paths = cfg.instance_variable_get(:@cli_opts)["waiver_file"]
251
- if waiver_paths.blank?
251
+ if waiver_paths.nil? || waiver_paths.empty?
252
252
  Inspec::Log.error "Must use --waiver-file with --filter-waived-controls"
253
253
  Inspec::UI.new.exit(:usage_error)
254
254
  end
@@ -276,7 +276,7 @@ module Inspec
276
276
  # be processed and rendered
277
277
  tests.each do |control_filename, source_code|
278
278
  cleared_tests = source_code.scan(/control\s+['"].+?['"].+?(?=(?:control\s+['"].+?['"])|\z)/m).collect do |element|
279
- next if element.blank?
279
+ next if element.nil? || element.empty?
280
280
 
281
281
  if element&.match?(waived_control_id_regex)
282
282
  splitlines = element.split("\n")
@@ -317,7 +317,7 @@ module Inspec::Reporters
317
317
  not_applicable = 0
318
318
 
319
319
  all_unique_controls.each do |control|
320
- next if control[:status].empty?
320
+ next if control[:status].nil? || control[:status].empty?
321
321
 
322
322
  if control[:status] == "failed"
323
323
  failed += 1
data/lib/inspec/rule.rb CHANGED
@@ -375,19 +375,24 @@ module Inspec
375
375
  # only_if mechanism)
376
376
  # Double underscore: not intended to be called as part of the DSL
377
377
  def __apply_waivers
378
+ @__waiver_data = nil
378
379
  control_id = @__rule_id # TODO: control ID slugging
379
- waiver_files = Inspec::Config.cached.final_options["waiver_file"] if Inspec::Config.cached.respond_to?(:final_options)
380
380
 
381
- waiver_data_by_profile = Inspec::WaiverFileReader.fetch_waivers_by_profile(__profile_id, waiver_files) unless waiver_files.nil?
381
+ waiver_files = Inspec::Config.cached.final_options["waiver_file"] if Inspec::Config.cached.respond_to?(:final_options)
382
+ unless waiver_files.nil? || waiver_files.empty?
383
+ waiver_data_by_profile = Inspec::WaiverFileReader.fetch_waivers_by_profile(__profile_id, waiver_files)
384
+ return unless waiver_data_by_profile && waiver_data_by_profile[control_id] && waiver_data_by_profile[control_id].is_a?(Hash)
382
385
 
383
- return unless waiver_data_by_profile && waiver_data_by_profile[control_id] && waiver_data_by_profile[control_id].is_a?(Hash)
386
+ @__waiver_data = waiver_data_by_profile[control_id]
387
+ else
388
+ # Support for input registry is provided for backward compatibilty with compliance phase of chef-client
389
+ # Chef-client sends waiver information in inputs hash
390
+ input_registry = Inspec::InputRegistry.instance
391
+ waiver_data_via_input = input_registry.inputs_by_profile.dig(__profile_id, control_id)
392
+ return unless waiver_data_via_input && waiver_data_via_input.has_value? && waiver_data_via_input.value.is_a?(Hash)
384
393
 
385
- # An InSpec Input is a datastructure that tracks a profile parameter
386
- # over time. Its value can be set by many sources, and it keeps a
387
- # log of each "set" event so that when it is collapsed to a value,
388
- # it can determine the correct (highest priority) value.
389
- # Store in an instance variable for.. later reading???
390
- @__waiver_data = waiver_data_by_profile[control_id]
394
+ @__waiver_data = waiver_data_via_input.value
395
+ end
391
396
 
392
397
  __waiver_data["skipped_due_to_waiver"] = false
393
398
  __waiver_data["message"] = ""
data/lib/inspec/runner.rb CHANGED
@@ -142,7 +142,7 @@ module Inspec
142
142
  get_check_example(m, a, b)
143
143
  end.compact
144
144
 
145
- examples.map { |example| total_checks += example.examples.count }
145
+ examples.map { |example| total_checks += example.descendant_filtered_examples.count }
146
146
 
147
147
  unless control_describe_checks.empty?
148
148
  # controls with empty tests are avoided
@@ -19,7 +19,7 @@ module Waivers
19
19
  row_hash.delete("control_id")
20
20
  row_hash.delete_if { |k, v| k.nil? || v.nil? }
21
21
 
22
- waiver_data_hash[control_id] = row_hash if control_id && !row_hash.blank?
22
+ waiver_data_hash[control_id] = row_hash if control_id && !(row_hash.nil? || row_hash.empty?)
23
23
  end
24
24
 
25
25
  waiver_data_hash
@@ -25,7 +25,7 @@ module Waivers
25
25
  row_hash.delete_if { |k, v| k.nil? || v.nil? }
26
26
  end
27
27
 
28
- waiver_data_hash[control_id] = row_hash if control_id && !row_hash.blank?
28
+ waiver_data_hash[control_id] = row_hash if control_id && !(row_hash.nil? || row_hash.empty?)
29
29
  end
30
30
  waiver_data_hash
31
31
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "5.22.36".freeze
2
+ VERSION = "5.22.40".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.22.36
4
+ version: 5.22.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-14 00:00:00.000000000 Z
11
+ date: 2024-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry