Module: AbideDevUtils::CEM::HieraData::MappingData::MixinCIS

Defined in:
lib/abide_dev_utils/cem/hiera_data/mapping_data/mixins.rb

Overview

Mixin module used by Mapper to implement CIS-specific mapping behavior

Instance Method Summary collapse

Instance Method Details

#get_map(control_id, level: nil, profile: nil, **_) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/abide_dev_utils/cem/hiera_data/mapping_data/mixins.rb', line 9

def get_map(control_id, level: nil, profile: nil, **_)
  identified_map_data(control_id, valid_types: CIS_TYPES).get(control_id, level: level, profile: profile)
  return unless imdata

  if level.nil? || profile.nil?
    map_data[mtype][mtop].each do |lvl, profile_hash|
      next if lvl == 'benchmark' || (level && level != lvl)

      profile_hash.each do |prof, control_hash|
        next if profile && profile != prof

        return control_hash[control_id] if control_hash.key?(control_id)
      end
    end
  else
    imdata[level][profile][control_id]
  end
end