inspec_tools 2.0.4 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +0,0 @@
1
- require 'roo'
2
-
3
- module Util
4
- class ExtractNistMappings
5
- def initialize(file)
6
- @file = file
7
- @full_excel = []
8
- @headers = {}
9
-
10
- open_excel
11
- set_working_sheet
12
- map_headers
13
- retrieve_mappings
14
- end
15
-
16
- def open_excel
17
- @xlsx = Roo::Excelx.new(@file)
18
- end
19
-
20
- def full_excl
21
- @full_excel
22
- end
23
-
24
- def set_working_sheet
25
- @xlsx.default_sheet = 'VER 6.1 Controls'
26
- end
27
-
28
- def map_headers
29
- @xlsx.row(3).each_with_index { |header, i|
30
- @headers[header] = i
31
- }
32
- end
33
-
34
- def retrieve_mappings
35
- nist_ver = 4
36
- cis_ver = @xlsx.row(2)[4].split(' ')[-1]
37
- ctrl_count = 1
38
- ((@xlsx.first_row + 3)..@xlsx.last_row).each do |row_value|
39
- current_row = {}
40
- if @xlsx.row(row_value)[@headers['NIST SP 800-53 Control #']].to_s != ''
41
- current_row[:nist] = @xlsx.row(row_value)[@headers['NIST SP 800-53 Control #']].to_s
42
- else
43
- current_row[:nist] = 'Not Mapped'
44
- end
45
- current_row[:nist_ver] = nist_ver
46
- if @xlsx.row(row_value)[@headers['Control']].to_s == ''
47
- current_row[:cis] = ctrl_count.to_s
48
- ctrl_count += 1
49
- else
50
- current_row[:cis] = @xlsx.row(row_value)[@headers['Control']].to_s
51
- end
52
- current_row[:cis_ver] = cis_ver
53
- @full_excel << current_row
54
- end
55
- end
56
- end
57
- end