lib/puppetx/simp/compliance_mapper.rb
def list_puppet_params(profile_list)
      v1_table = {}
      v2_table = {}

      # Set the keys in reverse order. This means that [ 'disa', 'nist'] would prioritize
      # disa values over nist. Only bother to store the highest priority value
      profile_list.reverse.each do |profile_map|
        # If we see no version tag, we know that this profile map must be
        # version 1, and we run the legacy code for the v1 compiler
        unless profile_map =~ /^v[0-9]+/

          @compliance_data.each do |filename, map|
            # Assume version 1 if no version is specified.
            # Due to old archaic code
            version = SemanticPuppet::Version.parse('1.0.0')

            if map.key?("version")
              version = SemanticPuppet::Version.parse(map["version"])
            end

            if version.major == 1
              v1_data = v1_parser(profile_map, map)

              result = {}
              # Convert this into what cook() is looking for
              v1_data.each do |item, data|
                result[item] = {
                  'parameter' => item,
                  'value'     => data['value'],
                  'type'      => 'puppet',
                  'settings'  => {
                    'parameter' => item,
                    'value'     => data['value']
                  }
                }
              end

              v1_table.merge!(result)
            end
          end

          # v2 application
          begin
            v2_table = v2.list_puppet_params(profile_list)
          rescue Exception => ex
            raise ex
          end
        end
      end

      table = v1_table.merge!(v2_table)

      control_list.new(table)
    end
# NOTE To ensure backwards compatability, we need to take steps to ensure that
# the v1 and v2 compilers both work without stepping on each-others' toes.
NOTE To ensure backwards compatability, we need to take steps to ensure that
the v1 and v2 compilers both work without stepping on each-others' toes.
NOTE To ensure backwards compatability we need to take steps to ensure that the v1 and v2 compilers both work without stepping on each - others ' toes .
def list_puppet_params(profile_list)
      v1_table = {}
      v2_table = {}
      profile_list.reverse.each do |profile_map|
        unless profile_map =~ /^v[0-9]+/
          @compliance_data.each do |filename, map|
            version = SemanticPuppet::Version.parse('1.0.0')
            if map.key?("version")
              version = SemanticPuppet::Version.parse(map["version"])
            end
            if version.major == 1
              v1_data = v1_parser(profile_map, map)
              result = {}
              v1_data.each do |item, data|
                result[item] = {
                  'parameter' => item,
                  'value'     => data['value'],
                  'type'      => 'puppet',
                  'settings'  => {
                    'parameter' => item,
                    'value'     => data['value']
                  }
                }
              end
              v1_table.merge!(result)
            end
          end
          begin
            v2_table = v2.list_puppet_params(profile_list)
          rescue Exception => ex
            raise ex
          end
        end
      end
      table = v1_table.merge!(v2_table)
      control_list.new(table)
    end
def list_puppet_params ( profile_list ) v1_table = { } v2_table = { } profile_list . reverse . each do | profile_map | unless profile_map =~ / ^v[0-9]+ / @compliance_data . each do | filename , map | version = SemanticPuppet :: Version . parse ( '1.0.0' ) if map . key? ( "version" ) version = SemanticPuppet :: Version . parse ( map [ "version" ] ) end if version . major == 1 v1_data = v1_parser ( profile_map , map ) result = { } v1_data . each do | item , data | result [ item ] = { 'parameter' => item , 'value' => data [ 'value' ] , 'type' => 'puppet' , 'settings' => { 'parameter' => item , 'value' => data [ 'value' ] } } end v1_table . merge! ( result ) end end begin v2_table = v2 . list_puppet_params ( profile_list ) rescue Exception => ex raise ex end end end table = v1_table . merge! ( v2_table ) control_list . new ( table ) end
NOTE To ensure backwards compatability, we need to take steps to ensure that
the v1 and v2 compilers both work without stepping on each-others' toes.
NOTE To ensure backwards compatability we need to take steps to ensure that the v1 and v2 compilers both work without stepping on each - others ' toes .
# Set the keys in reverse order. This means that [ 'disa', 'nist'] would prioritize # disa values over nist. Only bother to store the highest priority value # If we see no version tag, we know that this profile map must be # version 1, and we run the legacy code for the v1 compiler # Assume version 1 if no version is specified. # Due to old archaic code # Convert this into what cook() is looking for # v2 application
profile_list