Class: FileBasedRuleRepo

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

Overview

This is really the traditional implementation for CustomRuleLoader that looks in cfn-nag/custom_rules and an optional directory of a client’s choosing

Instance Method Summary collapse

Constructor Details

#initialize(rule_directory) ⇒ FileBasedRuleRepo

Returns a new instance of FileBasedRuleRepo.



11
12
13
14
# File 'lib/cfn-nag/rule_repos/file_based_rule_repo.rb', line 11

def initialize(rule_directory)
  @rule_directory = rule_directory
  validate_extra_rule_directory rule_directory
end

Instance Method Details

#discover_rulesObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cfn-nag/rule_repos/file_based_rule_repo.rb', line 16

def discover_rules
  rule_registry = RuleRegistry.new

  # we look on the file system, and we load from the file system into a Class
  # that the runtime can refer back to later from the registry which is effectively
  # just a set of rule definitons
  discover_rule_classes(@rule_directory).each do |rule_class|
    rule_registry.definition(rule_class)
  end

  rule_registry
end