Class: AbideDevUtils::XCCDF::XccdfElement

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/abide_dev_utils/xccdf.rb

Direct Known Subclasses

Control, Profile

Constant Summary

Constants included from Common

Common::CIS_CONTROL_NUMBER, Common::CIS_CONTROL_PARTS, Common::CIS_LEVEL_CODE, Common::CIS_NEXT_GEN_WINDOWS, Common::CIS_PROFILE_PARTS, Common::CONTROL_PREFIX, Common::UNDERSCORED, Common::XPATHS

Instance Method Summary collapse

Methods included from Common

#==, #abide_object?, #control_parts, #control_profile_text, #name_normalize_control, #normalize_control_name, #normalize_profile_name, #normalize_string, #number_normalize_control, #profile_parts, #sorted_control_classes, #sorted_profile_classes, #text_normalize, #validate_xccdf, #xpath

Constructor Details

#initialize(element) ⇒ XccdfElement

Returns a new instance of XccdfElement.



479
480
481
482
483
# File 'lib/abide_dev_utils/xccdf.rb', line 479

def initialize(element)
  @xml = element
  @element_type = self.class.name.split('::').last.downcase
  @raw_title = control_profile_text(element)
end

Instance Method Details

#hiera_title(**opts) ⇒ Object



504
505
506
# File 'lib/abide_dev_utils/xccdf.rb', line 504

def hiera_title(**opts)
  send("normalize_#{@element_type}_name".to_sym, @xml, **opts)
end

#referenceObject



500
501
502
# File 'lib/abide_dev_utils/xccdf.rb', line 500

def reference
  @reference ||= @element_type == 'control' ? @xml['idref'] : @xml['id']
end

#to_hObject



485
486
487
488
489
490
491
492
493
494
# File 'lib/abide_dev_utils/xccdf.rb', line 485

def to_h
  @properties.each_with_object({}) do |pair, hash|
    hash[pair[0]] = if pair[1].nil?
                      send(pair[0])
                    else
                      obj = send(pair[0])
                      obj.send(pair[1])
                    end
  end
end

#to_sObject



496
497
498
# File 'lib/abide_dev_utils/xccdf.rb', line 496

def to_s
  @hash.inspect
end