Class: InspecTools::XCCDF
Overview
rubocop:disable Metrics/ClassLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/BlockLength
Instance Method Summary collapse
-
#initialize(xccdf, replace_tags = nil) ⇒ XCCDF
constructor
A new instance of XCCDF.
- #inject_metadata(metadata = '{}') ⇒ Object
- #published ⇒ Object
- #publisher ⇒ Object
-
#to_attributes ⇒ Object
extracts non-InSpec attributes.
- #to_ckl ⇒ Object
- #to_csv ⇒ Object
- #to_inspec ⇒ Object
Constructor Details
#initialize(xccdf, replace_tags = nil) ⇒ XCCDF
Returns a new instance of XCCDF.
15 16 17 18 19 20 21 22 |
# File 'lib/inspec_tools/xccdf.rb', line 15 def initialize(xccdf, = nil) @xccdf = xccdf @xccdf = (, @xccdf) unless .nil? cci_list_path = File.join(File.dirname(__FILE__), '../data/U_CCI_List.xml') @cci_items = HappyMapperTools::CCIAttributes::CCI_List.parse(File.read(cci_list_path)) # @cci_items = HappyMapperTools::CCIAttributes::CCI_List.parse(File.read('./data/U_CCI_List.xml')) @benchmark = HappyMapperTools::StigAttributes::Benchmark.parse(@xccdf) end |
Instance Method Details
#inject_metadata(metadata = '{}') ⇒ Object
83 84 85 86 87 88 |
# File 'lib/inspec_tools/xccdf.rb', line 83 def ( = '{}') = JSON.parse() .each do |key, value| @profile[key] = value end end |
#published ⇒ Object
79 80 81 |
# File 'lib/inspec_tools/xccdf.rb', line 79 def published @benchmark.release_date.release_date end |
#publisher ⇒ Object
75 76 77 |
# File 'lib/inspec_tools/xccdf.rb', line 75 def publisher @benchmark.reference.dc_publisher end |
#to_attributes ⇒ Object
extracts non-InSpec attributes
TODO there may be more attributes we want to extract, see data/attributes.yml for example
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/inspec_tools/xccdf.rb', line 45 def to_attributes # rubocop:disable Metrics/AbcSize @attribute = {} @attribute['benchmark.title'] = @benchmark.title @attribute['benchmark.id'] = @benchmark.id @attribute['benchmark.description'] = @benchmark.description @attribute['benchmark.version'] = @benchmark.version @attribute['benchmark.status'] = @benchmark.status @attribute['benchmark.status.date'] = @benchmark.release_date.release_date @attribute['benchmark.notice.id'] = @benchmark.notice.id @attribute['benchmark.plaintext'] = @benchmark.plaintext.plaintext @attribute['benchmark.plaintext.id'] = @benchmark.plaintext.id @attribute['reference.href'] = @benchmark.reference.href @attribute['reference.dc.publisher'] = @benchmark.reference.dc_publisher @attribute['reference.dc.source'] = @benchmark.reference.dc_source @attribute['reference.dc.title'] = @benchmark.group[0].rule.reference.dc_title if !@benchmark.group[0].nil? @attribute['reference.dc.subject'] = @benchmark.group[0].rule.reference.dc_subject if !@benchmark.group[0].nil? @attribute['reference.dc.type'] = @benchmark.group[0].rule.reference.dc_type if !@benchmark.group[0].nil? @attribute['reference.dc.identifier'] = @benchmark.group[0].rule.reference.dc_identifier if !@benchmark.group[0].nil? @attribute['content_ref.name'] = @benchmark.group[0].rule.check.content_ref.name if !@benchmark.group[0].nil? @attribute['content_ref.href'] = @benchmark.group[0].rule.check.content_ref.href if !@benchmark.group[0].nil? @attribute end |
#to_ckl ⇒ Object
24 25 26 |
# File 'lib/inspec_tools/xccdf.rb', line 24 def to_ckl # TODO: to_ckl end |
#to_csv ⇒ Object
28 29 30 |
# File 'lib/inspec_tools/xccdf.rb', line 28 def to_csv # TODO: to_csv end |
#to_inspec ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/inspec_tools/xccdf.rb', line 32 def to_inspec @profile = {} @controls = [] insert_controls @profile['sha256'] = Digest::SHA256.hexdigest @profile.to_s @profile end |