From 61818d5a3b944e0ea3a7f02a644f5f89e033a3ae Mon Sep 17 00:00:00 2001 From: Jacob Scrapchansky Date: Wed, 4 Aug 2021 13:24:00 -0400 Subject: [PATCH 1/2] Added conversion to array when string is detected in csv2inspec --- lib/inspec_tools/csv.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/inspec_tools/csv.rb b/lib/inspec_tools/csv.rb index 84f1f0e..d00626a 100644 --- a/lib/inspec_tools/csv.rb +++ b/lib/inspec_tools/csv.rb @@ -74,7 +74,11 @@ def parse_controls(prefix) control['tags']['nist'] = nist unless nist.nil? || nist.include?(nil) @mapping['control.tags'].each do |tag| if tag.first == 'cci' - control['tags'][tag.first] = cci_number + if cci_number.is_a? String + control['tags'][tag.first] = [cci_number] + else + control['tags'][tag.first] = cci_number + end next end control['tags'][tag.first] = row[tag.last] unless row[tag.last].nil? From e4fc326e0145197351c03d22e7dc9205374f2921 Mon Sep 17 00:00:00 2001 From: Furrure <71794171+Furrure@users.noreply.github.com> Date: Mon, 9 Aug 2021 11:25:57 -0400 Subject: [PATCH 2/2] Update csv.rb Changed to detect if it is an array, rather than checking if it is a string. --- lib/inspec_tools/csv.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/inspec_tools/csv.rb b/lib/inspec_tools/csv.rb index d00626a..b1ef09a 100644 --- a/lib/inspec_tools/csv.rb +++ b/lib/inspec_tools/csv.rb @@ -74,10 +74,10 @@ def parse_controls(prefix) control['tags']['nist'] = nist unless nist.nil? || nist.include?(nil) @mapping['control.tags'].each do |tag| if tag.first == 'cci' - if cci_number.is_a? String - control['tags'][tag.first] = [cci_number] - else + if cci_number.is_a? Array control['tags'][tag.first] = cci_number + else + control['tags'][tag.first] = [cci_number] end next end