Class: Util::ExtractNistMappings
- Defined in:
- lib/utilities/extract_nist_cis_mapping.rb
Instance Method Summary collapse
- #full_excl ⇒ Object
-
#initialize(file) ⇒ ExtractNistMappings
constructor
A new instance of ExtractNistMappings.
- #map_headers ⇒ Object
- #open_excel ⇒ Object
- #retrieve_mappings ⇒ Object
- #set_working_sheet ⇒ Object
Constructor Details
#initialize(file) ⇒ ExtractNistMappings
Returns a new instance of ExtractNistMappings.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 5 def initialize(file) @file = file @full_excel = [] @headers = {} open_excel set_working_sheet map_headers retrieve_mappings end |
Instance Method Details
#full_excl ⇒ Object
20 21 22 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 20 def full_excl @full_excel end |
#map_headers ⇒ Object
28 29 30 31 32 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 28 def map_headers @xlsx.row(3).each_with_index { |header, i| @headers[header] = i } end |
#open_excel ⇒ Object
16 17 18 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 16 def open_excel @xlsx = Roo::Excelx.new(@file) end |
#retrieve_mappings ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 34 def retrieve_mappings nist_ver = 4 cis_ver = @xlsx.row(2)[4].split(' ')[-1] ctrl_count = 1 ((@xlsx.first_row + 3)..@xlsx.last_row).each do |row_value| current_row = {} if @xlsx.row(row_value)[@headers['NIST SP 800-53 Control #']].to_s != '' current_row[:nist] = @xlsx.row(row_value)[@headers['NIST SP 800-53 Control #']].to_s else current_row[:nist] = 'Not Mapped' end current_row[:nist_ver] = nist_ver if @xlsx.row(row_value)[@headers['Control']].to_s == '' current_row[:cis] = ctrl_count.to_s ctrl_count += 1 else current_row[:cis] = @xlsx.row(row_value)[@headers['Control']].to_s end current_row[:cis_ver] = cis_ver @full_excel << current_row end end |
#set_working_sheet ⇒ Object
24 25 26 |
# File 'lib/utilities/extract_nist_cis_mapping.rb', line 24 def set_working_sheet @xlsx.default_sheet = 'VER 6.1 Controls' end |