Class: GemBasedRuleRepo

Inherits:
Object show all
Defined in:
lib/cfn-nag/rule_repos/gem_based_rule_repo.rb

Instance Method Summary collapse

Instance Method Details

#discover_rulesObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cfn-nag/rule_repos/gem_based_rule_repo.rb', line 7

def discover_rules
  rule_registry = RuleRegistry.new

  rule_gem_names.each do |rule_gem_name|
    next unless load_gem_entrypoint(rule_gem_name)

    gem_path = Gem.loaded_specs[rule_gem_name].full_gem_path
    require_all_rb_files_in_gem gem_path, rule_gem_name
  end

  unless rule_gem_names.empty?
    ObjectSpace.each_object do |object|
      if derives_from_base_rule?(object) || (object.respond_to?(:cfn_nag_rule?) && object.cfn_nag_rule?)
        rule_registry.definition(object)
      end
    end
  end

  rule_registry
end