Class: Utils::ToXCCDF

Inherits:
Object show all
Defined in:
lib/utilities/xccdf/to_xccdf.rb

Overview

Data conversions for Inspec output into XCCDF format.

Instance Method Summary collapse

Constructor Details

#initialize(attribute, data) ⇒ ToXCCDF

Returns a new instance of ToXCCDF.

Parameters:

  • attribute (Hash)

    XCCDF supplemental attributes

  • data (Hash)

    Converted Inspec output data



8
9
10
11
12
# File 'lib/utilities/xccdf/to_xccdf.rb', line 8

def initialize(attribute, data)
  @attribute = attribute
  @data = data
  @benchmark = HappyMapperTools::Benchmark::Benchmark.new
end

Instance Method Details

#to_xml(metadata) ⇒ Object

Build entire XML document and produce final output

Parameters:

  • metadata (Hash)

    Data representing a system under scan



16
17
18
19
20
21
22
# File 'lib/utilities/xccdf/to_xccdf.rb', line 16

def to_xml()
  build_benchmark_header
  build_groups
  # Only populate results if a target is defined so that conformant XML is produced.
  @benchmark.testresult = build_test_results() if ['fqdn']
  @benchmark.to_xml
end