12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/inspec/utils/waivers/csv_file_reader.rb', line 12
def self.fetch_data(path)
waiver_data_hash = {}
CSV.foreach(path, headers: true) do |row|
row_hash = row.to_hash
= row_hash.keys if .empty?
control_id = row_hash["control_id"]
row_hash.delete("control_id")
row_hash.delete_if { |k, v| k.nil? || v.nil? }
waiver_data_hash[control_id] = row_hash if control_id && !(row_hash.nil? || row_hash.empty?)
end
waiver_data_hash
rescue CSV::MalformedCSVError => e
raise "Error reading InSpec waivers in CSV: #{e}"
end
|