Class: AbideDevUtils::XCCDF::XccdfElement

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

Direct Known Subclasses

CisControl, Profile, StigControl

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::CIS_TITLE_MARKER, Common::CONTROL_PARTS, Common::CONTROL_PREFIX, Common::PROFILE_PARTS, Common::STIG_CONTROL_PARTS, Common::STIG_PROFILE_PARTS, Common::STIG_TITLE_MARKER, 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, #text_normalize, #validate_xccdf, #xpath

Methods inherited from XccdfObject

#control_class, #control_sort_key, #controls_class

Constructor Details

#initialize(element, benchmark) ⇒ XccdfElement

Returns a new instance of XccdfElement.



591
592
593
594
595
596
# File 'lib/abide_dev_utils/xccdf.rb', line 591

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

Instance Method Details

#hiera_title(**opts) ⇒ Object



617
618
619
620
# File 'lib/abide_dev_utils/xccdf.rb', line 617

def hiera_title(**opts)
  e_type = @element_type.include?('control') ? 'control' : 'profile'
  send("normalize_#{e_type}_name".to_sym, @xml, **opts)
end

#referenceObject



613
614
615
# File 'lib/abide_dev_utils/xccdf.rb', line 613

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

#to_hObject



598
599
600
601
602
603
604
605
606
607
# File 'lib/abide_dev_utils/xccdf.rb', line 598

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



609
610
611
# File 'lib/abide_dev_utils/xccdf.rb', line 609

def to_s
  @hash.inspect
end