Class: HeimdallTools::DBProtectMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/heimdall_tools/dbprotect_mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, _name = nil) ⇒ DBProtectMapper

Returns a new instance of DBProtectMapper.



15
16
17
18
19
20
# File 'lib/heimdall_tools/dbprotect_mapper.rb', line 15

def initialize(xml, _name = nil)
  dataset = xml_to_hash(xml)
  @entries = compile_findings(dataset['dataset'])
rescue StandardError => e
  raise "Invalid DBProtect XML file provided Exception: #{e};\nNote that XML must be of kind `Check Results Details`."
end

Instance Method Details

#to_hdfObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/heimdall_tools/dbprotect_mapper.rb', line 22

def to_hdf
  controls = []
  @entries.each do |entry|
    @item = {}
    @item['id']                 = entry['Check ID']
    @item['title']              = entry['Check']
    @item['desc']               = format_desc(entry)
    @item['impact']             = impact(entry['Risk DV'])
    @item['tags']               = {}
    @item['descriptions']       = []
    @item['refs']               = NA_ARRAY
    @item['source_location']    = NA_HASH
    @item['code']               = ''
    @item['results']            = finding(entry)

    controls << @item
  end
  controls = collapse_duplicates(controls)
  results = HeimdallDataFormat.new(profile_name: @entries.first['Policy'],
                                   version: '',
                                   title: @entries.first['Job Name'],
                                   summary: format_summary(@entries.first),
                                   controls: controls)
  results.to_hdf
end